Java 25 support: drop the deprecated sun.misc.Unsafe path (jctools atomic queue)#802
Open
vasiliy-mikhailov wants to merge 1 commit into
Open
Java 25 support: drop the deprecated sun.misc.Unsafe path (jctools atomic queue)#802vasiliy-mikhailov wants to merge 1 commit into
vasiliy-mikhailov wants to merge 1 commit into
Conversation
The outgoing-QoS queue used org.jctools.queues.SpscUnboundedArrayQueue, which reaches sun.misc.Unsafe and triggers a terminal-deprecation warning on Java 25. A jctools version bump alone does not fix this: 4.0.5 still calls deprecated Unsafe (verified on Temurin 25.0.3). Switching the single usage to the Unsafe-free org.jctools.queues.atomic.SpscUnboundedAtomicArrayQueue (backed by AtomicReferenceFieldUpdater) removes the Unsafe code path with identical SPSC queue semantics. Also bumps jctools 2.1.2 -> 4.0.5 as the issue requested. Full test suite unchanged: 2619 passing / 12 skipped / 0 failures. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @vasiliy-mikhailov on file. In order for us to review and merge your code, please sign our Contributor License Agreement to get yourself added. You'll find the CLA and more information here: https://github.com/hivemq/hivemq-community/blob/master/CONTRIBUTING.adoc#contributor-license-agreement |
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.
Java 25 support: drop the deprecated
sun.misc.UnsafepathResolves #775.
A plain jctools version bump does not fix it
The issue proposes bumping jctools to silence the terminally-deprecated
sun.misc.Unsafewarning on Java 25. I checked that directly, exercising the exactqueue this project uses (
SpscUnboundedArrayQueue) on Temurin 25.0.3:sun.misc.Unsafe::objectFieldOffsetsun.misc.Unsafe::objectFieldOffsetatomicqueuejctools is built on
Unsafeby design, so a newer version still trips thewarning.
The fix
jctools ships
Unsafe-free*Atomic*queue variants (backed byAtomicReferenceFieldUpdater) for exactly this situation. The only jctools usagein the project is a single SPSC queue in
MqttOutgoingQosHandler, so switching itto
org.jctools.queues.atomic.SpscUnboundedAtomicArrayQueueremoves theUnsafecode path entirely while keeping identical queue semantics:
The atomic variant uses field updaters rather than raw
Unsafeoffsets — anegligible difference for this per-connection outgoing queue, and the idiomatic
jctools choice when
Unsafeis unavailable or undesired. jctools is also bumped2.1.2 → 4.0.5, as the issue requested.Verification
sun.misc.Unsafedeprecation warning (the
Unsafe-based queue does)../gradlew test: 2619 passing / 12 skipped / 0 failures, identicalbefore and after.
./gradlew assemblebuilds the shaded jar with the relocated atomic class.🤖 Generated with Claude Code