Skip to content

Commit cdcc7a1

Browse files
authored
[java] Delete SM binary only when SE_MANAGER_PATH is not set (#12840)
1 parent 1992155 commit cdcc7a1

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

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

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -70,21 +70,23 @@ public class SeleniumManager {
7070

7171
/** Wrapper for the Selenium Manager binary. */
7272
private SeleniumManager() {
73-
Runtime.getRuntime()
74-
.addShutdownHook(
75-
new Thread(
76-
() -> {
77-
if (binary != null && Files.exists(binary)) {
78-
try {
79-
Files.delete(binary);
80-
} catch (IOException e) {
81-
LOG.warning(
82-
String.format(
83-
"%s deleting temporal file: %s",
84-
e.getClass().getSimpleName(), e.getMessage()));
73+
if (managerPath == null) {
74+
Runtime.getRuntime()
75+
.addShutdownHook(
76+
new Thread(
77+
() -> {
78+
if (binary != null && Files.exists(binary)) {
79+
try {
80+
Files.delete(binary);
81+
} catch (IOException e) {
82+
LOG.warning(
83+
String.format(
84+
"%s deleting temporal file: %s",
85+
e.getClass().getSimpleName(), e.getMessage()));
86+
}
8587
}
86-
}
87-
}));
88+
}));
89+
}
8890
}
8991

9092
public static SeleniumManager getInstance() {

0 commit comments

Comments
 (0)