You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Andrew Grieve (JIRA)" <ji...@apache.org> on 2013/10/10 03:28:42 UTC

[jira] [Resolved] (CB-5021) Make InAppBrowser "close" more robust - avoid NPE if no matching "open"

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

Andrew Grieve resolved CB-5021.
-------------------------------

    Resolution: Fixed
      Assignee: Andrew Grieve

> 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)