10000 Add concurrency test for processReadyKeys() to detect potential thread-safety issues by bhaveshthakker · Pull Request #380 · dnsjava/dnsjava · GitHub
[go: up one dir, main page]

Skip to content

Add concurrency test for processReadyKeys() to detect potential thread-safety issues #380

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix: Avoid ConcurrentModificationException by closing selector in sel…
…ector thread
  • Loading branch information
bhaveshthakker authored Jun 14, 2025
commit 5aa68c47ac26fd676b5637869b208eccf7203d58
14 changes: 8 additions & 6 deletions src/main/java/org/xbill/DNS/NioClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,14 @@ private static void close(boolean fromHook) {
}

if (localSelector != null) {
localSelector.wakeup();
try {
localSelector.close();
} catch (IOException e) {
log.warn("Failed to properly close selector, ignoring and continuing close", e);
}
REGISTRATIONS_TASKS[0] = () -> {
try {
localSelector.close(); // ✅ runs safely inside the selector thread
} catch (IOException e) {
log.warn("Failed to properly close selector", e);
}
};
localSelector.wakeup(); // wake up selector thread to execute shutdown
}

if (localSelectorThread != null) {
Expand Down
Loading
0