Skip to content

Commit

Permalink
fix: close executor when closing pool (#501)
Browse files Browse the repository at this point in the history
  • Loading branch information
olavloite committed Oct 9, 2020
1 parent 62fa39a commit 2086746
Showing 1 changed file with 24 additions and 16 deletions.
Expand Up @@ -398,26 +398,34 @@ void checkAndCloseSpanners(CheckAndCloseSpannersMode mode) {
keysStillInUse.add(entry.getKey());
}
}
if (keysStillInUse.isEmpty() || mode == CheckAndCloseSpannersMode.WARN) {
if (!keysStillInUse.isEmpty()) {
try {
if (keysStillInUse.isEmpty() || mode == CheckAndCloseSpannersMode.WARN) {
if (!keysStillInUse.isEmpty()) {
logLeakedConnections(keysStillInUse);
logger.log(
Level.WARNING,
"There is/are "
+ keysStillInUse.size()
+ " connection(s) still open."
+ " Close all connections before stopping the application");
}
// Force close all Spanner instances by passing in a value that will always be less than
// the
// difference between the current time and the close time of a connection.
closeUnusedSpanners(Long.MIN_VALUE);
} else {
logLeakedConnections(keysStillInUse);
logger.log(
Level.WARNING,
throw SpannerExceptionFactory.newSpannerException(
ErrorCode.FAILED_PRECONDITION,
"There is/are "
+ keysStillInUse.size()
+ " connection(s) still open."
+ " Close all connections before stopping the application");
+ " connection(s) still open. Close all connections before calling closeSpanner()");
}
// Force close all Spanner instances by passing in a value that will always be less than the
// difference between the current time and the close time of a connection.
closeUnusedSpanners(Long.MIN_VALUE);
} else {
logLeakedConnections(keysStillInUse);
throw SpannerExceptionFactory.newSpannerException(
ErrorCode.FAILED_PRECONDITION,
"There is/are "
+ keysStillInUse.size()
+ " connection(s) still open. Close all connections before calling closeSpanner()");
} finally {
if (closerService != null) {
closerService.shutdown();
}
initialized = false;
}
}
}
Expand Down

0 comments on commit 2086746

Please sign in to comment.