cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter (JIRA)" <>
Subject [jira] [Commented] (CB-5021) Make InAppBrowser "close" more robust - avoid NPE if no matching "open"
Date Thu, 10 Oct 2013 22:16:42 GMT


Peter commented on CB-5021:

Sadly I'm still not convinced this is addressing the original problem :-( but I won't have
a 3.x environment set up until next week so I am not yet in a position to test it.

The concerns are:

* since we were calling via *pluginManager.exec* (see original problem description) there
was no need to expose that closeDialog publicly. In fact, bypassing the _well defined_ 'execute'
interface and calling directly into the plugin methods doesn't really seem like a good idea
to me. 

* I expect that line _this.callbackContext.success();_ is just going to trip and fall on its
head because in the absence of any prior IAB "open" (see original problem description) the
callbackContext member will still be null when we call the exec "close"

> Make InAppBrowser "close" more robust - avoid NPE if no matching "open"
> -----------------------------------------------------------------------
>                 Key: CB-5021
>                 URL:
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android, Plugin InAppBrowser
>    Affects Versions: 2.9.0
>            Reporter: Peter
>            Assignee: Andrew Grieve
>            Priority: Minor
> We have an Android application which implements an embedded WebView "container" in which
it executes customer Cordova apps.
> Under certain conditions our container needs to terminate the customer app, and during
this termination it attempts to do some resource cleanup. For example, to cleanup any possible
lurking InAppBrowser resources it does (equivalent of a IAB.close) the following:
> {code}
> cwv.pluginManager.exec("InAppBrowser", "close", null, "[]");
> {code}
> Unfortunately, we don't really know if user app was actually using InAppBrowser or not.
> * If it _was_ using IAB, then the above exec works.
> * If it _wasn’t_ using IAB, the above exec results in NPE (inAppWebView is null) since
current ** code assumes "close" won't be called without matching "open".
> Proposed improvement below is to make the InAppBrowser’s "close" more robust, so if
it gets called in an unusual scenario (e.g. without a prior "open") then it is just a harmless
> For example,
> Before:
> {code}
> else if (action.equals("close")) {
>     closeDialog();
>     this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK));
> }
> {code}
> After:
> {code}
> else if (action.equals("close")) {
>     if (inAppWebView != null) {
>         closeDialog();
>         this.callbackContext.success();
>     }
> }
> {code}

This message was sent by Atlassian JIRA

View raw message