Skip to content

Commit 5101238

Browse files
author
Quintin Willison
committed
Fix oversight in my base message deserialisation code, covering the case where a key is populated but with JSON null.
1 parent 7fbc7b1 commit 5101238

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

lib/src/main/java/io/ably/lib/types/BaseMessage.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.davidehrmann.vcdiff.VCDiffDecoder;
44
import com.davidehrmann.vcdiff.VCDiffDecoderBuilder;
55
import com.google.gson.JsonElement;
6+
import com.google.gson.JsonNull;
67
import com.google.gson.JsonObject;
78
import com.google.gson.JsonParseException;
89
import com.google.gson.JsonPrimitive;
@@ -241,7 +242,7 @@ protected void read(final JsonObject map) throws MessageDecodeException {
241242
*/
242243
protected String readString(final JsonObject map, final String key) {
243244
final JsonElement element = map.get(key);
244-
if (null == element) {
245+
if (null == element || element instanceof JsonNull) {
245246
return null;
246247
}
247248
return element.getAsString();
@@ -255,7 +256,7 @@ protected String readString(final JsonObject map, final String key) {
255256
*/
256257
protected Long readLong(final JsonObject map, final String key) {
257258
final JsonElement element = map.get(key);
258-
if (null == element) {
259+
if (null == element || element instanceof JsonNull) {
259260
return null;
260261
}
261262
return element.getAsLong();

0 commit comments

Comments
 (0)