From d7decc84abc32dab63ee423d4d904f28d18cb1d7 Mon Sep 17 00:00:00 2001 From: yukon Date: Fri, 10 Mar 2017 16:41:58 +0800 Subject: [PATCH] [ROCKETMQ-139] Degrade the client related modules' JDK version to 1.6 --- client/pom.xml | 6 +++++- .../rocketmq/client/consumer/DefaultMQPushConsumer.java | 2 +- .../rocketmq/client/impl/factory/MQClientInstance.java | 6 +++++- .../client/consumer/DefaultMQPullConsumerTest.java | 4 ++-- .../client/consumer/DefaultMQPushConsumerTest.java | 2 +- .../client/consumer/store/LocalFileOffsetStoreTest.java | 2 +- .../consumer/store/RemoteBrokerOffsetStoreTest.java | 2 +- .../client/impl/factory/MQClientInstanceTest.java | 6 +++--- .../rocketmq/client/producer/DefaultMQProducerTest.java | 6 +++--- .../producer/selector/SelectMessageQueueByHashTest.java | 2 +- common/pom.xml | 4 ++++ .../src/main/java/org/apache/rocketmq/common/MixAll.java | 4 ++-- .../test/java/org/apache/rocketmq/common/MixAllTest.java | 6 +++--- .../org/apache/rocketmq/common/filter/FilterAPITest.java | 2 +- remoting/pom.xml | 4 ++++ .../rocketmq/remoting/netty/NettyRemotingClient.java | 8 ++++---- 16 files changed, 41 insertions(+), 25 deletions(-) diff --git a/client/pom.xml b/client/pom.xml index 7c952ac4..24d0a54b 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -22,12 +22,16 @@ 4.1.0-incubating-SNAPSHOT - 4.0.0 jar rocketmq-client rocketmq-client ${project.version} + + 1.6 + 1.6 + + ${project.groupId} diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumer.java b/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumer.java index 2cce03d3..3903fe2b 100644 --- a/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumer.java +++ b/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumer.java @@ -133,7 +133,7 @@ public class DefaultMQPushConsumer extends ClientConfig implements MQPushConsume /** * Subscription relationship */ - private Map subscription = new HashMap<>(); + private Map subscription = new HashMap(); /** * Message listener diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java b/client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java index 1343e763..ebcfb626 100644 --- a/client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java +++ b/client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java @@ -842,7 +842,11 @@ public class MQClientInstance { try { this.mQClientAPIImpl.unregisterClient(addr, this.clientId, producerGroup, consumerGroup, 3000); log.info("unregister client[Producer: {} Consumer: {}] from broker[{} {} {}] success", producerGroup, consumerGroup, brokerName, entry1.getKey(), addr); - } catch (RemotingException | InterruptedException | MQBrokerException e) { + } catch (RemotingException e) { + log.error("unregister client exception from broker: " + addr, e); + } catch (InterruptedException e) { + log.error("unregister client exception from broker: " + addr, e); + } catch (MQBrokerException e) { log.error("unregister client exception from broker: " + addr, e); } } diff --git a/client/src/test/java/org/apache/rocketmq/client/consumer/DefaultMQPullConsumerTest.java b/client/src/test/java/org/apache/rocketmq/client/consumer/DefaultMQPullConsumerTest.java index 6672b1e8..33142617 100644 --- a/client/src/test/java/org/apache/rocketmq/client/consumer/DefaultMQPullConsumerTest.java +++ b/client/src/test/java/org/apache/rocketmq/client/consumer/DefaultMQPullConsumerTest.java @@ -99,7 +99,7 @@ public class DefaultMQPullConsumerTest { assertThat(pullResult.getNextBeginOffset()).isEqualTo(1024 + 1); assertThat(pullResult.getMinOffset()).isEqualTo(123); assertThat(pullResult.getMaxOffset()).isEqualTo(2048); - assertThat(pullResult.getMsgFoundList()).isEqualTo(new ArrayList<>()); + assertThat(pullResult.getMsgFoundList()).isEqualTo(new ArrayList()); } @Test @@ -137,7 +137,7 @@ public class DefaultMQPullConsumerTest { assertThat(pullResult.getNextBeginOffset()).isEqualTo(1024 + 1); assertThat(pullResult.getMinOffset()).isEqualTo(123); assertThat(pullResult.getMaxOffset()).isEqualTo(2048); - assertThat(pullResult.getMsgFoundList()).isEqualTo(new ArrayList<>()); + assertThat(pullResult.getMsgFoundList()).isEqualTo(new ArrayList()); } @Override public void onException(Throwable e) { diff --git a/client/src/test/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumerTest.java b/client/src/test/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumerTest.java index 2e0af5af..cdf1d780 100644 --- a/client/src/test/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumerTest.java +++ b/client/src/test/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumerTest.java @@ -143,7 +143,7 @@ public class DefaultMQPushConsumerTest { doReturn(new FindBrokerResult("127.0.0.1:10911", false)).when(mQClientFactory).findBrokerAddressInSubscribe(anyString(), anyLong(), anyBoolean()); doReturn(Collections.singletonList(mQClientFactory.getClientId())).when(mQClientFactory).findConsumerIdList(anyString(), anyString()); - Set messageQueueSet = new HashSet<>(); + Set messageQueueSet = new HashSet(); messageQueueSet.add(createPullRequest().getMessageQueue()); pushConsumer.getDefaultMQPushConsumerImpl().updateTopicSubscribeInfo(topic, messageQueueSet); doReturn(123L).when(rebalancePushImpl).computePullFromWhere(any(MessageQueue.class)); diff --git a/client/src/test/java/org/apache/rocketmq/client/consumer/store/LocalFileOffsetStoreTest.java b/client/src/test/java/org/apache/rocketmq/client/consumer/store/LocalFileOffsetStoreTest.java index bf0adcb4..22e212b3 100644 --- a/client/src/test/java/org/apache/rocketmq/client/consumer/store/LocalFileOffsetStoreTest.java +++ b/client/src/test/java/org/apache/rocketmq/client/consumer/store/LocalFileOffsetStoreTest.java @@ -69,7 +69,7 @@ public class LocalFileOffsetStoreTest { offsetStore.updateOffset(messageQueue, 1024, false); assertThat(offsetStore.readOffset(messageQueue, ReadOffsetType.READ_FROM_STORE)).isEqualTo(-1); - offsetStore.persistAll(new HashSet<>(Collections.singletonList(messageQueue))); + offsetStore.persistAll(new HashSet(Collections.singletonList(messageQueue))); assertThat(offsetStore.readOffset(messageQueue, ReadOffsetType.READ_FROM_STORE)).isEqualTo(1024); } } \ No newline at end of file diff --git a/client/src/test/java/org/apache/rocketmq/client/consumer/store/RemoteBrokerOffsetStoreTest.java b/client/src/test/java/org/apache/rocketmq/client/consumer/store/RemoteBrokerOffsetStoreTest.java index a13930fd..81c394c4 100644 --- a/client/src/test/java/org/apache/rocketmq/client/consumer/store/RemoteBrokerOffsetStoreTest.java +++ b/client/src/test/java/org/apache/rocketmq/client/consumer/store/RemoteBrokerOffsetStoreTest.java @@ -119,7 +119,7 @@ public class RemoteBrokerOffsetStoreTest { assertThat(offsetStore.readOffset(messageQueue, ReadOffsetType.READ_FROM_STORE)).isEqualTo(1023); offsetStore.updateOffset(messageQueue, 1025, false); - offsetStore.persistAll(new HashSet<>(Collections.singletonList(messageQueue))); + offsetStore.persistAll(new HashSet(Collections.singletonList(messageQueue))); assertThat(offsetStore.readOffset(messageQueue, ReadOffsetType.READ_FROM_STORE)).isEqualTo(1025); } diff --git a/client/src/test/java/org/apache/rocketmq/client/impl/factory/MQClientInstanceTest.java b/client/src/test/java/org/apache/rocketmq/client/impl/factory/MQClientInstanceTest.java index eedf0b18..7e0b4f93 100644 --- a/client/src/test/java/org/apache/rocketmq/client/impl/factory/MQClientInstanceTest.java +++ b/client/src/test/java/org/apache/rocketmq/client/impl/factory/MQClientInstanceTest.java @@ -48,17 +48,17 @@ public class MQClientInstanceTest { TopicRouteData topicRouteData = new TopicRouteData(); topicRouteData.setFilterServerTable(new HashMap>()); - List brokerDataList = new ArrayList<>(); + List brokerDataList = new ArrayList(); BrokerData brokerData = new BrokerData(); brokerData.setBrokerName("BrokerA"); brokerData.setCluster("DefaultCluster"); - HashMap brokerAddrs = new HashMap<>(); + HashMap brokerAddrs = new HashMap(); brokerAddrs.put(0L, "127.0.0.1:10911"); brokerData.setBrokerAddrs(brokerAddrs); brokerDataList.add(brokerData); topicRouteData.setBrokerDatas(brokerDataList); - List queueDataList = new ArrayList<>(); + List queueDataList = new ArrayList(); QueueData queueData = new QueueData(); queueData.setBrokerName("BrokerA"); queueData.setPerm(6); diff --git a/client/src/test/java/org/apache/rocketmq/client/producer/DefaultMQProducerTest.java b/client/src/test/java/org/apache/rocketmq/client/producer/DefaultMQProducerTest.java index eddd3806..2f035e0f 100644 --- a/client/src/test/java/org/apache/rocketmq/client/producer/DefaultMQProducerTest.java +++ b/client/src/test/java/org/apache/rocketmq/client/producer/DefaultMQProducerTest.java @@ -194,17 +194,17 @@ public class DefaultMQProducerTest { TopicRouteData topicRouteData = new TopicRouteData(); topicRouteData.setFilterServerTable(new HashMap>()); - List brokerDataList = new ArrayList<>(); + List brokerDataList = new ArrayList(); BrokerData brokerData = new BrokerData(); brokerData.setBrokerName("BrokerA"); brokerData.setCluster("DefaultCluster"); - HashMap brokerAddrs = new HashMap<>(); + HashMap brokerAddrs = new HashMap(); brokerAddrs.put(0L, "127.0.0.1:10911"); brokerData.setBrokerAddrs(brokerAddrs); brokerDataList.add(brokerData); topicRouteData.setBrokerDatas(brokerDataList); - List queueDataList = new ArrayList<>(); + List queueDataList = new ArrayList(); QueueData queueData = new QueueData(); queueData.setBrokerName("BrokerA"); queueData.setPerm(6); diff --git a/client/src/test/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByHashTest.java b/client/src/test/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByHashTest.java index 64ef21de..056e910b 100644 --- a/client/src/test/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByHashTest.java +++ b/client/src/test/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByHashTest.java @@ -34,7 +34,7 @@ public class SelectMessageQueueByHashTest { Message message = new Message(topic, new byte[] {}); - List messageQueues = new ArrayList<>(); + List messageQueues = new ArrayList(); for (int i = 0; i < 10; i++) { MessageQueue messageQueue = new MessageQueue(topic, "DefaultBroker", i); messageQueues.add(messageQueue); diff --git a/common/pom.xml b/common/pom.xml index c2ab1879..835ffa63 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -27,6 +27,10 @@ rocketmq-common rocketmq-common ${project.version} + + 1.6 + 1.6 + diff --git a/common/src/main/java/org/apache/rocketmq/common/MixAll.java b/common/src/main/java/org/apache/rocketmq/common/MixAll.java index cbb395a0..4a54a602 100644 --- a/common/src/main/java/org/apache/rocketmq/common/MixAll.java +++ b/common/src/main/java/org/apache/rocketmq/common/MixAll.java @@ -256,7 +256,7 @@ public class MixAll { if (null == value) { value = ""; } - } catch (IllegalArgumentException | IllegalAccessException e) { + } catch (IllegalAccessException e) { e.printStackTrace(); } @@ -313,7 +313,7 @@ public class MixAll { try { field.setAccessible(true); value = field.get(object); - } catch (IllegalArgumentException | IllegalAccessException e) { + } catch (IllegalAccessException e) { e.printStackTrace(); } diff --git a/common/src/test/java/org/apache/rocketmq/common/MixAllTest.java b/common/src/test/java/org/apache/rocketmq/common/MixAllTest.java index 06024c35..8220981e 100644 --- a/common/src/test/java/org/apache/rocketmq/common/MixAllTest.java +++ b/common/src/test/java/org/apache/rocketmq/common/MixAllTest.java @@ -59,9 +59,9 @@ public class MixAllTest { file.delete(); } file.createNewFile(); - try (PrintWriter out = new PrintWriter(fileName)) { - out.write("TestForMixAll"); - } + PrintWriter out = new PrintWriter(fileName); + out.write("TestForMixAll"); + out.close(); String string = MixAll.file2String(fileName); assertThat(string).isEqualTo("TestForMixAll"); file.delete(); diff --git a/common/src/test/java/org/apache/rocketmq/common/filter/FilterAPITest.java b/common/src/test/java/org/apache/rocketmq/common/filter/FilterAPITest.java index 097a01cb..5137f328 100644 --- a/common/src/test/java/org/apache/rocketmq/common/filter/FilterAPITest.java +++ b/common/src/test/java/org/apache/rocketmq/common/filter/FilterAPITest.java @@ -36,7 +36,7 @@ public class FilterAPITest { assertThat(subscriptionData.getTopic()).isEqualTo(topic); assertThat(subscriptionData.getSubString()).isEqualTo(subString); String [] tags = subString.split("\\|\\|"); - Set tagSet = new HashSet<>(); + Set tagSet = new HashSet(); for (String tag : tags) { tagSet.add(tag.trim()); } diff --git a/remoting/pom.xml b/remoting/pom.xml index b25e0623..15523412 100644 --- a/remoting/pom.xml +++ b/remoting/pom.xml @@ -27,6 +27,10 @@ rocketmq-remoting rocketmq-remoting ${project.version} + + 1.6 + 1.6 + diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingClient.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingClient.java index d84f2a81..85f9244d 100644 --- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingClient.java +++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingClient.java @@ -73,12 +73,12 @@ public class NettyRemotingClient extends NettyRemotingAbstract implements Remoti private final Bootstrap bootstrap = new Bootstrap(); private final EventLoopGroup eventLoopGroupWorker; private final Lock lockChannelTables = new ReentrantLock(); - private final ConcurrentHashMap channelTables = new ConcurrentHashMap<>(); + private final ConcurrentHashMap channelTables = new ConcurrentHashMap(); private final Timer timer = new Timer("ClientHouseKeepingService", true); - private final AtomicReference> namesrvAddrList = new AtomicReference<>(); - private final AtomicReference namesrvAddrChoosed = new AtomicReference<>(); + private final AtomicReference> namesrvAddrList = new AtomicReference>(); + private final AtomicReference namesrvAddrChoosed = new AtomicReference(); private final AtomicInteger namesrvIndex = new AtomicInteger(initValueIndex()); private final Lock lockNamesrvChannel = new ReentrantLock(); @@ -522,7 +522,7 @@ public class NettyRemotingClient extends NettyRemotingAbstract implements Remoti executorThis = this.publicExecutor; } - Pair pair = new Pair<>(processor, executorThis); + Pair pair = new Pair(processor, executorThis); this.processorTable.put(requestCode, pair); } -- GitLab