Skip to content

Commit 6d3749b

Browse files
authored
[java] Fix falsy Spotbugs warning about not closed resource (#16318)
#16314 fix falsy Spotbugs warning about not closed resource I had to inline method `findBinaryInClasspath()` to make Spotbugs happy. I could not find any other way to suppress this falsy warning. :(
1 parent 9cd26d5 commit 6d3749b

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

java/src/org/openqa/selenium/manager/SeleniumManager.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,9 @@ private synchronized Path getBinary() {
217217

218218
binary = getBinaryInCache(SELENIUM_MANAGER + extension);
219219
if (!Files.exists(binary)) {
220-
try (InputStream inputStream = findBinaryInClasspath(folder, extension)) {
220+
String binaryPathInJar = String.format("%s/%s%s", folder, SELENIUM_MANAGER, extension);
221+
try (InputStream inputStream =
222+
requireNonNull(getClass().getResourceAsStream(binaryPathInJar))) {
221223
Files.createDirectories(binary.getParent());
222224
saveToFileSafely(inputStream, binary);
223225
}
@@ -251,13 +253,6 @@ private void saveToFileSafely(InputStream inputStream, Path target) throws IOExc
251253
}
252254
}
253255

254-
private InputStream findBinaryInClasspath(String folder, String extension) {
255-
String binaryPathInJar = String.format("%s/%s%s", folder, SELENIUM_MANAGER, extension);
256-
return requireNonNull(
257-
getClass().getResourceAsStream(binaryPathInJar),
258-
() -> "Resource not found in classpath: " + binaryPathInJar);
259-
}
260-
261256
/**
262257
* Executes Selenium Manager to get the locations of the requested assets
263258
*

0 commit comments

Comments
 (0)