[Bug] When dataReadAheadEnable is set to false, there will be problems running on higher JDK versions
Before Creating the Bug Report
-
[x] I found a bug, not just asking a question, which should be created in GitHub Discussions.
-
[x] I have searched the GitHub Issues and GitHub Discussions of this repository and believe that this is not a duplicate.
-
[x] I have confirmed that this bug belongs to the current repository, not other repositories of RocketMQ.
Runtime platform environment
When dataReadAheadEnable is set to false, there will be problems running on higher JDK versions
java.lang.IllegalAccessError: class org.apache.rocketmq.store.CommitLog (in unnamed module @0x3d8314f0) cannot access class sun.nio.ch.DirectBuffer (in module java.base) because module java.base does not export sun.nio.ch to unnamed module @0x3d8314f0
at org.apache.rocketmq.store.CommitLog.setFileReadMode(CommitLog.java:2484)
at org.apache.rocketmq.store.CommitLog.lambda$scanFileAndSetReadMode$1(CommitLog.java:2472)
at java.base/java.util.concurrent.CopyOnWriteArrayList.forEach(CopyOnWriteArrayList.java:891)
at org.apache.rocketmq.store.CommitLog.scanFileAndSetReadMode(CommitLog.java:2471)
at org.apache.rocketmq.store.CommitLog.load(CommitLog.java:167)
at org.apache.rocketmq.store.DefaultMessageStore.load(DefaultMessageStore.java:397)
at org.apache.rocketmq.broker.BrokerController.recoverAndInitService(BrokerController.java:942)
at org.apache.rocketmq.broker.BrokerController.initialize(BrokerController.java:928)
at org.apache.rocketmq.broker.BrokerStartup.createBrokerController(BrokerStartup.java:322)
at org.apache.rocketmq.broker.BrokerStartup.main(BrokerStartup.java:58)
RocketMQ version
all
JDK Version
jdk21
Describe the Bug
use internal api in higher jdk will fail
Steps to Reproduce
When dataReadAheadEnable is set to false, there will be problems running on higher JDK versions
What Did You Expect to See?
run ok
What Did You See Instead?
failed
Additional Context
change final long address = ((DirectBuffer) mappedFile.getMappedByteBuffer()).address();
to
final long address = PlatformDependent.directBufferAddress(mappedFile.getMappedByteBuffer());
can fixed
Hi @leizhiyuan , thank you for digging into this issue and providing a clear solution! This looks like a great fix.
Since there isn't a Pull Request for this yet, I'd be happy to create one based on your suggestion to help move this forward. Would that be okay with you?"
Sure, Thank You,I wanted to get feedback from the community. If you're interested, you can submit a pull request and wait for the community owner to review and confirm.