diff --git a/core/src/main/java/org/jclouds/json/config/GsonModule.java b/core/src/main/java/org/jclouds/json/config/GsonModule.java index 1d340cb5cd..eb607e527e 100644 --- a/core/src/main/java/org/jclouds/json/config/GsonModule.java +++ b/core/src/main/java/org/jclouds/json/config/GsonModule.java @@ -106,14 +106,14 @@ public class GsonModule extends AbstractModule { // simple (type adapters) builder.registerTypeAdapter(Properties.class, propertiesAdapter.nullSafe()); builder.registerTypeAdapter(Date.class, adapter.nullSafe()); - builder.registerTypeAdapter(new TypeToken>() { - }.getType(), byteListAdapter.nullSafe()); builder.registerTypeAdapter(byte[].class, byteArrayAdapter.nullSafe()); builder.registerTypeAdapter(JsonBall.class, jsonAdapter.nullSafe()); builder.registerTypeAdapterFactory(optional); builder.registerTypeAdapterFactory(iterable); builder.registerTypeAdapterFactory(collection); builder.registerTypeAdapterFactory(list); + builder.registerTypeAdapter(new TypeToken>() { + }.getType(), byteListAdapter.nullSafe()); builder.registerTypeAdapterFactory(immutableList); builder.registerTypeAdapterFactory(set); builder.registerTypeAdapterFactory(immutableSet); diff --git a/core/src/test/java/org/jclouds/json/JsonTest.java b/core/src/test/java/org/jclouds/json/JsonTest.java index 7d76a8508f..16ac1f91ff 100644 --- a/core/src/test/java/org/jclouds/json/JsonTest.java +++ b/core/src/test/java/org/jclouds/json/JsonTest.java @@ -18,8 +18,11 @@ */ package org.jclouds.json; +import static com.google.common.io.BaseEncoding.base16; +import static com.google.common.primitives.Bytes.asList; import static org.testng.Assert.assertEquals; +import java.util.List; import java.util.Map; import java.util.Properties; @@ -113,6 +116,17 @@ public class JsonTest { private Test enumValue; } + private static class ByteList { + List checksum; + } + + public void testByteList() { + ByteList bl = new ByteList(); + bl.checksum = asList(base16().lowerCase().decode("1dda05ed139664f1f89b9dec482b77c0")); + assertEquals(json.toJson(bl), "{\"checksum\":\"1dda05ed139664f1f89b9dec482b77c0\"}"); + assertEquals(json.fromJson(json.toJson(bl), ByteList.class).checksum, bl.checksum); + } + public void testPropertiesSerializesDefaults() { Properties props = new Properties(); props.put("string", "string");