未验证 提交 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 {
}
public void executePullRequestLater(final PullRequest pullRequest, final long timeDelay) {
this.scheduledExecutorService.schedule(new Runnable() {
@Override
public void run() {
PullMessageService.this.executePullRequestImmediately(pullRequest);
}
}, timeDelay, TimeUnit.MILLISECONDS);
if (!isStopped()) {
this.scheduledExecutorService.schedule(new Runnable() {
@Override
public void run() {
PullMessageService.this.executePullRequestImmediately(pullRequest);
}
}, timeDelay, TimeUnit.MILLISECONDS);
} else {
log.warn("PullMessageServiceScheduledThread has shutdown");
}
}
public void executePullRequestImmediately(final PullRequest pullRequest) {
......@@ -62,7 +65,11 @@ public class PullMessageService extends ServiceThread {
}
public void executeTaskLater(final Runnable r, final long timeDelay) {
this.scheduledExecutorService.schedule(r, timeDelay, TimeUnit.MILLISECONDS);
if (!isStopped()) {
this.scheduledExecutorService.schedule(r, timeDelay, TimeUnit.MILLISECONDS);
} else {
log.warn("PullMessageServiceScheduledThread has shutdown");
}
}
public ScheduledExecutorService getScheduledExecutorService() {
......@@ -86,10 +93,8 @@ public class PullMessageService extends ServiceThread {
while (!this.isStopped()) {
try {
PullRequest pullRequest = this.pullRequestQueue.take();
if (pullRequest != null) {
this.pullMessage(pullRequest);
}
} catch (InterruptedException e) {
this.pullMessage(pullRequest);
} catch (InterruptedException ignored) {
} catch (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.
先完成此消息的编辑!
想要评论请 注册