Fix NPE in AppHarnessUI when events are sent and no one is listening
Project: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/commit/32145b81 Tree: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/tree/32145b81 Diff: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/diff/32145b81 Branch: refs/heads/master Commit: 32145b8115c7b035077f46e5586a321cf450dd79 Parents: 7e9f136 Author: Andrew Grieve <[email protected]> Authored: Tue Jun 17 16:22:29 2014 -0400 Committer: Andrew Grieve <[email protected]> Committed: Tue Jun 17 16:40:02 2014 -0400 ---------------------------------------------------------------------- AppHarnessUI/AppHarnessUI.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/32145b81/AppHarnessUI/AppHarnessUI.java ---------------------------------------------------------------------- diff --git a/AppHarnessUI/AppHarnessUI.java b/AppHarnessUI/AppHarnessUI.java index b3cfc16..588109f 100644 --- a/AppHarnessUI/AppHarnessUI.java +++ b/AppHarnessUI/AppHarnessUI.java @@ -91,9 +91,11 @@ public class AppHarnessUI extends CordovaPlugin { } private void sendEvent(String eventName) { - PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, eventName); - pluginResult.setKeepCallback(true); - eventsCallback.sendPluginResult(pluginResult ); + if (eventsCallback != null) { + PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, eventName); + pluginResult.setKeepCallback(true); + eventsCallback.sendPluginResult(pluginResult ); + } } @SuppressLint("NewApi")
