From 9ad9ad064f32470ae7e61ca3c400c680e8ab5ab4 Mon Sep 17 00:00:00 2001 From: yukon Date: Wed, 5 Jul 2017 14:48:16 +0800 Subject: [PATCH] [ROCKETMQ-238] Catch Throwable to avoid error cancel some key scheduled tasks. --- .../java/org/apache/rocketmq/broker/BrokerController.java | 4 ++-- .../rocketmq/broker/client/ClientHousekeepingService.java | 4 ++-- .../apache/rocketmq/remoting/netty/NettyRemotingClient.java | 2 +- .../apache/rocketmq/remoting/netty/NettyRemotingServer.java | 2 +- .../java/org/apache/rocketmq/store/DefaultMessageStore.java | 4 ++-- .../rocketmq/store/schedule/ScheduleMessageService.java | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java b/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java index 1416ebf638e..53968fa59e8 100644 --- a/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java +++ b/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java @@ -296,7 +296,7 @@ public void run() { public void run() { try { BrokerController.this.protectBroker(); - } catch (Exception e) { + } catch (Throwable e) { log.error("protectBroker error.", e); } } @@ -307,7 +307,7 @@ public void run() { public void run() { try { BrokerController.this.printWaterMark(); - } catch (Exception e) { + } catch (Throwable e) { log.error("printWaterMark error.", e); } } diff --git a/broker/src/main/java/org/apache/rocketmq/broker/client/ClientHousekeepingService.java b/broker/src/main/java/org/apache/rocketmq/broker/client/ClientHousekeepingService.java index 559dac1d832..c61531c201d 100644 --- a/broker/src/main/java/org/apache/rocketmq/broker/client/ClientHousekeepingService.java +++ b/broker/src/main/java/org/apache/rocketmq/broker/client/ClientHousekeepingService.java @@ -45,8 +45,8 @@ public void start() { public void run() { try { ClientHousekeepingService.this.scanExceptionChannel(); - } catch (Exception e) { - log.error("", e); + } catch (Throwable e) { + log.error("Error occurred when scan not active client channels.", e); } } }, 1000 * 10, 1000 * 10, TimeUnit.MILLISECONDS); 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 1c3da9adca2..db6a7e4bab4 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 @@ -166,7 +166,7 @@ public void initChannel(SocketChannel ch) throws Exception { public void run() { try { NettyRemotingClient.this.scanResponseTable(); - } catch (Exception e) { + } catch (Throwable e) { log.error("scanResponseTable exception", e); } } diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingServer.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingServer.java index a9a55abae0b..b2041b2ac21 100644 --- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingServer.java +++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingServer.java @@ -195,7 +195,7 @@ public void initChannel(SocketChannel ch) throws Exception { public void run() { try { NettyRemotingServer.this.scanResponseTable(); - } catch (Exception e) { + } catch (Throwable e) { log.error("scanResponseTable exception", e); } } diff --git a/store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java b/store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java index 4549f1ea32b..b5bac3f721f 100644 --- a/store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java +++ b/store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java @@ -1443,7 +1443,7 @@ public void run() { this.deleteExpiredFiles(); this.redeleteHangedFile(); - } catch (Exception e) { + } catch (Throwable e) { DefaultMessageStore.log.warn(this.getServiceName() + " service has exception. ", e); } } @@ -1583,7 +1583,7 @@ class CleanConsumeQueueService { public void run() { try { this.deleteExpiredFiles(); - } catch (Exception e) { + } catch (Throwable e) { DefaultMessageStore.log.warn(this.getServiceName() + " service has exception. ", e); } } diff --git a/store/src/main/java/org/apache/rocketmq/store/schedule/ScheduleMessageService.java b/store/src/main/java/org/apache/rocketmq/store/schedule/ScheduleMessageService.java index 172954deea1..012a4f0550a 100644 --- a/store/src/main/java/org/apache/rocketmq/store/schedule/ScheduleMessageService.java +++ b/store/src/main/java/org/apache/rocketmq/store/schedule/ScheduleMessageService.java @@ -121,7 +121,7 @@ public void start() { public void run() { try { ScheduleMessageService.this.persist(); - } catch (Exception e) { + } catch (Throwable e) { log.error("scheduleAtFixedRate flush exception", e); } }