diff --git a/README.adoc b/README.adoc index 6c999969..186a51c0 100644 --- a/README.adoc +++ b/README.adoc @@ -115,6 +115,13 @@ Do NOT use it. |1000 |700 +.2+|dnsjava.nio.register_shutdown_hook +3+|Register Shutdown Hook for automatic termination of NIO. +If disabled, the nio selector thread will not automatically clean up on JVM termination. +|Boolean +|True +|False + .2+|dnsjava.harden_unknown_additional 3+|Harden against unknown records in the authority section and additional section. If disabled, such records are copied from the upstream and presented to the client together with the answer. diff --git a/src/main/java/org/xbill/DNS/NioClient.java b/src/main/java/org/xbill/DNS/NioClient.java index 47c08361..73f2c45a 100644 --- a/src/main/java/org/xbill/DNS/NioClient.java +++ b/src/main/java/org/xbill/DNS/NioClient.java @@ -25,6 +25,8 @@ *
*
dnsjava.nio.selector_timeout *
Set selector timeout in milliseconds. Default/Max 1000, Min 1. + *
dnsjava.nio.register_shutdown_hook + *
Register Shutdown Hook termination of NIO. Default True. *
* * @since 3.4 @@ -60,7 +62,9 @@ static Selector selector() throws IOException { selectorThread.start(); closeThread = new Thread(() -> close(true)); closeThread.setName("dnsjava NIO shutdown hook"); - Runtime.getRuntime().addShutdownHook(closeThread); + if (Boolean.parseBoolean(System.getProperty("dnsjava.nio.register_shutdown_hook", "true"))) { + Runtime.getRuntime().addShutdownHook(closeThread); + } } } }