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) {
|
while (true) {
|
||||||
if (Thread.currentThread().isInterrupted()) {
|
if (Thread.currentThread().isInterrupted()) {
|
||||||
log.warn("Prefetch thread was interrupted.");
|
log.warn("Prefetch thread was interrupted.");
|
||||||
|
callShutdownOnStrategy();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (prefetchCounters.shouldGetNewRecords()) {
|
if (prefetchCounters.shouldGetNewRecords()) {
|
||||||
|
|
@ -129,8 +130,8 @@ public class PrefetchGetRecordsCache implements GetRecordsCache {
|
||||||
getRecordsResultQueue.put(processRecordsInput);
|
getRecordsResultQueue.put(processRecordsInput);
|
||||||
prefetchCounters.added(processRecordsInput);
|
prefetchCounters.added(processRecordsInput);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
log.info("Thread was interrupted, indicating shutdown was called on the cache. Calling shutdown on the GetRecordsRetrievalStrategy.");
|
log.info("Thread was interrupted, indicating shutdown was called on the cache.");
|
||||||
getRecordsRetrievalStrategy.shutdown();
|
callShutdownOnStrategy();
|
||||||
} catch (Error e) {
|
} catch (Error e) {
|
||||||
log.error("Error was thrown while getting records, please check for the 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 {
|
private void sleepBeforeNextCall() throws InterruptedException {
|
||||||
if (lastSuccessfulCall == null) {
|
if (lastSuccessfulCall == null) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue