Skip to content

Commit

Permalink
feat(ui): display deserialization exception
Browse files Browse the repository at this point in the history
  • Loading branch information
tchiotludo committed Dec 8, 2020
1 parent 09e35de commit 92d4ee8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
18 changes: 14 additions & 4 deletions client/src/containers/Topic/Topic/TopicData/TopicData.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down Expand Up @@ -767,9 +768,18 @@ class TopicData extends Root {
},
cell: obj => {
return (
<pre className="mb-0 khq-data-highlight">
<code>{obj.value}</code>
</pre>
<div>
{obj.exceptions.length > 0 && (
<div
className="alert alert-warning"
role="alert"
dangerouslySetInnerHTML={{ __html: obj.exceptions.join('<br /><br />')}}>
</div>
)}
<pre className="mb-0 khq-data-highlight">
<code>{obj.value}</code>
</pre>
</div>
);
}
},
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/org/akhq/models/Record.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -49,6 +47,8 @@ public class Record {
@Getter(AccessLevel.NONE)
private String value;

private final List<String> exceptions = new ArrayList<>();

public Record(RecordMetadata record, byte[] bytesKey, byte[] bytesValue, Map<String, String> headers) {
this.topic = record.topic();
this.partition = record.partition();
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 92d4ee8

Please sign in to comment.