Repository navigation
Add dnsjava.secure_random_algorithm property to select SecureRandom - #419
Merged
ibauersachs merged 1 commit intoOct 3, 2026
Merged
Conversation
Allow selecting the SecureRandom algorithm used for UDP source port and message ID generation via the dnsjava.secure_random_algorithm system property. This lets heavy-volume deployments pick an algorithm that avoids the lock contention of the default SecureRandom. The property is read through a shared Utils.secureRandom() helper used by both NioUdpClient and Header. When the property is unset or names an algorithm that is not available, it falls back to the default SecureRandom, so behavior is unchanged when the property is not set.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #419 +/- ##
=========================================
Coverage 66.94% 66.95%
- Complexity 3095 3098 +3
=========================================
Files 198 198
Lines 13702 13709 +7
Branches 2141 2142 +1
=========================================
+ Hits 9173 9179 +6
Misses 3949 3949
- Partials 580 581 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Member
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Closes #368
High-volume deployments see lock contention on the default
SecureRandom. This adds adnsjava.secure_random_algorithmsystem property that selects theSecureRandomalgorithm, following the existingdnsjava.*property convention.Details:
Utils.secureRandom()helper reads the property and returns aSecureRandomfor the configured algorithm.NioUdpClient(UDP source port selection) andHeader(message ID generation).Header.randomisstatic final, so the property is read at class initialization.NoSuchAlgorithmException), it falls back to a defaultnew SecureRandom(). The change is a no-op when the property is not set, so there is no behavior change by default.Testing:
UtilsTestcovering the default (unset), a valid algorithm, and an invalid algorithm (fallback) cases.--release 8).