[#148] Throwables.propagate in deprecated for making runtime exception more verbose (#160)
diff --git a/src/main/java/org/apache/rocketmq/dashboard/service/AbstractCommonService.java b/src/main/java/org/apache/rocketmq/dashboard/service/AbstractCommonService.java
index 004ece4..a546fbf 100644
--- a/src/main/java/org/apache/rocketmq/dashboard/service/AbstractCommonService.java
+++ b/src/main/java/org/apache/rocketmq/dashboard/service/AbstractCommonService.java
@@ -38,7 +38,8 @@
}
}
catch (Exception e) {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
}
if (CollectionUtils.isNotEmpty(brokerNameList)) {
diff --git a/src/main/java/org/apache/rocketmq/dashboard/service/client/MQAdminExtImpl.java b/src/main/java/org/apache/rocketmq/dashboard/service/client/MQAdminExtImpl.java
index 2e45a8b..360c0e3 100644
--- a/src/main/java/org/apache/rocketmq/dashboard/service/client/MQAdminExtImpl.java
+++ b/src/main/java/org/apache/rocketmq/dashboard/service/client/MQAdminExtImpl.java
@@ -140,7 +140,7 @@
}
@Override
- public SubscriptionGroupConfig examineSubscriptionGroupConfig(String addr, String group) {
+ public SubscriptionGroupConfig examineSubscriptionGroupConfig(String addr, String group) throws MQBrokerException {
RemotingClient remotingClient = MQAdminInstance.threadLocalRemotingClient();
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ALL_SUBSCRIPTIONGROUP_CONFIG, null);
RemotingCommand response = null;
@@ -148,7 +148,8 @@
response = remotingClient.invokeSync(addr, request, 3000);
}
catch (Exception err) {
- throw Throwables.propagate(err);
+ Throwables.throwIfUnchecked(err);
+ throw new RuntimeException(err);
}
assert response != null;
switch (response.getCode()) {
@@ -157,12 +158,12 @@
return subscriptionGroupWrapper.getSubscriptionGroupTable().get(group);
}
default:
- throw Throwables.propagate(new MQBrokerException(response.getCode(), response.getRemark()));
+ throw new MQBrokerException(response.getCode(), response.getRemark());
}
}
@Override
- public TopicConfig examineTopicConfig(String addr, String topic) {
+ public TopicConfig examineTopicConfig(String addr, String topic) throws MQBrokerException {
RemotingClient remotingClient = MQAdminInstance.threadLocalRemotingClient();
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ALL_TOPIC_CONFIG, null);
RemotingCommand response = null;
@@ -170,7 +171,8 @@
response = remotingClient.invokeSync(addr, request, 3000);
}
catch (Exception err) {
- throw Throwables.propagate(err);
+ Throwables.throwIfUnchecked(err);
+ throw new RuntimeException(err);
}
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
@@ -178,7 +180,7 @@
return topicConfigSerializeWrapper.getTopicConfigTable().get(topic);
}
default:
- throw Throwables.propagate(new MQBrokerException(response.getCode(), response.getRemark()));
+ throw new MQBrokerException(response.getCode(), response.getRemark());
}
}
diff --git a/src/main/java/org/apache/rocketmq/dashboard/service/impl/AclServiceImpl.java b/src/main/java/org/apache/rocketmq/dashboard/service/impl/AclServiceImpl.java
index c16392c..0c0177f 100644
--- a/src/main/java/org/apache/rocketmq/dashboard/service/impl/AclServiceImpl.java
+++ b/src/main/java/org/apache/rocketmq/dashboard/service/impl/AclServiceImpl.java
@@ -68,7 +68,8 @@
}
} catch (Exception e) {
log.error("getAclConfig error.", e);
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
AclConfig aclConfig = new AclConfig();
aclConfig.setGlobalWhiteAddrs(Collections.emptyList());
@@ -100,7 +101,8 @@
mqAdminExt.createAndUpdatePlainAccessConfig(addr, config);
}
} catch (Exception e) {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
}
@@ -116,7 +118,8 @@
log.info("Delete acl [{}] from broker [{}] complete", config.getAccessKey(), addr);
}
} catch (Exception e) {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
}
@@ -142,7 +145,8 @@
mqAdminExt.createAndUpdatePlainAccessConfig(addr, config);
}
} catch (Exception e) {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
}
@@ -174,7 +178,8 @@
}
}
} catch (Exception e) {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
}
@@ -206,7 +211,8 @@
}
}
} catch (Exception e) {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
}
@@ -249,7 +255,8 @@
}
}
} catch (Exception e) {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
}
@@ -261,7 +268,8 @@
mqAdminExt.createAndUpdatePlainAccessConfig(addr, config);
}
} catch (Exception e) {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
}
@@ -281,7 +289,8 @@
mqAdminExt.updateGlobalWhiteAddrConfig(addr, StringUtils.join(aclConfig.getGlobalWhiteAddrs(), ","));
}
} catch (Exception e) {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
}
@@ -297,7 +306,8 @@
mqAdminExt.updateGlobalWhiteAddrConfig(addr, StringUtils.join(aclConfig.getGlobalWhiteAddrs(), ","));
}
} catch (Exception e) {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
}
@@ -311,7 +321,8 @@
mqAdminExt.updateGlobalWhiteAddrConfig(addr, StringUtils.join(whiteList, ","));
}
} catch (Exception e) {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
}
diff --git a/src/main/java/org/apache/rocketmq/dashboard/service/impl/ClusterServiceImpl.java b/src/main/java/org/apache/rocketmq/dashboard/service/impl/ClusterServiceImpl.java
index 3512ec2..facf448 100644
--- a/src/main/java/org/apache/rocketmq/dashboard/service/impl/ClusterServiceImpl.java
+++ b/src/main/java/org/apache/rocketmq/dashboard/service/impl/ClusterServiceImpl.java
@@ -59,7 +59,8 @@
return resultMap;
}
catch (Exception err) {
- throw Throwables.propagate(err);
+ Throwables.throwIfUnchecked(err);
+ throw new RuntimeException(err);
}
}
@@ -70,7 +71,8 @@
return mqAdminExt.getBrokerConfig(brokerAddr);
}
catch (Exception e) {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
}
}
diff --git a/src/main/java/org/apache/rocketmq/dashboard/service/impl/ConsumerServiceImpl.java b/src/main/java/org/apache/rocketmq/dashboard/service/impl/ConsumerServiceImpl.java
index a5367a3..9fb51d6 100644
--- a/src/main/java/org/apache/rocketmq/dashboard/service/impl/ConsumerServiceImpl.java
+++ b/src/main/java/org/apache/rocketmq/dashboard/service/impl/ConsumerServiceImpl.java
@@ -73,8 +73,6 @@
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Service;
-import static com.google.common.base.Throwables.propagate;
-
@Service
public class ConsumerServiceImpl extends AbstractCommonService implements ConsumerService, InitializingBean, DisposableBean {
private Logger logger = LoggerFactory.getLogger(ConsumerServiceImpl.class);
@@ -131,7 +129,8 @@
}
}
catch (Exception err) {
- throw Throwables.propagate(err);
+ Throwables.throwIfUnchecked(err);
+ throw new RuntimeException(err);
}
List<GroupConsumeInfo> groupConsumeInfoList = Collections.synchronizedList(Lists.newArrayList());
CountDownLatch countDownLatch = new CountDownLatch(consumerGroupSet.size());
@@ -218,7 +217,8 @@
consumeStats = mqAdminExt.examineConsumeStats(groupName, topic);
}
catch (Exception e) {
- throw propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
List<MessageQueue> mqList = Lists.newArrayList(Iterables.filter(consumeStats.getOffsetTable().keySet(), new Predicate<MessageQueue>() {
@Override
@@ -278,7 +278,8 @@
return group2ConsumerInfoMap;
}
catch (Exception e) {
- throw propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
}
@@ -341,7 +342,8 @@
}
}
catch (Exception e) {
- throw propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
return consumerConfigInfoList;
}
@@ -366,7 +368,8 @@
}
}
catch (Exception e) {
- throw propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
return true;
}
@@ -393,7 +396,8 @@
}
}
catch (Exception err) {
- throw Throwables.propagate(err);
+ Throwables.throwIfUnchecked(err);
+ throw new RuntimeException(err);
}
return true;
}
@@ -408,7 +412,8 @@
}
}
catch (Exception e) {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
return brokerNameSet;
@@ -420,7 +425,8 @@
return mqAdminExt.examineConsumerConnectionInfo(consumerGroup);
}
catch (Exception e) {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
}
@@ -430,7 +436,8 @@
return mqAdminExt.getConsumerRunningInfo(consumerGroup, clientId, jstack);
}
catch (Exception e) {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
}
}
diff --git a/src/main/java/org/apache/rocketmq/dashboard/service/impl/DashboardCollectServiceImpl.java b/src/main/java/org/apache/rocketmq/dashboard/service/impl/DashboardCollectServiceImpl.java
index fa8f073..75cebd4 100644
--- a/src/main/java/org/apache/rocketmq/dashboard/service/impl/DashboardCollectServiceImpl.java
+++ b/src/main/java/org/apache/rocketmq/dashboard/service/impl/DashboardCollectServiceImpl.java
@@ -107,7 +107,8 @@
strings = Files.readLines(file, Charsets.UTF_8);
}
catch (IOException e) {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
StringBuffer sb = new StringBuffer();
for (String string : strings) {
diff --git a/src/main/java/org/apache/rocketmq/dashboard/service/impl/DlqMessageServiceImpl.java b/src/main/java/org/apache/rocketmq/dashboard/service/impl/DlqMessageServiceImpl.java
index 5a22643..4d3c3f7 100644
--- a/src/main/java/org/apache/rocketmq/dashboard/service/impl/DlqMessageServiceImpl.java
+++ b/src/main/java/org/apache/rocketmq/dashboard/service/impl/DlqMessageServiceImpl.java
@@ -62,10 +62,12 @@
&& e.getResponseCode() == ResponseCode.TOPIC_NOT_EXIST) {
return new MessagePage(new PageImpl<>(messageViews, page, 0), query.getTaskId());
} else {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
} catch (Exception e) {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
return messageService.queryMessageByPage(query);
}
diff --git a/src/main/java/org/apache/rocketmq/dashboard/service/impl/MessageServiceImpl.java b/src/main/java/org/apache/rocketmq/dashboard/service/impl/MessageServiceImpl.java
index b80864b..d51197f 100644
--- a/src/main/java/org/apache/rocketmq/dashboard/service/impl/MessageServiceImpl.java
+++ b/src/main/java/org/apache/rocketmq/dashboard/service/impl/MessageServiceImpl.java
@@ -115,7 +115,8 @@
if (err instanceof MQClientException) {
throw new ServiceException(-1, ((MQClientException) err).getErrorMessage());
}
- throw Throwables.propagate(err);
+ Throwables.throwIfUnchecked(err);
+ throw new RuntimeException(err);
}
}
@@ -185,7 +186,8 @@
});
return messageViewList;
} catch (Exception e) {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
} finally {
consumer.shutdown();
}
@@ -209,7 +211,8 @@
try {
return mqAdminExt.consumeMessageDirectly(consumerGroup, clientId, topic, msgId);
} catch (Exception e) {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
}
@@ -223,7 +226,8 @@
return mqAdminExt.consumeMessageDirectly(consumerGroup, connection.getClientId(), topic, msgId);
}
} catch (Exception e) {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
throw new IllegalStateException("NO CONSUMER");
@@ -388,7 +392,8 @@
PageImpl<MessageView> page = new PageImpl<>(messageViews, query.page(), total);
return new MessagePageTask(page, queueOffsetInfos);
} catch (Exception e) {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
} finally {
consumer.shutdown();
}
@@ -455,7 +460,8 @@
}
return new PageImpl<>(messageViews, query.page(), total);
} catch (Exception e) {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
} finally {
consumer.shutdown();
}
diff --git a/src/main/java/org/apache/rocketmq/dashboard/service/impl/MonitorServiceImpl.java b/src/main/java/org/apache/rocketmq/dashboard/service/impl/MonitorServiceImpl.java
index ea4dd58..d0e44c3 100644
--- a/src/main/java/org/apache/rocketmq/dashboard/service/impl/MonitorServiceImpl.java
+++ b/src/main/java/org/apache/rocketmq/dashboard/service/impl/MonitorServiceImpl.java
@@ -82,7 +82,8 @@
MixAll.string2File(dataStr, path);
}
catch (Exception e) {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
}
diff --git a/src/main/java/org/apache/rocketmq/dashboard/service/impl/ProducerServiceImpl.java b/src/main/java/org/apache/rocketmq/dashboard/service/impl/ProducerServiceImpl.java
index 8918060..5f5e491 100644
--- a/src/main/java/org/apache/rocketmq/dashboard/service/impl/ProducerServiceImpl.java
+++ b/src/main/java/org/apache/rocketmq/dashboard/service/impl/ProducerServiceImpl.java
@@ -35,7 +35,8 @@
return mqAdminExt.examineProducerConnectionInfo(producerGroup, topic);
}
catch (Exception e) {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
}
}
diff --git a/src/main/java/org/apache/rocketmq/dashboard/service/impl/TopicServiceImpl.java b/src/main/java/org/apache/rocketmq/dashboard/service/impl/TopicServiceImpl.java
index cd0dd89..1d7d571 100644
--- a/src/main/java/org/apache/rocketmq/dashboard/service/impl/TopicServiceImpl.java
+++ b/src/main/java/org/apache/rocketmq/dashboard/service/impl/TopicServiceImpl.java
@@ -84,7 +84,8 @@
allTopics.getTopicList().addAll(topics);
return allTopics;
} catch (Exception e) {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
}
@@ -93,7 +94,8 @@
try {
return mqAdminExt.examineTopicStats(topic);
} catch (Exception e) {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
}
@@ -102,7 +104,8 @@
try {
return mqAdminExt.examineTopicRouteInfo(topic);
} catch (Exception ex) {
- throw Throwables.propagate(ex);
+ Throwables.throwIfUnchecked(ex);
+ throw new RuntimeException(ex);
}
}
@@ -111,7 +114,8 @@
try {
return mqAdminExt.queryTopicConsumeByWho(topic);
} catch (Exception e) {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
}
@@ -126,7 +130,8 @@
mqAdminExt.createAndUpdateTopicConfig(clusterInfo.getBrokerAddrTable().get(brokerName).selectBrokerAddr(), topicConfig);
}
} catch (Exception err) {
- throw Throwables.propagate(err);
+ Throwables.throwIfUnchecked(err);
+ throw new RuntimeException(err);
}
}
@@ -137,7 +142,8 @@
clusterInfo = mqAdminExt.examineBrokerClusterInfo();
return mqAdminExt.examineTopicConfig(clusterInfo.getBrokerAddrTable().get(brokerName).selectBrokerAddr(), topic);
} catch (Exception e) {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
}
@@ -170,7 +176,8 @@
}
mqAdminExt.deleteTopicInNameServer(nameServerSet, topic);
} catch (Exception err) {
- throw Throwables.propagate(err);
+ Throwables.throwIfUnchecked(err);
+ throw new RuntimeException(err);
}
return true;
}
@@ -181,7 +188,8 @@
try {
clusterInfo = mqAdminExt.examineBrokerClusterInfo();
} catch (Exception err) {
- throw Throwables.propagate(err);
+ Throwables.throwIfUnchecked(err);
+ throw new RuntimeException(err);
}
for (String clusterName : clusterInfo.getClusterAddrTable().keySet()) {
deleteTopic(topic, clusterName);
@@ -197,11 +205,13 @@
try {
clusterInfo = mqAdminExt.examineBrokerClusterInfo();
} catch (Exception e) {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
mqAdminExt.deleteTopicInBroker(Sets.newHashSet(clusterInfo.getBrokerAddrTable().get(brokerName).selectBrokerAddr()), topic);
} catch (Exception e) {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
return true;
}
@@ -230,7 +240,8 @@
producer.start();
return producer.getDefaultMQProducerImpl().getmQClientFactory().getMQClientAPIImpl().getSystemTopicList(20000L);
} catch (Exception e) {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
} finally {
producer.shutdown();
}
@@ -258,7 +269,8 @@
);
return producer.send(msg);
} catch (Exception e) {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
} finally {
waitSendTraceFinish(producer, sendTopicMessageRequest.isTraceEnabled());
producer.shutdown();
diff --git a/src/main/java/org/apache/rocketmq/dashboard/task/CollectTaskRunnble.java b/src/main/java/org/apache/rocketmq/dashboard/task/CollectTaskRunnble.java
index b772176..28fd7a5 100644
--- a/src/main/java/org/apache/rocketmq/dashboard/task/CollectTaskRunnble.java
+++ b/src/main/java/org/apache/rocketmq/dashboard/task/CollectTaskRunnble.java
@@ -93,7 +93,8 @@
try {
list = dashboardCollectService.getTopicMap().get(topic);
} catch (ExecutionException e) {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
if (null == list) {
list = Lists.newArrayList();
diff --git a/src/main/java/org/apache/rocketmq/dashboard/task/DashboardCollectTask.java b/src/main/java/org/apache/rocketmq/dashboard/task/DashboardCollectTask.java
index c943284..d58668b 100644
--- a/src/main/java/org/apache/rocketmq/dashboard/task/DashboardCollectTask.java
+++ b/src/main/java/org/apache/rocketmq/dashboard/task/DashboardCollectTask.java
@@ -84,7 +84,8 @@
}
}
catch (Exception err) {
- throw Throwables.propagate(err);
+ Throwables.throwIfUnchecked(err);
+ throw new RuntimeException(err);
}
}
@@ -128,7 +129,8 @@
log.debug("Broker Collected Data in memory = {}" + JsonUtil.obj2String(dashboardCollectService.getBrokerMap().asMap()));
}
catch (Exception e) {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
}
@@ -144,10 +146,12 @@
Thread.sleep(1000);
}
catch (InterruptedException e1) {
- throw Throwables.propagate(e1);
+ Throwables.throwIfUnchecked(e1);
+ throw new RuntimeException(e1);
}
fetchBrokerRuntimeStats(brokerAddr, retryTime - 1);
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
}
@@ -197,7 +201,8 @@
}
catch (IOException e) {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
}
diff --git a/src/test/java/org/apache/rocketmq/dashboard/testbase/RocketMQConsoleTestBase.java b/src/test/java/org/apache/rocketmq/dashboard/testbase/RocketMQConsoleTestBase.java
index 29d6b8f..d4eff14 100644
--- a/src/test/java/org/apache/rocketmq/dashboard/testbase/RocketMQConsoleTestBase.java
+++ b/src/test/java/org/apache/rocketmq/dashboard/testbase/RocketMQConsoleTestBase.java
@@ -78,7 +78,8 @@
}
}
}
- throw Throwables.propagate(exception);
+ Throwables.throwIfUnchecked(exception);
+ throw new RuntimeException(exception);
}
}
@@ -91,7 +92,8 @@
producer.start();
}
catch (Exception e) {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
}
@@ -137,7 +139,8 @@
consumer.start();
}
catch (Exception e) {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
}