[ 
https://issues.apache.org/jira/browse/CB-5021?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Peter reopened CB-5021:
-----------------------


see previous comment

> Make InAppBrowser "close" more robust - avoid NPE if no matching "open"
> -----------------------------------------------------------------------
>
>                 Key: CB-5021
>                 URL: https://issues.apache.org/jira/browse/CB-5021
>             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 *InAppBrowser.java* 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 NOP.
> 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
(v6.1#6144)

Reply via email to