Skip to content

Commit

Permalink
return null with null input in deserializer
Browse files Browse the repository at this point in the history
  • Loading branch information
naser-ayat committed Jul 27, 2023
1 parent 457daf9 commit 125906d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
import org.apache.kafka.common.serialization.Deserializer;

public class SpanDataDeserializer implements Deserializer<ExportTraceServiceRequest> {
@SuppressWarnings("NullAway")
@Override
public ExportTraceServiceRequest deserialize(String topic, byte[] data) {
if (Objects.isNull(data)) {
return ExportTraceServiceRequest.getDefaultInstance();
return null;
}
try {
return ExportTraceServiceRequest.parseFrom(data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;

import io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest;
import io.opentelemetry.proto.resource.v1.Resource;
Expand Down Expand Up @@ -42,7 +43,7 @@ void deserialize() {

@Test
void deserializeNullData() {
assertNotNull(testSubject.deserialize("test-topic", null));
assertNull(testSubject.deserialize("test-topic", null));
}

@Test
Expand Down

0 comments on commit 125906d

Please sign in to comment.