Uploaded image for project: 'jclouds'
  1. jclouds
  2. JCLOUDS-1044

MapTypeAdapter and IterableTypeAdapter doesn't handle NULL values correctly

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 1.9.1, 2.0.0
    • Fix Version/s: 2.0.0, 1.9.3
    • Component/s: jclouds-core
    • Labels:
      None

      Description

      JSON deserialization fails for null values in "inner collections/maps".
      The adapters in NullFilteringTypeAdapterFactories are missing check for JsonToken.NULL

      Sample Java type, which can hit the problem:

      Map<String, List<Map<String, String>>>
      

      and JSON to reproduce the issue:

      {"value":[null]}
      

      or another one:

      {"value":null}
      

      The stacktrace then can look like:

      21:50:57.824 [main] ERROR org.jclouds.http.functions.ParseJson - Error parsing input: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was NULL at line 1 column 3791 path $.NetworkSettings.Ports.
      com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was NULL at line 1 column 3791 path $.NetworkSettings.Ports.
      	at org.jclouds.json.internal.DeserializationConstructorAndReflectiveTypeAdapterFactory$DeserializeIntoParameterizedConstructor.read(DeserializationConstructorAndReflectiveTypeAdapterFactory.java:190) ~[jclouds-core-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT]
      	at org.jclouds.json.internal.DeserializationConstructorAndReflectiveTypeAdapterFactory$ParameterReader.read(DeserializationConstructorAndReflectiveTypeAdapterFactory.java:272) ~[jclouds-core-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT]
      	at org.jclouds.json.internal.DeserializationConstructorAndReflectiveTypeAdapterFactory$DeserializeIntoParameterizedConstructor.read(DeserializationConstructorAndReflectiveTypeAdapterFactory.java:184) ~[jclouds-core-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT]
      	at com.google.gson.Gson.fromJson(Gson.java:810) ~[gson-2.3.1.jar:na]
      	at com.google.gson.Gson.fromJson(Gson.java:775) ~[gson-2.3.1.jar:na]
      	at com.google.gson.Gson.fromJson(Gson.java:724) ~[gson-2.3.1.jar:na]
      	at org.jclouds.json.internal.GsonWrapper.fromJson(GsonWrapper.java:42) ~[jclouds-core-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT]
      	at org.jclouds.http.functions.ParseJson.apply(ParseJson.java:83) [jclouds-core-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT]
      	at org.jclouds.http.functions.ParseJson.apply(ParseJson.java:77) [jclouds-core-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT]
      	at org.jclouds.http.functions.ParseJson.apply(ParseJson.java:62) [jclouds-core-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT]
      	at org.jclouds.http.functions.ParseJson.apply(ParseJson.java:42) [jclouds-core-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT]
      	at org.jclouds.rest.internal.InvokeHttpMethod.invoke(InvokeHttpMethod.java:90) [jclouds-core-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT]
      	at org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:73) [jclouds-core-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT]
      	at org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:44) [jclouds-core-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT]
      	at org.jclouds.reflect.FunctionalReflection$FunctionalInvocationHandler.handleInvocation(FunctionalReflection.java:117) [jclouds-core-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT]
      	at com.google.common.reflect.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:87) [guava-18.0.jar:na]
      	at com.sun.proxy.$Proxy77.inspectContainer(Unknown Source) [na:na]
      	at org.jclouds.docker.compute.strategy.DockerComputeServiceAdapter.listNodes(DockerComputeServiceAdapter.java:214) [docker-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT]
      	at org.jclouds.compute.strategy.impl.AdaptingComputeServiceStrategies.listDetailsOnNodesMatching(AdaptingComputeServiceStrategies.java:122) [jclouds-compute-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT]
      	at org.jclouds.compute.strategy.impl.AdaptingComputeServiceStrategies.listNodes(AdaptingComputeServiceStrategies.java:112) [jclouds-compute-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT]
      	at org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThenAddToSet.getNextNames(CreateNodesWithGroupEncodedIntoNameThenAddToSet.java:192) [jclouds-compute-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT]
      	at org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThenAddToSet.execute(CreateNodesWithGroupEncodedIntoNameThenAddToSet.java:121) [jclouds-compute-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT]
      	at org.jclouds.compute.internal.BaseComputeService.createNodesInGroup(BaseComputeService.java:210) [jclouds-compute-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT]
      <cut>
      Caused by: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was NULL at line 1 column 3791 path $.NetworkSettings.Ports.
      	at com.google.gson.stream.JsonReader.beginArray(JsonReader.java:350) ~[gson-2.3.1.jar:na]
      	at org.jclouds.json.internal.NullFilteringTypeAdapterFactories$IterableTypeAdapter.readAndBuild(NullFilteringTypeAdapterFactories.java:88) ~[jclouds-core-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT]
      	at org.jclouds.json.internal.NullFilteringTypeAdapterFactories$IterableTypeAdapter.read(NullFilteringTypeAdapterFactories.java:82) ~[jclouds-core-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT]
      	at org.jclouds.json.internal.NullFilteringTypeAdapterFactories$IterableTypeAdapter.read(NullFilteringTypeAdapterFactories.java:61) ~[jclouds-core-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT]
      	at org.jclouds.json.internal.NullFilteringTypeAdapterFactories$MapTypeAdapter.read(NullFilteringTypeAdapterFactories.java:311) ~[jclouds-core-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT]
      	at org.jclouds.json.internal.NullFilteringTypeAdapterFactories$MapTypeAdapter.read(NullFilteringTypeAdapterFactories.java:281) ~[jclouds-core-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT]
      	at org.jclouds.json.internal.DeserializationConstructorAndReflectiveTypeAdapterFactory$ParameterReader.read(DeserializationConstructorAndReflectiveTypeAdapterFactory.java:272) ~[jclouds-core-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT]
      	at org.jclouds.json.internal.DeserializationConstructorAndReflectiveTypeAdapterFactory$DeserializeIntoParameterizedConstructor.read(DeserializationConstructorAndReflectiveTypeAdapterFactory.java:184) ~[jclouds-core-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT]
      	... 52 common frames omitted
      

        Issue Links

          Activity

          Hide
          kwart Josef Cacek added a comment -
          Show
          kwart Josef Cacek added a comment - PR sent: https://github.com/jclouds/jclouds/pull/887
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 0fb1b459a607f21f6a8ebd7492879d02553c4b88 in jclouds's branch refs/heads/master from Josef Cacek
          [ https://git-wip-us.apache.org/repos/asf?p=jclouds.git;h=0fb1b45 ]

          JCLOUDS-1044 fix handling NULL JsonTokens in adapters under NullFilteringTypeAdapterFactories class

          Show
          jira-bot ASF subversion and git services added a comment - Commit 0fb1b459a607f21f6a8ebd7492879d02553c4b88 in jclouds's branch refs/heads/master from Josef Cacek [ https://git-wip-us.apache.org/repos/asf?p=jclouds.git;h=0fb1b45 ] JCLOUDS-1044 fix handling NULL JsonTokens in adapters under NullFilteringTypeAdapterFactories class
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 7016b040d79e671b41dac06f877a54139ad4def7 in jclouds's branch refs/heads/1.9.x from Josef Cacek
          [ https://git-wip-us.apache.org/repos/asf?p=jclouds.git;h=7016b04 ]

          JCLOUDS-1044 fix handling NULL JsonTokens in adapters under NullFilteringTypeAdapterFactories class

          Show
          jira-bot ASF subversion and git services added a comment - Commit 7016b040d79e671b41dac06f877a54139ad4def7 in jclouds's branch refs/heads/1.9.x from Josef Cacek [ https://git-wip-us.apache.org/repos/asf?p=jclouds.git;h=7016b04 ] JCLOUDS-1044 fix handling NULL JsonTokens in adapters under NullFilteringTypeAdapterFactories class

            People

            • Assignee:
              Unassigned
              Reporter:
              kwart Josef Cacek
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development