未验证 提交 bf848c14 编写于 作者: Z Zhanhui Li 提交者: GitHub

Check if pull message service has shutdown before scheduling pull requests (#277)

上级 d035ccb0
...@@ -44,13 +44,16 @@ public class PullMessageService extends ServiceThread { ...@@ -44,13 +44,16 @@ public class PullMessageService extends ServiceThread {
} }
public void executePullRequestLater(final PullRequest pullRequest, final long timeDelay) { public void executePullRequestLater(final PullRequest pullRequest, final long timeDelay) {
if (!isStopped()) {
this.scheduledExecutorService.schedule(new Runnable() { this.scheduledExecutorService.schedule(new Runnable() {
@Override @Override
public void run() { public void run() {
PullMessageService.this.executePullRequestImmediately(pullRequest); PullMessageService.this.executePullRequestImmediately(pullRequest);
} }
}, timeDelay, TimeUnit.MILLISECONDS); }, timeDelay, TimeUnit.MILLISECONDS);
} else {
log.warn("PullMessageServiceScheduledThread has shutdown");
}
} }
public void executePullRequestImmediately(final PullRequest pullRequest) { public void executePullRequestImmediately(final PullRequest pullRequest) {
...@@ -62,7 +65,11 @@ public class PullMessageService extends ServiceThread { ...@@ -62,7 +65,11 @@ public class PullMessageService extends ServiceThread {
} }
public void executeTaskLater(final Runnable r, final long timeDelay) { public void executeTaskLater(final Runnable r, final long timeDelay) {
if (!isStopped()) {
this.scheduledExecutorService.schedule(r, timeDelay, TimeUnit.MILLISECONDS); this.scheduledExecutorService.schedule(r, timeDelay, TimeUnit.MILLISECONDS);
} else {
log.warn("PullMessageServiceScheduledThread has shutdown");
}
} }
public ScheduledExecutorService getScheduledExecutorService() { public ScheduledExecutorService getScheduledExecutorService() {
...@@ -86,10 +93,8 @@ public class PullMessageService extends ServiceThread { ...@@ -86,10 +93,8 @@ public class PullMessageService extends ServiceThread {
while (!this.isStopped()) { while (!this.isStopped()) {
try { try {
PullRequest pullRequest = this.pullRequestQueue.take(); PullRequest pullRequest = this.pullRequestQueue.take();
if (pullRequest != null) {
this.pullMessage(pullRequest); this.pullMessage(pullRequest);
} } catch (InterruptedException ignored) {
} catch (InterruptedException e) {
} catch (Exception e) { } catch (Exception e) {
log.error("Pull Message Service Run Method exception", e); log.error("Pull Message Service Run Method exception", e);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册