Uploaded image for project: 'Apache RocketMQ'
  1. Apache RocketMQ
  2. ROCKETMQ-208

incompatibility problem found in enviroment of JDK 1.7 when running client

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.1.0-incubating
    • Component/s: rocketmq-client
    • Labels:
      None
    • Environment:
      jdk 1.7

      Description

      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

        Issue Links

          Activity

          Hide
          Jaskey Jaskey Lam added a comment -

          Some methods calls `keySet()` in rocketmq code base, and the implementations in java 8 is different from java7.

          Though the target compatible is set to 1.7, the problem will still be found if the jar is compiled with java8 compiler.

          Something should be done to avoid this problem or rocketmq can not be run properly for user who are using java7

          Show
          Jaskey Jaskey Lam added a comment - Some methods calls `keySet()` in rocketmq code base, and the implementations in java 8 is different from java7. Though the target compatible is set to 1.7, the problem will still be found if the jar is compiled with java8 compiler. Something should be done to avoid this problem or rocketmq can not be run properly for user who are using java7
          Hide
          Jaskey Jaskey Lam added a comment -

          Since the problem is found in 3.5.8, and I have checked that the jar downloaded from http://mvnrepository.com/artifact/com.alibaba.rocketmq/rocketmq-client/3.5.8 is indeeded compile by java 8 compiler.

          Manifest-Version: 1.0
          Archiver-Version: Plexus Archiver
          Built-By: alvin
          Created-By: Apache Maven 3.3.3
          Build-Jdk: 1.8.0_92
          
          

          Once the jar is compile by java 8 compiler, problem will be found.

          Show
          Jaskey Jaskey Lam added a comment - Since the problem is found in 3.5.8, and I have checked that the jar downloaded from http://mvnrepository.com/artifact/com.alibaba.rocketmq/rocketmq-client/3.5.8 is indeeded compile by java 8 compiler. Manifest-Version: 1.0 Archiver-Version: Plexus Archiver Built-By: alvin Created-By: Apache Maven 3.3.3 Build-Jdk: 1.8.0_92 Once the jar is compile by java 8 compiler, problem will be found.
          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user Jaskey opened a pull request:

          https://github.com/apache/incubator-rocketmq/pull/110

          ROCKETMQ-208incompatibility 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 <linjunjie1103@gmail.com>
          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


          Show
          githubbot ASF GitHub Bot added a comment - 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 <linjunjie1103@gmail.com> 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
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user coveralls commented on the issue:

          https://github.com/apache/incubator-rocketmq/pull/110

          [![Coverage Status](https://coveralls.io/builds/11802730/badge)](https://coveralls.io/builds/11802730)

          Coverage increased (+0.04%) to 31.014% when pulling *77dc4d63ad698663675098b4b4a46fa9c8e59734 on Jaskey:ROCKETMQ-208-concurenthashmap-ncompatibility-problem* into *fa85abcdf6ee46e56403ddf86828a38683103fd0 on apache:master*.

          Show
          githubbot ASF GitHub Bot added a comment - Github user coveralls commented on the issue: https://github.com/apache/incubator-rocketmq/pull/110 [! [Coverage Status] ( https://coveralls.io/builds/11802730/badge)](https://coveralls.io/builds/11802730 ) Coverage increased (+0.04%) to 31.014% when pulling * 77dc4d63ad698663675098b4b4a46fa9c8e59734 on Jaskey: ROCKETMQ-208 -concurenthashmap-ncompatibility-problem * into * fa85abcdf6ee46e56403ddf86828a38683103fd0 on apache:master *.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user lizhanhui commented on the issue:

          https://github.com/apache/incubator-rocketmq/pull/110

          Good Job

          +1

          Show
          githubbot ASF GitHub Bot added a comment - Github user lizhanhui commented on the issue: https://github.com/apache/incubator-rocketmq/pull/110 Good Job +1
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user lizhanhui commented on the issue:

          https://github.com/apache/incubator-rocketmq/pull/110

          Looks CI is buggy.

          Show
          githubbot ASF GitHub Bot added a comment - Github user lizhanhui commented on the issue: https://github.com/apache/incubator-rocketmq/pull/110 Looks CI is buggy.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user Jaskey commented on the issue:

          https://github.com/apache/incubator-rocketmq/pull/110

          @lizhanhui

          I suffer from this for serveal times, always is blocked by the defaultPushConsumerTest causing by no output for long time

          Show
          githubbot ASF GitHub Bot added a comment - Github user Jaskey commented on the issue: https://github.com/apache/incubator-rocketmq/pull/110 @lizhanhui I suffer from this for serveal times, always is blocked by the defaultPushConsumerTest causing by no output for long time
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user dongeforever commented on the issue:

          https://github.com/apache/incubator-rocketmq/pull/110

          +1

          Show
          githubbot ASF GitHub Bot added a comment - Github user dongeforever commented on the issue: https://github.com/apache/incubator-rocketmq/pull/110 +1
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user zhouxinyu commented on the issue:

          https://github.com/apache/incubator-rocketmq/pull/110

          +1, cool~

          Show
          githubbot ASF GitHub Bot added a comment - Github user zhouxinyu commented on the issue: https://github.com/apache/incubator-rocketmq/pull/110 +1, cool~
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user coveralls commented on the issue:

          https://github.com/apache/incubator-rocketmq/pull/110

          [![Coverage Status](https://coveralls.io/builds/11844151/badge)](https://coveralls.io/builds/11844151)

          Coverage decreased (-0.02%) to 38.587% when pulling *57227585735920c83c916df00a0d1f8cba0623a6 on Jaskey:ROCKETMQ-208-concurenthashmap-ncompatibility-problem* into *0c5e53db6f4d0ed9f25747379a8b679e2da5392d on apache:master*.

          Show
          githubbot ASF GitHub Bot added a comment - Github user coveralls commented on the issue: https://github.com/apache/incubator-rocketmq/pull/110 [! [Coverage Status] ( https://coveralls.io/builds/11844151/badge)](https://coveralls.io/builds/11844151 ) Coverage decreased (-0.02%) to 38.587% when pulling * 57227585735920c83c916df00a0d1f8cba0623a6 on Jaskey: ROCKETMQ-208 -concurenthashmap-ncompatibility-problem * into * 0c5e53db6f4d0ed9f25747379a8b679e2da5392d on apache:master *.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user coveralls commented on the issue:

          https://github.com/apache/incubator-rocketmq/pull/110

          [![Coverage Status](https://coveralls.io/builds/11844151/badge)](https://coveralls.io/builds/11844151)

          Coverage decreased (-0.02%) to 38.587% when pulling *57227585735920c83c916df00a0d1f8cba0623a6 on Jaskey:ROCKETMQ-208-concurenthashmap-ncompatibility-problem* into *0c5e53db6f4d0ed9f25747379a8b679e2da5392d on apache:master*.

          Show
          githubbot ASF GitHub Bot added a comment - Github user coveralls commented on the issue: https://github.com/apache/incubator-rocketmq/pull/110 [! [Coverage Status] ( https://coveralls.io/builds/11844151/badge)](https://coveralls.io/builds/11844151 ) Coverage decreased (-0.02%) to 38.587% when pulling * 57227585735920c83c916df00a0d1f8cba0623a6 on Jaskey: ROCKETMQ-208 -concurenthashmap-ncompatibility-problem * into * 0c5e53db6f4d0ed9f25747379a8b679e2da5392d on apache:master *.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user coveralls commented on the issue:

          https://github.com/apache/incubator-rocketmq/pull/110

          [![Coverage Status](https://coveralls.io/builds/11844151/badge)](https://coveralls.io/builds/11844151)

          Coverage decreased (-0.02%) to 38.587% when pulling *57227585735920c83c916df00a0d1f8cba0623a6 on Jaskey:ROCKETMQ-208-concurenthashmap-ncompatibility-problem* into *0c5e53db6f4d0ed9f25747379a8b679e2da5392d on apache:master*.

          Show
          githubbot ASF GitHub Bot added a comment - Github user coveralls commented on the issue: https://github.com/apache/incubator-rocketmq/pull/110 [! [Coverage Status] ( https://coveralls.io/builds/11844151/badge)](https://coveralls.io/builds/11844151 ) Coverage decreased (-0.02%) to 38.587% when pulling * 57227585735920c83c916df00a0d1f8cba0623a6 on Jaskey: ROCKETMQ-208 -concurenthashmap-ncompatibility-problem * into * 0c5e53db6f4d0ed9f25747379a8b679e2da5392d on apache:master *.
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 96cd2e4ed03e2c47a7d79d7e10980d154d2acb93 in incubator-rocketmq's branch refs/heads/develop from Jaskey Lam
          [ https://git-wip-us.apache.org/repos/asf?p=incubator-rocketmq.git;h=96cd2e4 ]

          ROCKETMQ-208incompatibility problem found in enviroment of JDK 1.7 when running client closes apache/incubator-rocketmq#10

          Show
          jira-bot ASF subversion and git services added a comment - Commit 96cd2e4ed03e2c47a7d79d7e10980d154d2acb93 in incubator-rocketmq's branch refs/heads/develop from Jaskey Lam [ https://git-wip-us.apache.org/repos/asf?p=incubator-rocketmq.git;h=96cd2e4 ] ROCKETMQ-208 incompatibility problem found in enviroment of JDK 1.7 when running client closes apache/incubator-rocketmq#10
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit a8e0834a0d8e5f5951b327be8aea5e5aae8f39ac in incubator-rocketmq's branch refs/heads/release-4.1.0-incubating from Jaskey Lam
          [ https://git-wip-us.apache.org/repos/asf?p=incubator-rocketmq.git;h=a8e0834 ]

          ROCKETMQ-208incompatibility problem found in enviroment of JDK 1.7 when running client closes apache/incubator-rocketmq#10

          Show
          jira-bot ASF subversion and git services added a comment - Commit a8e0834a0d8e5f5951b327be8aea5e5aae8f39ac in incubator-rocketmq's branch refs/heads/release-4.1.0-incubating from Jaskey Lam [ https://git-wip-us.apache.org/repos/asf?p=incubator-rocketmq.git;h=a8e0834 ] ROCKETMQ-208 incompatibility problem found in enviroment of JDK 1.7 when running client closes apache/incubator-rocketmq#10
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user Jaskey commented on the issue:

          https://github.com/apache/incubator-rocketmq/pull/110

          @lizhanhui @dongeforever @zhouxinyu

          conflicts resolved, and to avoid the same problem in the future, I have replace `ConcurrentHashMap` to `ConcurrentMap` when declaring as much as possible as long as we do not dependent on the method implementation the class.

          Please review.

          Show
          githubbot ASF GitHub Bot added a comment - Github user Jaskey commented on the issue: https://github.com/apache/incubator-rocketmq/pull/110 @lizhanhui @dongeforever @zhouxinyu conflicts resolved, and to avoid the same problem in the future, I have replace `ConcurrentHashMap` to `ConcurrentMap` when declaring as much as possible as long as we do not dependent on the method implementation the class. Please review.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user dongeforever commented on the issue:

          https://github.com/apache/incubator-rocketmq/pull/110

          @Jaskey This PR has been merged and will be released in 4.1.0. Thanks a lot for your work.

          Show
          githubbot ASF GitHub Bot added a comment - Github user dongeforever commented on the issue: https://github.com/apache/incubator-rocketmq/pull/110 @Jaskey This PR has been merged and will be released in 4.1.0. Thanks a lot for your work.
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 96cd2e4ed03e2c47a7d79d7e10980d154d2acb93 in incubator-rocketmq's branch refs/heads/release-4.1.0-incubating from Jaskey Lam
          [ https://git-wip-us.apache.org/repos/asf?p=incubator-rocketmq.git;h=96cd2e4 ]

          ROCKETMQ-208incompatibility problem found in enviroment of JDK 1.7 when running client closes apache/incubator-rocketmq#10

          Show
          jira-bot ASF subversion and git services added a comment - Commit 96cd2e4ed03e2c47a7d79d7e10980d154d2acb93 in incubator-rocketmq's branch refs/heads/release-4.1.0-incubating from Jaskey Lam [ https://git-wip-us.apache.org/repos/asf?p=incubator-rocketmq.git;h=96cd2e4 ] ROCKETMQ-208 incompatibility problem found in enviroment of JDK 1.7 when running client closes apache/incubator-rocketmq#10
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 24d6eefba65845b91513188f66d230af021a3cc9 in incubator-rocketmq's branch refs/heads/master from Jaskey Lam
          [ https://git-wip-us.apache.org/repos/asf?p=incubator-rocketmq.git;h=24d6eef ]

          ROCKETMQ-208incompatibility problem found in enviroment of JDK 1.7 when running client closes apache/incubator-rocketmq#10

          Show
          jira-bot ASF subversion and git services added a comment - Commit 24d6eefba65845b91513188f66d230af021a3cc9 in incubator-rocketmq's branch refs/heads/master from Jaskey Lam [ https://git-wip-us.apache.org/repos/asf?p=incubator-rocketmq.git;h=24d6eef ] ROCKETMQ-208 incompatibility problem found in enviroment of JDK 1.7 when running client closes apache/incubator-rocketmq#10
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user lizhanhui commented on the issue:

          https://github.com/apache/incubator-rocketmq/pull/110

          @Jaskey Please close this PR at your earliest convenient time.

          Show
          githubbot ASF GitHub Bot added a comment - Github user lizhanhui commented on the issue: https://github.com/apache/incubator-rocketmq/pull/110 @Jaskey Please close this PR at your earliest convenient time.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user Jaskey closed the pull request at:

          https://github.com/apache/incubator-rocketmq/pull/110

          Show
          githubbot ASF GitHub Bot added a comment - Github user Jaskey closed the pull request at: https://github.com/apache/incubator-rocketmq/pull/110

            People

            • Assignee:
              Jaskey Jaskey Lam
              Reporter:
              l_yy laiyiyu
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development