Source:
private void shutDownGracefully() { if (log.isDebugEnabled()) log.debugf("Wait for on-going transactions to finish for %s.", Util.prettyPrintTime(configuration.transaction().cacheStopTimeout(), TimeUnit.MILLISECONDS)); long now = System.nanoTime(); long failTime = now + TimeUnit.MILLISECONDS.toNanos(configuration.transaction().cacheStopTimeout()); boolean localTxsOnGoing = !localTransactions.isEmpty(); while (localTxsOnGoing && System.nanoTime() - failTime < 0) { try { Thread.sleep(30); localTxsOnGoing = !localTransactions.isEmpty(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); log.debugf("Interrupted waiting for %d on-going local transactions to finish.", localTransactions.size()); } } if (executorService != null) { Future<?> remoteTxsFuture = executorService.submit(new Runnable() { @Override public void run() { int transactions = 0; for (RemoteTransaction tx : remoteTransactions.values()) { synchronized (tx) { tx.markForRollback(true); } if (Thread.currentThread().isInterrupted()) break; } } }); try { remoteTxsFuture.get(failTime - System.nanoTime(), TimeUnit.NANOSECONDS); } catch (InterruptedException e) { log.debug("Interrupted waiting for on-going remote transactional commands to finish."); remoteTxsFuture.cancel(true); Thread.currentThread().interrupt(); } catch (ExecutionException e) { log.debug("Exception while waiting for on-going remote transactional commands to finish", e); } catch (TimeoutException e) { remoteTxsFuture.cancel(true); } } if (!localTransactions.isEmpty() || remoteTransactionsCount() != 0) { log.unfinishedTransactionsRemain(localTransactions.size(), remoteTransactionsCount()); if (trace) { log.tracef("Unfinished local transactions: %s", localTransactions.values().stream().map(tx -> tx.getGlobalTransaction().toString()) .collect(Collectors.joining(", ", "[", "]"))); log.tracef("Unfinished remote transactions: %s", remoteTransactions == null ? "none" : remoteTransactions.keySet()); } } else { log.debug("All transactions terminated"); } }

Target:
private void shutDownGracefully() { if (log.isDebugEnabled()) log.debugf("Wait for on-going transactions to finish for %s.", Util.prettyPrintTime(configuration.transaction().cacheStopTimeout(), TimeUnit.MILLISECONDS)); long now = System.nanoTime(); long failTime = now + TimeUnit.MILLISECONDS.toNanos(configuration.transaction().cacheStopTimeout()); boolean localTxsOnGoing = !localTransactions.isEmpty(); while (localTxsOnGoing && System.nanoTime() - failTime < 0) { try { Thread.sleep(30); localTxsOnGoing = !localTransactions.isEmpty(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); log.debugf("Interrupted waiting for %d on-going local transactions to finish.", localTransactions.size()); } } if (remoteTransactions != null) { Future<?> remoteTxsFuture = timeoutExecutor.submit(new Runnable() { @Override public void run() { int transactions = 0; for (RemoteTransaction tx : remoteTransactions.values()) { synchronized (tx) { tx.markForRollback(true); } if (Thread.currentThread().isInterrupted()) break; } } }); try { remoteTxsFuture.get(failTime - System.nanoTime(), TimeUnit.NANOSECONDS); } catch (InterruptedException e) { log.debug("Interrupted waiting for on-going remote transactional commands to finish."); remoteTxsFuture.cancel(true); Thread.currentThread().interrupt(); } catch (ExecutionException e) { log.debug("Exception while waiting for on-going remote transactional commands to finish", e); } catch (TimeoutException e) { remoteTxsFuture.cancel(true); } } if (!localTransactions.isEmpty() || remoteTransactionsCount() != 0) { log.unfinishedTransactionsRemain(localTransactions.size(), remoteTransactionsCount()); if (trace) { log.tracef("Unfinished local transactions: %s", localTransactions.values().stream().map(tx -> tx.getGlobalTransaction().toString()) .collect(Collectors.joining(", ", "[", "]"))); log.tracef("Unfinished remote transactions: %s", remoteTransactions == null ? "none" : remoteTransactions.keySet()); } } else { log.debug("All transactions terminated"); } }