Skip to content

Commit 787ea3b

Browse files
AndyTWFclaude
andcommitted
fix: handle JSON null for extras in PresenceMessage deserialization
Treat `"extras": null` as absent rather than throwing a MessageDecodeException. This avoids a hard failure when incoming JSON explicitly sets extras to null. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f903317 commit 787ea3b

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,11 +295,11 @@ protected void read(final JsonObject map) throws MessageDecodeException {
295295
super.read(map);
296296

297297
final JsonElement extrasElement = map.get(EXTRAS);
298-
if (null != extrasElement) {
299-
if (!(extrasElement instanceof JsonObject)) {
298+
if (extrasElement != null && !extrasElement.isJsonNull()) {
299+
if (!extrasElement.isJsonObject()) {
300300
throw MessageDecodeException.fromDescription("PresenceMessage extras is of type \"" + extrasElement.getClass() + "\" when expected a JSON object.");
301301
}
302-
extras = MessageExtras.read((JsonObject) extrasElement);
302+
extras = MessageExtras.read(extrasElement.getAsJsonObject());
303303
}
304304

305305
Integer actionValue = readInt(map, "action");

0 commit comments

Comments
 (0)