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

Andrea Turli updated JCLOUDS-1044:
----------------------------------
    Fix Version/s: 1.9.3

> MapTypeAdapter and IterableTypeAdapter doesn't handle NULL values correctly
> ---------------------------------------------------------------------------
>
>                 Key: JCLOUDS-1044
>                 URL: https://issues.apache.org/jira/browse/JCLOUDS-1044
>             Project: jclouds
>          Issue Type: Bug
>          Components: jclouds-core
>    Affects Versions: 1.9.1, 2.0.0
>            Reporter: Josef Cacek
>            Priority: Critical
>             Fix For: 2.0.0, 1.9.3
>
>
> 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:
> {code}
> Map<String, List<Map<String, String>>>
> {code}
> and JSON to reproduce the issue:
> {code}
> {"value":[null]}
> {code}
> or another one:
> {code}
> {"value":null}
> {code}
> The stacktrace then can look like:
> {code}
> 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
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to