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

[jira] [Commented] (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:comment-tabpanel&focusedCommentId=13791078#comment-13791078 ] 

ASF subversion and git services commented on CB-5021:
-----------------------------------------------------

Commit ef5eddac9add2200e91a846cdea9e54d66b66074 in branch refs/heads/dev from [~agrieve]
[ https://git-wip-us.apache.org/repos/asf?p=cordova-plugin-inappbrowser.git;h=ef5edda ]

CB-5021 Make it safe to call close() multiple times


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