[
https://issues.apache.org/jira/browse/ROCKETMQ-208?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16034794#comment-16034794
]
ASF GitHub Bot commented on ROCKETMQ-208:
-----------------------------------------
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
----
> incompatibility problem found in enviroment of JDK 1.7 when running client
> --------------------------------------------------------------------------
>
> Key: ROCKETMQ-208
> URL: https://issues.apache.org/jira/browse/ROCKETMQ-208
> Project: Apache RocketMQ
> Issue Type: Bug
> Components: rocketmq-broker
> Environment: jdk 1.7
> Reporter: laiyiyu
> Assignee: yukon
>
> when I start the application which dependencies on rmq client 3.5.8 in
> java7, the application throw the exception no such method, causing by the
> ConcurrentHashMap inner class KeySetView of the java8 incompatible with
> the java7;
> so , I think the official use the java8 packing the rmq source code
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)