Skip to content

Commit

Permalink
[pinpoint-apm#11497] Fix potential NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
emeroad committed Oct 4, 2024
1 parent dc4cb95 commit 6006af9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void close() {

@Override
public void close(Throwable throwable) {
logger.warn("close. message:{}", throwable.getMessage(), throwable);
logger.warn("close", throwable);
close0(throwable);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.navercorp.pinpoint.profiler.receiver.grpc;

import org.junit.jupiter.api.Test;

import java.io.IOException;

import static org.mockito.Mockito.mock;

class ActiveThreadCountStreamSocketTest {

@Test
void close_NPE() {
GrpcStreamService grpcStreamService = mock(GrpcStreamService.class);
ActiveThreadCountStreamSocket socket = new ActiveThreadCountStreamSocket(1, grpcStreamService);
socket.close(null);
}

@Test
void close() {
GrpcStreamService grpcStreamService = mock(GrpcStreamService.class);
ActiveThreadCountStreamSocket socket = new ActiveThreadCountStreamSocket(1, grpcStreamService);
socket.close(new IOException("test"));
}
}

0 comments on commit 6006af9

Please sign in to comment.