@@ -647,27 +647,20 @@ private TransactionManager configureTransactionState(ProducerConfig config,
647647 * @throws InterruptException if the thread is interrupted while blocked
648648 */
649649 public void initTransactions () {
650- throwIfNoTransactionManager ();
651- throwIfProducerClosed ();
652- long now = time .nanoseconds ();
653- TransactionalRequestResult result = transactionManager .initializeTransactions ();
654- sender .wakeup ();
655- result .await (maxBlockTimeMs , TimeUnit .MILLISECONDS );
656- producerMetrics .recordInit (time .nanoseconds () - now );
657- transactionManager .maybeUpdateTransactionV2Enabled (true );
650+ initTransactions (false );
658651 }
659652
660653 /**
661654 * Initialize the transactional state for this producer, similar to {@link #initTransactions()} but
662- * with additional handling for two-phase commit (2PC). Must be called before any send operations
663- * that require a {@code transactionalId}.
655+ * with additional capabilities to keep a previously prepared transaction.
656+ * Must be called before any send operations that require a {@code transactionalId}.
664657 * <p>
665658 * Unlike the standard {@link #initTransactions()}, when {@code keepPreparedTxn} is set to
666- * {@code true}, the producer does <em>not</em> automatically abort existing transactions
667- * in the “prepare” phase. Instead, it enters a recovery mode allowing only finalization
668- * of those previously prepared transactions. This behavior is crucial for 2PC scenarios,
669- * where transactions should remain intact until the external transaction manager decides
670- * whether to commit or abort.
659+ * {@code true}, the producer does <em>not</em> automatically abort existing transactions.
660+ * Instead, it enters a recovery mode allowing only finalization of those previously prepared transactions.
661+ *
662+ * This behavior is especially crucial for 2PC scenarios, where transactions should remain intact
663+ * until the external transaction manager decides whether to commit or abort.
671664 * <p>
672665 * When {@code keepPreparedTxn} is {@code false}, this behaves like the normal transactional
673666 * initialization, aborting any unfinished transactions and resetting the producer for
0 commit comments