Skip to content

Commit

Permalink
Fix oversight in my base message deserialisation code, covering the c…
Browse files Browse the repository at this point in the history
…ase where a key is populated but with JSON null.
  • Loading branch information
Quintin Willison committed Jun 12, 2020
1 parent 7fbc7b1 commit 5101238
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/src/main/java/io/ably/lib/types/BaseMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.davidehrmann.vcdiff.VCDiffDecoder;
import com.davidehrmann.vcdiff.VCDiffDecoderBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonNull;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.JsonPrimitive;
Expand Down Expand Up @@ -241,7 +242,7 @@ protected void read(final JsonObject map) throws MessageDecodeException {
*/
protected String readString(final JsonObject map, final String key) {
final JsonElement element = map.get(key);
if (null == element) {
if (null == element || element instanceof JsonNull) {
return null;
}
return element.getAsString();
Expand All @@ -255,7 +256,7 @@ protected String readString(final JsonObject map, final String key) {
*/
protected Long readLong(final JsonObject map, final String key) {
final JsonElement element = map.get(key);
if (null == element) {
if (null == element || element instanceof JsonNull) {
return null;
}
return element.getAsLong();
Expand Down

0 comments on commit 5101238

Please sign in to comment.