From 92d4ee8b7c91988171dd7b83c7d7e51108fd8004 Mon Sep 17 00:00:00 2001 From: tchiotludo Date: Tue, 8 Dec 2020 21:56:55 +0100 Subject: [PATCH] feat(ui): display deserialization exception --- .../Topic/Topic/TopicData/TopicData.jsx | 18 ++++++++++++++---- src/main/java/org/akhq/models/Record.java | 8 +++++--- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/client/src/containers/Topic/Topic/TopicData/TopicData.jsx b/client/src/containers/Topic/Topic/TopicData/TopicData.jsx index de8ba1dbc..830011afa 100644 --- a/client/src/containers/Topic/Topic/TopicData/TopicData.jsx +++ b/client/src/containers/Topic/Topic/TopicData/TopicData.jsx @@ -324,7 +324,8 @@ class TopicData extends Root { partition: JSON.stringify(message.partition) || '', offset: JSON.stringify(message.offset) || '', headers: message.headers || {}, - schema: { key: message.keySchemaId, value: message.valueSchemaId } + schema: { key: message.keySchemaId, value: message.valueSchemaId }, + exceptions: message.exceptions || [] }; tableMessages.push(messageToPush); }); @@ -767,9 +768,18 @@ class TopicData extends Root { }, cell: obj => { return ( -
-                      {obj.value}
-                    
+
+ {obj.exceptions.length > 0 && ( +

')}}> +
+ )} +
+                              {obj.value}
+                            
+
); } }, diff --git a/src/main/java/org/akhq/models/Record.java b/src/main/java/org/akhq/models/Record.java index f806c5304..c1d1084df 100644 --- a/src/main/java/org/akhq/models/Record.java +++ b/src/main/java/org/akhq/models/Record.java @@ -15,9 +15,7 @@ import java.time.Instant; import java.time.ZoneId; import java.time.ZonedDateTime; -import java.util.Base64; -import java.util.HashMap; -import java.util.Map; +import java.util.*; @ToString @EqualsAndHashCode @@ -49,6 +47,8 @@ public class Record { @Getter(AccessLevel.NONE) private String value; + private final List exceptions = new ArrayList<>(); + public Record(RecordMetadata record, byte[] bytesKey, byte[] bytesValue, Map headers) { this.topic = record.topic(); this.partition = record.partition(); @@ -113,6 +113,8 @@ private String convertToString(byte[] payload, Integer schemaId, boolean isKey) GenericRecord record = (GenericRecord) kafkaAvroDeserializer.deserialize(topic, payload); return AvroToJsonSerializer.toJson(record); } catch (Exception exception) { + this.exceptions.add(exception.getMessage()); + return new String(payload); } } else {