Don't call deserializers with null

This commit is contained in:
Jesse Wilson 2011-09-09 08:13:50 +00:00
parent ee9ffa808a
commit f50cce6d14
2 changed files with 6 additions and 2 deletions

View File

@ -51,7 +51,11 @@ final class GsonToMiniGsonTypeAdapter implements TypeAdapter.Factory {
// TODO: handle if deserializer is null
throw new UnsupportedOperationException();
}
return deserializer.deserialize(Streams.parse(reader), typeOfT, createDeserializationContext(miniGson));
JsonElement value = Streams.parse(reader);
if (value.isJsonNull()) {
return null;
}
return deserializer.deserialize(value, typeOfT, createDeserializationContext(miniGson));
}
@Override
public void write(JsonWriter writer, Object value) throws IOException {

View File

@ -81,7 +81,7 @@ public abstract class JsonElement {
if (isJsonObject()) {
return (JsonObject) this;
}
throw new IllegalStateException("This is not a JSON Object.");
throw new IllegalStateException("Not a JSON Object: " + this);
}
/**