only close exec if it exists (#9952)

This commit is contained in:
Clint Wylie 2020-05-29 20:09:34 -07:00 committed by GitHub
parent e03d38b6c8
commit c2c38f6ac2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -560,16 +560,18 @@ public class KinesisRecordSupplier implements RecordSupplier<String, String>
assign(ImmutableSet.of());
scheduledExec.shutdown();
if (scheduledExec != null) {
scheduledExec.shutdown();
try {
if (!scheduledExec.awaitTermination(EXCEPTION_RETRY_DELAY_MS, TimeUnit.MILLISECONDS)) {
scheduledExec.shutdownNow();
try {
if (!scheduledExec.awaitTermination(EXCEPTION_RETRY_DELAY_MS, TimeUnit.MILLISECONDS)) {
scheduledExec.shutdownNow();
}
}
catch (InterruptedException e) {
log.warn(e, "InterruptedException while shutting down");
throw new RuntimeException(e);
}
}
catch (InterruptedException e) {
log.warn(e, "InterruptedException while shutting down");
throw new RuntimeException(e);
}
this.closed = true;