juneau-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Bognar <james.bog...@salesforce.com>
Subject Re: ObjectMap parsing NullPointerException
Date Wed, 14 Jun 2017 18:29:02 GMT
Let me try it out.  I'll let you know.

On Wed, Jun 14, 2017 at 2:03 PM, David Goddard <goddard@acm.org> wrote:

> Hi,
>
> I'm updating some code from Juneau 6.0.1 to 6.2.0-incubating and I'm
> finding that parsing some JSON to an ObjectMap that previously worked now
> fails with a NullPointerException:
>
>   java.lang.NullPointerException
>         at org.apache.juneau.ObjectMap.parseReader(ObjectMap.java:192)
>         at org.apache.juneau.ObjectMap.<init>(ObjectMap.java:186)
>
> This is the line of application code causing it:
>
>   ObjectMap map = new ObjectMap(new StringReader(json));
>
> The JSON in this case is:
>
> {
>   "weatherinsights": [
>         {
>             "credentials": {
>                 "username": "xx",
>                 "password": "xx",
>                 "host": "twcservice.au-syd.mybluemix.net",
>                 "port": 443,
>                 "url": "xx"
>             },
>             "syslog_drain_url": null,
>             "label": "weatherinsights",
>             "provider": null,
>             "plan": "Free-v2",
>             "name": "Weather Company Data xx",
>             "tags": [
>                 "big_data",
>                 "ibm_created",
>                 "ibm_dedicated_public"
>             ]
>         }
>     ],
>    "cloudantNoSQLDB": [
>       {
>          "name": "xx",
>          "label": "cloudantNoSQLDB",
>          "plan": "Shared",
>          "credentials": {
>             "username": "xx",
>             "password": "xx",
>             "host": "xx-bluemix.cloudant.com",
>             "port": 443,
>             "url": "xx"
>          }
>       }
>    ]
> }
>
> Looking in debug, I see that the failure in ObjectMap is here:
>
>   private void parseReader(Reader r, Parser p) throws ParseException {
>         if (p == null)
>                 p = JsonParser.DEFAULT;
>         p.parseIntoMap(r, this, session.string(), session.object());
>   }
>
> This fails because the variable, session, is null.  I can't figure out
> why.  Stepping through it in debug, before it gets to this point, I see the
> ObjectMap being initialised here:
>
>         public ObjectMap(BeanSession session) {
>                 super();
>                 this.session = session;
>         }
>
> In this case, the passed value of session is *not* null:
>
>   {
>         BeanContext: {
>                 id: -981232688,
>                 beansRequireDefaultConstructor: false,
>                 beansRequireSerializable: false,
>                 beansRequireSettersForGetters: false,
>                 beansRequireSomeProperties: true,
>                 beanMapPutReturnsOldValue: false,
>                 beanConstructorVisibility: 'PUBLIC',
>                 beanClassVisibility: 'PUBLIC',
>                 beanMethodVisibility: 'PUBLIC',
>                 beanFieldVisibility: 'PUBLIC',
>                 useInterfaceProxies: true,
>                 ignoreUnknownBeanProperties: false,
>                 ignoreUnknownNullBeanProperties: true,
>                 ignorePropertiesWithoutSetters: true,
>                 ignoreInvocationExceptionsOnGetters: false,
>                 ignoreInvocationExceptionsOnSetters: false,
>                 useJavaBeanIntrospector: false,
>                 beanFilters: [
>                 ],
>                 pojoSwaps: [
>                 ],
>                 notBeanClasses: [
>                 ],
>                 implClasses: {
>                 },
>                 sortProperties: false,
>                 locale: 'en_GB',
>                 timeZone: null,
>                 mediaType: null
>         },
>         BeanSession: {
>                 locale: 'en_GB',
>                 timeZone: null
>         }
>   }
>
>
> However, by the time we get to parseReader, session *is* null.
>
> I'm obviously not ruling out something dumb on my part, but is there any
> obvious issue here, or somewhere for me to look further?
>
> Thanks,
>
> David
>



-- 
James Bognar

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