You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using apicurio 2.2.5.Final with spring cloud stream kafka streams and avroSerdes, I have to read/write the artifact identifier from/to payload instead of headers so I have added this configuration to my props file:
But after this addition every message received cause:
java.lang.NullPointerException: Cannot invoke "io.apicurio.registry.serde.headers.HeadersHandler.readHeaders(org.apache.kafka.common.header.Headers)" because "this.headersHandler" is null
The problem is in the method deserialize(String topic, Headers headers, byte[] data) inside the class io.apicurio.registry.serde.AbstractKafkaDeserializer; this is the code:
public U deserialize(String topic, Headers headers, byte[] data) {
if (data == null) {
return null;
}
ArtifactReference artifactReference = null;
if (headers != null) { <-- headers isn't null, It's an object with an empty array
artifactReference = headersHandler.readHeaders(headers); <-- headersHandler is null and causes the NPE
if (artifactReference.hasValue()) {
return readData(topic, headers, data, artifactReference);
}
}
if (data[0] == MAGIC_BYTE) {
return deserialize(topic, data);
} else if (headers == null){
throw new IllegalStateException("Headers cannot be null");
} else {
//try to read data even if artifactReference has no value, maybe there is a fallbackArtifactProvider configured
return readData(topic, headers, data, artifactReference);
}
}
There is no headers in the message but the condition (headers != null) is true (because the variable is valorized with an empty array) and the call headersHandler.readHeaders(headers) with headersHandler null causes a NPE.
Am I doing all right or there are other configurations to add?
A possible solution could be change headers != null into headers != null && headers.toArray().size() > 0 or check if headersHandler is not null
The text was updated successfully, but these errors were encountered:
I'm using apicurio 2.2.5.Final with spring cloud stream kafka streams and avroSerdes, I have to read/write the artifact identifier from/to payload instead of headers so I have added this configuration to my props file:
spring.cloud.stream.kafka.streams.binder.configuration.apicurio.registry.headers.enabled=false
But after this addition every message received cause:
java.lang.NullPointerException: Cannot invoke "io.apicurio.registry.serde.headers.HeadersHandler.readHeaders(org.apache.kafka.common.header.Headers)" because "this.headersHandler" is null
The problem is in the method
deserialize(String topic, Headers headers, byte[] data)
inside the classio.apicurio.registry.serde.AbstractKafkaDeserializer
; this is the code:There is no headers in the message but the condition
(headers != null)
is true (because the variable is valorized with an empty array) and the callheadersHandler.readHeaders(headers)
withheadersHandler
null causes a NPE.Am I doing all right or there are other configurations to add?
A possible solution could be change
headers != null
intoheaders != null && headers.toArray().size() > 0
or check ifheadersHandler
is not nullThe text was updated successfully, but these errors were encountered: