From 3e38468d554309c6f7e105e880af01063201c19c Mon Sep 17 00:00:00 2001 From: dugenkui03 Date: Thu, 7 Apr 2022 23:17:58 +0800 Subject: [PATCH 1/3] remove checked Exception which will never be thrown from method signature --- .../rocketmq/client/impl/MQClientAPIImpl.java | 18 ++++++++---------- .../rocketmq/srvutil/FileWatchService.java | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java b/client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java index e7e805d173..a915e48645 100644 --- a/client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java +++ b/client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java @@ -300,7 +300,7 @@ public class MQClientAPIImpl { public void createPlainAccessConfig(final String addr, final PlainAccessConfig plainAccessConfig, final long timeoutMillis) - throws RemotingException, MQBrokerException, InterruptedException, MQClientException { + throws RemotingException, InterruptedException, MQClientException { CreateAccessConfigRequestHeader requestHeader = new CreateAccessConfigRequestHeader(); requestHeader.setAccessKey(plainAccessConfig.getAccessKey()); requestHeader.setSecretKey(plainAccessConfig.getSecretKey()); @@ -328,7 +328,7 @@ public class MQClientAPIImpl { } public void deleteAccessConfig(final String addr, final String accessKey, final long timeoutMillis) - throws RemotingException, MQBrokerException, InterruptedException, MQClientException { + throws RemotingException, InterruptedException, MQClientException { DeleteAccessConfigRequestHeader requestHeader = new DeleteAccessConfigRequestHeader(); requestHeader.setAccessKey(accessKey); @@ -349,7 +349,7 @@ public class MQClientAPIImpl { } public void updateGlobalWhiteAddrsConfig(final String addr, final String globalWhiteAddrs, final long timeoutMillis) - throws RemotingException, MQBrokerException, InterruptedException, MQClientException { + throws RemotingException, InterruptedException, MQClientException { UpdateGlobalWhiteAddrsConfigRequestHeader requestHeader = new UpdateGlobalWhiteAddrsConfigRequestHeader(); requestHeader.setGlobalWhiteAddrs(globalWhiteAddrs); @@ -404,7 +404,7 @@ public class MQClientAPIImpl { } public AclConfig getBrokerClusterConfig(final String addr, - final long timeoutMillis) throws RemotingCommandException, InterruptedException, RemotingTimeoutException, + final long timeoutMillis) throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQBrokerException { RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_BROKER_CLUSTER_ACL_CONFIG, null); @@ -1073,7 +1073,7 @@ public class MQClientAPIImpl { final EndTransactionRequestHeader requestHeader, final String remark, final long timeoutMillis - ) throws RemotingException, MQBrokerException, InterruptedException { + ) throws RemotingException, InterruptedException { RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.END_TRANSACTION, requestHeader); request.setRemark(remark); @@ -2103,8 +2103,7 @@ public class MQClientAPIImpl { } public Set getClusterList(String topic, - long timeoutMillis) throws MQClientException, RemotingConnectException, - RemotingSendRequestException, RemotingTimeoutException, InterruptedException { + long timeoutMillis) { return Collections.EMPTY_SET; } @@ -2170,8 +2169,7 @@ public class MQClientAPIImpl { } public void updateNameServerConfig(final Properties properties, final List nameServers, long timeoutMillis) - throws UnsupportedEncodingException, - MQBrokerException, InterruptedException, RemotingTimeoutException, RemotingSendRequestException, + throws UnsupportedEncodingException, InterruptedException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQClientException { String str = MixAll.properties2String(properties); if (str == null || str.length() < 1) { @@ -2281,7 +2279,7 @@ public class MQClientAPIImpl { } public boolean resumeCheckHalfMessage(final String addr, String msgId, - final long timeoutMillis) throws RemotingException, MQClientException, InterruptedException { + final long timeoutMillis) throws RemotingException, InterruptedException { ResumeCheckHalfMessageRequestHeader requestHeader = new ResumeCheckHalfMessageRequestHeader(); requestHeader.setMsgId(msgId); diff --git a/srvutil/src/main/java/org/apache/rocketmq/srvutil/FileWatchService.java b/srvutil/src/main/java/org/apache/rocketmq/srvutil/FileWatchService.java index 111cedea79..1ca3e29059 100644 --- a/srvutil/src/main/java/org/apache/rocketmq/srvutil/FileWatchService.java +++ b/srvutil/src/main/java/org/apache/rocketmq/srvutil/FileWatchService.java @@ -89,7 +89,7 @@ public class FileWatchService extends ServiceThread { log.info(this.getServiceName() + " service end"); } - private String hash(String filePath) throws IOException, NoSuchAlgorithmException { + private String hash(String filePath) throws IOException { Path path = Paths.get(filePath); md.update(Files.readAllBytes(path)); byte[] hash = md.digest(); From 164a1e96423fcfcc4bd0e87aa0ddbe79063f922e Mon Sep 17 00:00:00 2001 From: dugenkui03 Date: Thu, 7 Apr 2022 23:26:10 +0800 Subject: [PATCH 2/3] remove checked Exception which will never be thrown from method signature --- .../rocketmq/client/impl/MQClientAPIImpl.java | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java b/client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java index a915e48645..be70d9f5fa 100644 --- a/client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java +++ b/client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java @@ -528,7 +528,7 @@ public class MQClientAPIImpl { final AtomicInteger times, final SendMessageContext context, final DefaultMQProducerImpl producer - ) throws InterruptedException, RemotingException { + ) { final long beginStartTime = System.currentTimeMillis(); try { this.remotingClient.invokeAsync(addr, request, timeoutMillis, new InvokeCallback() { @@ -621,22 +621,10 @@ public class MQClientAPIImpl { } String addr = instance.findBrokerAddressInPublish(retryBrokerName); log.warn("async send msg by retry {} times. topic={}, brokerAddr={}, brokerName={}", tmp, msg.getTopic(), addr, - retryBrokerName, e); - try { - request.setOpaque(RemotingCommand.createNewRequestId()); - sendMessageAsync(addr, retryBrokerName, msg, timeoutMillis, request, sendCallback, topicPublishInfo, instance, + retryBrokerName, e); + request.setOpaque(RemotingCommand.createNewRequestId()); + sendMessageAsync(addr, retryBrokerName, msg, timeoutMillis, request, sendCallback, topicPublishInfo, instance, timesTotal, curTimes, context, producer); - } catch (InterruptedException e1) { - onExceptionImpl(retryBrokerName, msg, timeoutMillis, request, sendCallback, topicPublishInfo, instance, timesTotal, curTimes, e1, - context, false, producer); - } catch (RemotingTooMuchRequestException e1) { - onExceptionImpl(retryBrokerName, msg, timeoutMillis, request, sendCallback, topicPublishInfo, instance, timesTotal, curTimes, e1, - context, false, producer); - } catch (RemotingException e1) { - producer.updateFaultItem(brokerName, 3000, true); - onExceptionImpl(retryBrokerName, msg, timeoutMillis, request, sendCallback, topicPublishInfo, instance, timesTotal, curTimes, e1, - context, true, producer); - } } else { if (context != null) { From 049abc24342d8bc10c1b4e842b948c777235e72d Mon Sep 17 00:00:00 2001 From: dugenkui03 Date: Sun, 10 Apr 2022 11:33:11 +0800 Subject: [PATCH 3/3] remove checked Exception which will never be thrown from method signature --- .../main/java/org/apache/rocketmq/srvutil/FileWatchService.java | 1 - 1 file changed, 1 deletion(-) diff --git a/srvutil/src/main/java/org/apache/rocketmq/srvutil/FileWatchService.java b/srvutil/src/main/java/org/apache/rocketmq/srvutil/FileWatchService.java index 1ca3e29059..c2aaf9620e 100644 --- a/srvutil/src/main/java/org/apache/rocketmq/srvutil/FileWatchService.java +++ b/srvutil/src/main/java/org/apache/rocketmq/srvutil/FileWatchService.java @@ -23,7 +23,6 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.List; import org.apache.commons.lang3.StringUtils;