You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ac...@apache.org on 2017/12/29 07:36:35 UTC
incubator-weex git commit: [WEEX-169] [android] Fix new String null
pointer crash when byte array is null close #938
Repository: incubator-weex
Updated Branches:
refs/heads/master ec3db1355 -> 11a1f3eaf
[WEEX-169] [android] Fix new String null pointer crash when byte array is null
close #938
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/11a1f3ea
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/11a1f3ea
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/11a1f3ea
Branch: refs/heads/master
Commit: 11a1f3eafb33034d4766d077a66a4a924a519a4d
Parents: ec3db13
Author: yuhun-alibaba <to...@gmail.com>
Authored: Mon Dec 11 16:45:54 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Fri Dec 29 15:35:04 2017 +0800
----------------------------------------------------------------------
.../java/com/taobao/weex/bridge/WXBridge.java | 30 ++++++++++++++++----
1 file changed, 24 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/11a1f3ea/android/sdk/src/main/java/com/taobao/weex/bridge/WXBridge.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/bridge/WXBridge.java b/android/sdk/src/main/java/com/taobao/weex/bridge/WXBridge.java
index ca2d08a..06fdaf4 100644
--- a/android/sdk/src/main/java/com/taobao/weex/bridge/WXBridge.java
+++ b/android/sdk/src/main/java/com/taobao/weex/bridge/WXBridge.java
@@ -107,7 +107,15 @@ class WXBridge implements IWXBridge {
*/
public int callNative(String instanceId, byte [] tasks, String callback) {
+ try {
return callNative(instanceId,new String(tasks),callback);
+ } catch (Throwable e) {
+ //catch everything during call native.
+ // if(WXEnvironment.isApkDebugable()){
+ WXLogUtils.e(TAG,"callNative throw exception:"+e.getMessage());
+ // }
+ return 0;
+ }
}
public int callNative(String instanceId, String tasks, String callback) {
@@ -137,7 +145,12 @@ class WXBridge implements IWXBridge {
return errorCode;
}
public int callAddElement(String instanceId, String ref,byte[] dom,String index, String callback) {
- return callAddElement(instanceId,ref, new String(dom),index,callback);
+ try {
+ return callAddElement(instanceId,ref,new String(dom),index,callback);
+ } catch (Throwable e) {
+ WXLogUtils.e(TAG,"callAddElement throw exception:"+e.getMessage());
+ return 0;
+ }
}
/**
@@ -149,7 +162,12 @@ class WXBridge implements IWXBridge {
*/
public int callCreateBody(String instanceId, byte [] tasks, String callback) {
- return callCreateBody(instanceId,new String(tasks),callback);
+ try {
+ return callCreateBody(instanceId, new String(tasks),callback);
+ } catch (Throwable e) {
+ WXLogUtils.e(TAG,"callCreateBody throw exception:"+e.getMessage());
+ return 0;
+ }
}
public int callCreateBody(String instanceId, String tasks, String callback) {
@@ -231,10 +249,10 @@ class WXBridge implements IWXBridge {
@Override
public Object callNativeModule(String instanceId, String module, String method, byte [] arguments, byte [] options) {
- JSONArray argArray = JSON.parseArray(new String(arguments));
+ JSONArray argArray = JSON.parseArray(arguments == null ? new String("") : new String(arguments));
JSONObject optionsObj = null;
if (options != null) {
- optionsObj = JSON.parseObject(new String(options));
+ optionsObj = JSON.parseObject(options == null ? new String("") :new String(options));
}
Object object = WXBridgeManager.getInstance().callNativeModule(instanceId,module,method,argArray,optionsObj);
return new WXJSObject(object);
@@ -250,7 +268,7 @@ class WXBridge implements IWXBridge {
*/
@Override
public void callNativeComponent(String instanceId, String componentRef, String method, byte [] arguments, byte [] options) {
- JSONArray argArray = JSON.parseArray(new String(arguments));
+ JSONArray argArray = JSON.parseArray(arguments == null ? new String("") : new String(arguments));
WXBridgeManager.getInstance().callNativeComponent(instanceId,componentRef,method,argArray,options);
}
@@ -369,7 +387,7 @@ class WXBridge implements IWXBridge {
}
int errorCode = IWXBridge.INSTANCE_RENDERING;
try {
- errorCode = WXBridgeManager.getInstance().callUpdateAttrs(instanceId, ref, new String(tasks), callback);
+ errorCode = WXBridgeManager.getInstance().callUpdateAttrs(instanceId, ref, tasks == null ? new String("") : new String(tasks), callback);
} catch (Throwable e) {
//catch everything during call native.
if(WXEnvironment.isApkDebugable()){