GitHub user Jaskey opened a pull request:
https://github.com/apache/incubator-rocketmq/pull/110
[ROCKETMQ-208]incompatibility problem found in enviroment of JDK 1.7 when
running client
JIRA :
https://issues.apache.org/jira/browse/ROCKETMQ-208?jql=project%20%3D%20ROCKETMQ
This problem will be found when
- Our release version is compile in java 8 compiler
- Developer download the source file and they compile with java 8 compiler
but the user uses rocketmq-client in java 7.
How to test the problem :
1. compile rocketmq in ** jdk 8 compiler **
2. Run below test code in a machine which installed **java7** .
public class Test {
public static void main(String[] args) {
DefaultMQPushConsumer pushConsumer = new DefaultMQPushConsumer(
"FooBarGroup" + System.currentTimeMillis());
DefaultMQPushConsumerImpl pushConsumerImpl =
pushConsumer.getDefaultMQPushConsumerImpl();
new
RebalancePushImpl(pushConsumer.getDefaultMQPushConsumerImpl()).unlockAll(false);
}
}
We will find that a NoSuchError will be thrown :
Exception in thread "main" java.lang.NoSuchMethodError:
java.util.concurrent.ConcurrentHashMap.keySet()Ljava/util/concurrent/ConcurrentHashMap$KeySetView;
at
org.apache.rocketmq.client.impl.consumer.RebalanceImpl.buildProcessQueueTableByBrokerName(RebalanceImpl.java:121)
at
org.apache.rocketmq.client.impl.consumer.RebalanceImpl.unlockAll(RebalanceImpl.java:86)
at Test.main(Test.java:13)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
After apply this patch then retry, problem is solved.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/Jaskey/incubator-rocketmq
ROCKETMQ-208-concurenthashmap-ncompatibility-problem
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/incubator-rocketmq/pull/110.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #110
----
commit 77dc4d63ad698663675098b4b4a46fa9c8e59734
Author: Jaskey <[email protected]>
Date: 2017-06-02T13:49:22Z
Refactor to use ConcurentMap instead of ConcurentHashMap when declaring
field in order to avoid incompatibility problem when running client in lower
jre while compiling in java8 compiler
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---