Skip to content

Commit 0dfe6cb

Browse files
committed
Include wdm.avoidShutdownHook config key (issue #839)
1 parent 7464518 commit 0dfe6cb

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

src/main/java/io/github/bonigarcia/wdm/WebDriverManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1803,7 +1803,7 @@ protected Capabilities getMergedCapabilities() {
18031803
}
18041804

18051805
protected void addShutdownHookIfRequired() {
1806-
if (!shutdownHook) {
1806+
if (!shutdownHook && !config().isAvoidShutdownHook()) {
18071807
Runtime.getRuntime()
18081808
.addShutdownHook(new Thread("wdm-shutdown-hook") {
18091809
@Override

src/main/java/io/github/bonigarcia/wdm/config/Config.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ public class Config {
8383
"wdm.avoidReadReleaseFromRepository", Boolean.class);
8484
ConfigKey<Boolean> avoidTmpFolder = new ConfigKey<>("wdm.avoidTmpFolder",
8585
Boolean.class);
86+
ConfigKey<Boolean> avoidShutdownHook = new ConfigKey<>(
87+
"wdm.avoidShutdownHook", Boolean.class);
8688
ConfigKey<Integer> timeout = new ConfigKey<>("wdm.timeout", Integer.class);
8789
ConfigKey<Boolean> versionsPropertiesOnlineFirst = new ConfigKey<>(
8890
"wdm.versionsPropertiesOnlineFirst", Boolean.class);
@@ -540,6 +542,15 @@ public Config setAvoidTmpFolder(boolean value) {
540542
return this;
541543
}
542544

545+
public boolean isAvoidShutdownHook() {
546+
return resolve(avoidShutdownHook);
547+
}
548+
549+
public Config setAvoidShutdownHook(boolean value) {
550+
this.avoidShutdownHook.setValue(value);
551+
return this;
552+
}
553+
543554
public int getTimeout() {
544555
return resolve(timeout);
545556
}

src/main/resources/webdrivermanager.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ wdm.avoidResolutionCache=false
99
wdm.avoidFallback=false
1010
wdm.avoidReadReleaseFromRepository=false
1111
wdm.avoidTmpFolder=false
12+
wdm.avoidShutdownHook=false
1213
wdm.timeout=30
1314
wdm.resolutionCache=resolution.properties
1415
wdm.ttl=86400

0 commit comments

Comments
 (0)