Fix Kafka Indexing Service notice handle thread may never terminate (#6337)

* Fix Kafka Indexing Service notice handle thread may never terminate

* address comment

* handle null value
This commit is contained in:
QiuMM 2018-09-27 11:09:53 +08:00 committed by Gian Merlino
parent faf3f1e426
commit 993bc5e9d3
1 changed files with 6 additions and 2 deletions

View File

@ -367,8 +367,12 @@ public class KafkaSupervisor implements Supervisor
exec.submit(
() -> {
try {
while (!Thread.currentThread().isInterrupted()) {
final Notice notice = notices.take();
long pollTimeout = Math.max(ioConfig.getPeriod().getMillis(), MAX_RUN_FREQUENCY_MILLIS);
while (!Thread.currentThread().isInterrupted() && !stopped) {
final Notice notice = notices.poll(pollTimeout, TimeUnit.MILLISECONDS);
if (notice == null) {
continue;
}
try {
notice.handle();