cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon MacDonald <simon.macdon...@gmail.com>
Subject Re: android commit: Fix exception when plugin returns a null string.
Date Thu, 25 Oct 2012 15:04:52 GMT
Hey Andrew,

It is quite easy to reproduce. If you PluginResult is constructed like this:

String result = null;

return new PluginResult(status, result);
Obviously, that is a contrived example but the actual place we ran into
this was getting a shared preference that wasn't set so it returned a null
which we passed back to the JS side and that's where things fell down.

Simon Mac Donald
http://hi.im/simonmacdonald


On Thu, Oct 25, 2012 at 10:52 AM, Andrew Grieve <agrieve@google.com> wrote:

> Hey Bryce,
>
> I don't think this change is quite correct. Looks like it's converting null
> into an empty string. How did you run into this? Mobile spec? If it's
> something we need to support (looks like it is, iOS handles it at least),
> it'll need JS changes as well, so will need another re-tag. Worth it?
>
>
>
>
> On Wed, Oct 24, 2012 at 2:37 PM, <bcurtis@apache.org> wrote:
>
> > Updated Branches:
> >   refs/heads/master 7d3afcab9 -> cba0d5902
> >
> >
> > Fix exception when plugin returns a null string.
> >
> >
> > Project:
> > http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/repo
> > Commit:
> >
> http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/commit/cba0d590
> > Tree:
> >
> http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/cba0d590
> > Diff:
> >
> http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/cba0d590
> >
> > Branch: refs/heads/master
> > Commit: cba0d59021a2562af6888050a171d4ba3cdbe47e
> > Parents: 7d3afca
> > Author: Bryce Curtis <curtis.bryce@gmail.com>
> > Authored: Wed Oct 24 12:36:30 2012 -0600
> > Committer: Bryce Curtis <curtis.bryce@gmail.com>
> > Committed: Wed Oct 24 12:36:30 2012 -0600
> >
> > ----------------------------------------------------------------------
> >  .../org/apache/cordova/NativeToJsMessageQueue.java |   13 ++++++++++---
> >  1 files changed, 10 insertions(+), 3 deletions(-)
> > ----------------------------------------------------------------------
> >
> >
> >
> >
> http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/cba0d590/framework/src/org/apache/cordova/NativeToJsMessageQueue.java
> > ----------------------------------------------------------------------
> > diff --git a/framework/src/org/apache/cordova/NativeToJsMessageQueue.java
> > b/framework/src/org/apache/cordova/NativeToJsMessageQueue.java
> > index 55fa205..03a69b1 100755
> > --- a/framework/src/org/apache/cordova/NativeToJsMessageQueue.java
> > +++ b/framework/src/org/apache/cordova/NativeToJsMessageQueue.java
> > @@ -398,7 +398,12 @@ public class NativeToJsMessageQueue {
> >                      ret += 1 + pluginResult.getMessage().length();
> >                      break;
> >                  case PluginResult.MESSAGE_TYPE_STRING: // s
> > -                    ret += 1 + pluginResult.getStrMessage().length();
> > +                    if (pluginResult.getStrMessage() == null) {
> > +                        ret += 1;
> > +                    }
> > +                    else {
> > +                        ret += 1 +
> pluginResult.getStrMessage().length();
> > +                    }
> >                      break;
> >                  case PluginResult.MESSAGE_TYPE_JSON:
> >                  default:
> > @@ -433,8 +438,10 @@ public class NativeToJsMessageQueue {
> >                        .append(pluginResult.getMessage());
> >                      break;
> >                  case PluginResult.MESSAGE_TYPE_STRING: // s
> > -                    sb.append('s')
> > -                      .append(pluginResult.getStrMessage());
> > +                    sb.append('s');
> > +                    if (pluginResult.getStrMessage() != null) {
> > +                        sb.append(pluginResult.getStrMessage());
> > +                    }
> >                      break;
> >                  case PluginResult.MESSAGE_TYPE_JSON:
> >                  default:
> >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message