TransactionContextWrapper { void executePriorTransactionOperations(final TransactionContext localTransactionContext) { while (true) { final Collection<Entry<TransactionOperation, Boolean>> operationsBatch; synchronized (queuedTxOperations) { if (queuedTxOperations.isEmpty()) { if (!pendingEnqueue) { localTransactionContext.operationHandOffComplete(); transactionContext = localTransactionContext; } else { deferredTransactionContext = localTransactionContext; } return; } operationsBatch = new ArrayList<>(queuedTxOperations); queuedTxOperations.clear(); } for (Entry<TransactionOperation, Boolean> oper : operationsBatch) { final Boolean permit = oper.getValue(); if (permit.booleanValue() && !localTransactionContext.usesOperationLimiting()) { limiter.release(); } oper.getKey().invoke(localTransactionContext, permit); } } } TransactionContextWrapper(final TransactionIdentifier identifier, final ActorUtils actorUtils,
            final String shardName);   }
@Test public void testExecutePriorTransactionOperations() { for (int i = 0; i < 100; i++) { transactionContextWrapper.maybeExecuteTransactionOperation(mock(TransactionOperation.class)); } assertEquals(901, transactionContextWrapper.getLimiter().availablePermits()); transactionContextWrapper.executePriorTransactionOperations(transactionContext); assertEquals(1001, transactionContextWrapper.getLimiter().availablePermits()); }