Commit ada5e55
committed
Fix resource leak in PortAllocator canBind method
The canBind method in PortAllocator had a potential resource leak where
ServerSocket instances might not be properly closed if an exception
occurred between socket creation and the explicit close() call.
Fixed by using try-with-resources statement which ensures the
ServerSocket is automatically closed regardless of whether an
exception is thrown or not.
This prevents potential socket handle leaks in the testing framework.1 parent f87d454 commit ada5e55
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 changedLines changed: 1 addition & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
121 | | - | |
122 | | - | |
123 | | - | |
| 121 | + | |
124 | 122 | | |
125 | 123 | | |
126 | 124 | | |
| |||
0 commit comments