Skip to content

Commit 56b179f

Browse files
authored
Simplify port allocator (#14761)
1 parent 3af778b commit 56b179f

File tree

1 file changed

+1
-3
lines changed
  • testing-common/src/main/java/io/opentelemetry/instrumentation/test/utils

1 file changed

+1
-3
lines changed

testing-common/src/main/java/io/opentelemetry/instrumentation/test/utils/PortAllocator.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,7 @@ Closeable bind(int port) {
118118
}
119119

120120
boolean canBind(int port) {
121-
try {
122-
ServerSocket socket = new ServerSocket(port);
123-
socket.close();
121+
try (ServerSocket socket = new ServerSocket(port)) {
124122
return true;
125123
} catch (IOException exception) {
126124
return false;

0 commit comments

Comments
 (0)