Making sure to call shutdown on strategy once the cache is interrupted.
This commit is contained in:
parent
7b76d1d56e
commit
cd1f944add
1 changed files with 9 additions and 2 deletions
|
|
@ -115,6 +115,7 @@ public class PrefetchGetRecordsCache implements GetRecordsCache {
|
|||
while (true) {
|
||||
if (Thread.currentThread().isInterrupted()) {
|
||||
log.warn("Prefetch thread was interrupted.");
|
||||
callShutdownOnStrategy();
|
||||
break;
|
||||
}
|
||||
if (prefetchCounters.shouldGetNewRecords()) {
|
||||
|
|
@ -129,8 +130,8 @@ public class PrefetchGetRecordsCache implements GetRecordsCache {
|
|||
getRecordsResultQueue.put(processRecordsInput);
|
||||
prefetchCounters.added(processRecordsInput);
|
||||
} catch (InterruptedException e) {
|
||||
log.info("Thread was interrupted, indicating shutdown was called on the cache. Calling shutdown on the GetRecordsRetrievalStrategy.");
|
||||
getRecordsRetrievalStrategy.shutdown();
|
||||
log.info("Thread was interrupted, indicating shutdown was called on the cache.");
|
||||
callShutdownOnStrategy();
|
||||
} catch (Error e) {
|
||||
log.error("Error was thrown while getting records, please check for the error", e);
|
||||
}
|
||||
|
|
@ -138,6 +139,12 @@ public class PrefetchGetRecordsCache implements GetRecordsCache {
|
|||
}
|
||||
}
|
||||
|
||||
private void callShutdownOnStrategy() {
|
||||
if (!getRecordsRetrievalStrategy.isShutdown()) {
|
||||
getRecordsRetrievalStrategy.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
private void sleepBeforeNextCall() throws InterruptedException {
|
||||
if (lastSuccessfulCall == null) {
|
||||
return;
|
||||
|
|
|
|||
Loading…
Reference in a new issue