Skip to content
This repository was archived by the owner on Jun 3, 2021. It is now read-only.

Commit b94e830

Browse files
YorkShenlucky-chen
authored andcommitted
[Android] Fix ClassCastException in WXComponent.updateProperties() (#2897)
``` java.lang.ClassCastException: java.lang.Object[] cannot be cast to java.lang.String at com.taobao.weex.ui.component.WXComponent.updateProperties(WXComponent.java:710) at com.taobao.weex.ui.component.WXComponent.updateAttrs(WXComponent.java:274) at com.taobao.weex.ui.component.WXComponent.bindData(WXComponent.java:663) at CustomComponent.bindData(InteractiveVideoComponentV2.java:638) at com.taobao.weex.ui.component.WXVContainer.bindData(WXVContainer.java:166) ```
1 parent 4ce557b commit b94e830

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

android/sdk/src/main/java/com/taobao/weex/common/WXErrorCode.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ public enum WXErrorCode {
219219
WX_RENDER_ERR_NULL_KEY("-9603", "WX_RENDER_ERR_NULL_KEY", ErrorType.NATIVE_ERROR, ErrorGroup.NATIVE),
220220
WX_RENDER_ERR_NATIVE_RUNTIME("-9604", "WX_RENDER_ERR for js error", ErrorType.RENDER_ERROR, ErrorGroup.NATIVE),
221221
WX_RENDER_ERR_COMPONENT_NOT_REGISTER("-9605", "WX_RENDER_ERR_COMPONENT_NOT_REGISTER", ErrorType.NATIVE_ERROR, ErrorGroup.NATIVE),
222+
WX_RENDER_ERR_COMPONENT_ATTR_KEY("-9606", "The key passed to Component.updateAttr() is not string", ErrorType.NATIVE_ERROR, ErrorGroup.JS),
222223
WX_RENDER_ERR_BRIDGE_ARG_NULL("-9610", "WX_RENDER_ERR_BRIDGE_ARG_NULL", ErrorType.NATIVE_ERROR, ErrorGroup.NATIVE),
223224
WX_RENDER_ERR_CONTAINER_TYPE("-9611", "WX_RENDER_ERR_CONTAINER_TYPE", ErrorType.JS_ERROR,ErrorGroup.JS),
224225
WX_RENDER_ERR_TRANSITION("-9616", "WX_RENDER_ERR_TRANSITION", ErrorType.JS_ERROR, ErrorGroup.JS),

android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,19 @@ public void updateProperties(Map<String, Object> props) {
707707
}
708708

709709
for (Map.Entry<String, Object> entry : props.entrySet()) {
710-
String key = entry.getKey();
710+
Object key_obj = entry.getKey();
711+
String key = WXUtils.getString(key_obj, null);
712+
if (!(key_obj instanceof String)) {
713+
Map<String, String> map = new HashMap<>();
714+
map.put("componentType", getComponentType());
715+
map.put("actual key", key == null ? "" : key);
716+
WXExceptionUtils.commitCriticalExceptionRT(getInstanceId(),
717+
WXErrorCode.WX_RENDER_ERR_COMPONENT_ATTR_KEY,
718+
"WXComponent.updateProperties",
719+
WXErrorCode.WX_RENDER_ERR_COMPONENT_ATTR_KEY.getErrorMsg(),
720+
map);
721+
}
722+
711723
Object param = entry.getValue();
712724
String value = WXUtils.getString(param, null);
713725

0 commit comments

Comments
 (0)