Skip to content

Commit d1558b4

Browse files
committed
More clean up
1 parent aa4817f commit d1558b4

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

clients/src/test/java/org/apache/kafka/clients/producer/internals/TransactionManagerTest.java

+7-4
Original file line numberDiff line numberDiff line change
@@ -3799,14 +3799,12 @@ MAX_REQUEST_SIZE, ACKS_ALL, MAX_RETRIES, new SenderMetricsRegistry(new Metrics(t
37993799

38003800
@Test
38013801
public void testBackgroundInvalidStateTransitionIsFatal() {
3802-
// The default logic is to poison the transaction manager on an invalid state transition attempt if that
3803-
// attempt happens on the Sender thread. Here the logic is altered to always poison on invalid attempts to
3804-
// mimic as though it's being invoked by the Sender.
38053802
initializeTransactionManager(Optional.of(transactionalId), true);
3806-
transactionManager.setShouldSetToFatalErrorStateOverride(true);
38073803
doInitTransactions();
38083804
assertTrue(transactionManager.isTransactional());
38093805

3806+
transactionManager.setShouldSetToFatalErrorStateOverride(true);
3807+
38103808
// Intentionally perform an operation that will cause an invalid state transition. The detection of this
38113809
// will result in a poisoning of the transaction manager for all subsequent transactional operations since
38123810
// it was performed in the background.
@@ -4376,6 +4374,10 @@ private void runUntil(Supplier<Boolean> condition) {
43764374
ProducerTestUtils.runUntil(sender, condition);
43774375
}
43784376

4377+
/**
4378+
* This subclass exists only to optionally change the default behavior related to poisoning the state
4379+
* on invalid state transition attempts.
4380+
*/
43794381
private static class TestableTransactionManager extends TransactionManager {
43804382

43814383
private Optional<Boolean> shouldPoisonStateOnInvalidTransitionOverride;
@@ -4395,6 +4397,7 @@ private void setShouldSetToFatalErrorStateOverride(boolean override) {
43954397

43964398
@Override
43974399
protected boolean shouldPoisonStateOnInvalidTransition() {
4400+
// If there's an override, use it, otherwise invoke the default (i.e. super class) logic.
43984401
return shouldPoisonStateOnInvalidTransitionOverride.orElseGet(super::shouldPoisonStateOnInvalidTransition);
43994402
}
44004403
}

0 commit comments

Comments
 (0)