Skip to content

Commit 24f7e4c

Browse files
authored
Fix NPE on producing a message (#1342)
1 parent 2f5e484 commit 24f7e4c

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

kafka-ui-api/src/main/java/com/provectus/kafka/ui/serde/schemaregistry/SchemaRegistryAwareRecordSerDe.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,12 @@ public class SchemaRegistryAwareRecordSerDe implements RecordSerDe {
6262
@Nullable
6363
private final JsonSchemaMessageFormatter jsonSchemaMessageFormatter;
6464

65-
private ObjectMapper objectMapper;
65+
private final ObjectMapper objectMapper;
6666

67-
private SchemaRegistryClient createSchemaRegistryClient(KafkaCluster cluster,
68-
ObjectMapper objectMapper) {
67+
private SchemaRegistryClient createSchemaRegistryClient(KafkaCluster cluster) {
6968
if (cluster.getSchemaRegistry() == null) {
7069
throw new ValidationException("schemaRegistry is not specified");
7170
}
72-
this.objectMapper = objectMapper;
7371

7472
List<SchemaProvider> schemaProviders =
7573
List.of(new AvroSchemaProvider(), new ProtobufSchemaProvider(), new JsonSchemaProvider());
@@ -98,8 +96,9 @@ private SchemaRegistryClient createSchemaRegistryClient(KafkaCluster cluster,
9896

9997
public SchemaRegistryAwareRecordSerDe(KafkaCluster cluster, ObjectMapper objectMapper) {
10098
this.cluster = cluster;
99+
this.objectMapper = objectMapper;
101100
this.schemaRegistryClient = cluster.getSchemaRegistry() != null
102-
? createSchemaRegistryClient(cluster, objectMapper)
101+
? createSchemaRegistryClient(cluster)
103102
: null;
104103
if (schemaRegistryClient != null) {
105104
this.avroFormatter = new AvroMessageFormatter(schemaRegistryClient);

0 commit comments

Comments
 (0)