From c25515f414aba8ec776dc13663567cf9f84d0a08 Mon Sep 17 00:00:00 2001 From: spoonman01 Date: Wed, 27 Nov 2024 11:08:57 +0100 Subject: [PATCH] fix(json data deserialization) #WPB-12153 * Bump version to 1.7.2 --- pom.xml | 2 +- .../com/wire/xenon/backend/models/Payload.java | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 9952a23..450bfd6 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.wire xenon - 1.7.1 + 1.7.2 Xenon Base Wire Bots Library diff --git a/src/main/java/com/wire/xenon/backend/models/Payload.java b/src/main/java/com/wire/xenon/backend/models/Payload.java index 44aa5a9..86fd9f2 100644 --- a/src/main/java/com/wire/xenon/backend/models/Payload.java +++ b/src/main/java/com/wire/xenon/backend/models/Payload.java @@ -109,14 +109,14 @@ public Data deserialize(JsonParser jp, DeserializationContext ctxt) throws IOExc JsonNode node = jp.readValueAsTree(); if (node.isObject()) { Data data = new Data(); - data.sender = node.get("sender").asText(); - data.recipient = node.get("recipient").asText(); - data.text = node.get("text").asText(); - data.userIds = jp.getCodec().readValue(node.get("qualified_user_ids").traverse(jp.getCodec()), new TypeReference>() {}); - data.users = jp.getCodec().readValue(node.get("users").traverse(jp.getCodec()), new TypeReference>() {}); - data.name = node.get("name").asText(); - data.creator = node.get("creator").isTextual() ? UUID.fromString(node.get("creator").asText()) : null; - data.members = jp.getCodec().readValue(node.get("members").traverse(jp.getCodec()), Members.class); + data.sender = node.has("sender") ? node.get("sender").asText() : null; + data.recipient = node.has("recipient") ? node.get("recipient").asText() : null; + data.text = node.has("text") ? node.get("text").asText() : null; + data.userIds = node.has("qualified_user_ids") ? jp.getCodec().readValue(node.get("qualified_user_ids").traverse(jp.getCodec()), new TypeReference>() {}): null; + data.users = node.has("users") ? jp.getCodec().readValue(node.get("users").traverse(jp.getCodec()), new TypeReference>() {}) : null; + data.name = node.has("name") ? node.get("name").asText() : null; + data.creator = node.has("creator") && node.get("creator").isTextual() ? UUID.fromString(node.get("creator").asText()) : null; + data.members = node.has("members") ? jp.getCodec().readValue(node.get("members").traverse(jp.getCodec()), Members.class) : null; return data; } else if (node.isTextual()) { Data data = new Data();