Project: titanium
Issue TIMOB-16562: Android: Kroll bridge passing null/undefined values can throw exceptions when passed to TiConvert methods
h5. Problem Description Exception is thrown when passing objects with null/undefined values for expected keys values on Android. Ti.map.TiUIMapView passes this null value to TiConvert.toDouble which causes then throws a NullPointerException. Here is an example piece of code when setting a map region. This works fine on iOS: {code} function setup(event) { $.map.region = { latitude: 36, longitude: -78, latitudeDelta: null, longitudeDelta: null }; } {code} Here is the exception on Android: {code} [ERROR] : TiApplication: (main) [1830,1830] Sending event: exception on thread: main msg:java.lang.NullPointerException; Titanium 3.2.0,2013/12/20 10:57,d9182d6 [ERROR] : TiApplication: java.lang.NullPointerException [ERROR] : TiApplication: at org.appcelerator.titanium.util.TiConvert.toDouble(TiConvert.java:527) [ERROR] : TiApplication: at org.appcelerator.titanium.util.TiConvert.toDouble(TiConvert.java:540) [ERROR] : TiApplication: at ti.map.TiUIMapView.updateCamera(TiUIMapView.java:247) [ERROR] : TiApplication: at ti.map.TiUIMapView.propertyChanged(TiUIMapView.java:171) [ERROR] : TiApplication: at org.appcelerator.kroll.KrollPropertyChange.fireEvent(KrollPropertyChange.java:21) [ERROR] : TiApplication: at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1059) [ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:329) [ERROR] : TiApplication: at ti.map.ViewProxy.handleMessage(ViewProxy.java:150) [ERROR] : TiApplication: at android.os.Handler.dispatchMessage(Handler.java:95) [ERROR] : TiApplication: at android.os.Looper.loop(Looper.java:158) [ERROR] : TiApplication: at android.app.ActivityThread.main(ActivityThread.java:5789) [ERROR] : TiApplication: at java.lang.reflect.Method.invokeNative(Native Method) [ERROR] : TiApplication: at java.lang.reflect.Method.invoke(Method.java:525) [ERROR] : TiApplication: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027) [ERROR] : TiApplication: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:843) [ERROR] : TiApplication: at dalvik.system.NativeStart.main(Native Method) {code} This the kroll bridge should either ignore null/undefined values or have each have maps module defensively check for null values. I've attached a project showcases the error.
Story points: 8