You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "hachikuji (via GitHub)" <gi...@apache.org> on 2023/05/01 17:19:52 UTC

[GitHub] [kafka] hachikuji commented on a diff in pull request #13591: KAFKA-14831: Illegal state errors should be fatal in transactional producer

hachikuji commented on code in PR #13591:
URL: https://github.com/apache/kafka/pull/13591#discussion_r1181734242


##########
clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionManager.java:
##########
@@ -968,13 +1035,23 @@ private void transitionTo(State target) {
     }
 
     private void transitionTo(State target, RuntimeException error) {
+        transitionTo(target, error, InvalidStateTransitionHandler.SET_FATAL_STATE);
+    }
+
+    private void transitionTo(State target, RuntimeException error, InvalidStateTransitionHandler invalidStateTransitionHandler) {
         if (!currentState.isTransitionValid(currentState, target)) {
             String idString = transactionalId == null ?  "" : "TransactionalId " + transactionalId + ": ";
-            throw new IllegalStateException(idString + "Invalid transition attempted from state "
-                    + currentState.name() + " to state " + target.name());
-        }
+            String message = idString + "Invalid transition attempted from state "
+                    + currentState.name() + " to state " + target.name();
 
-        if (target == State.FATAL_ERROR || target == State.ABORTABLE_ERROR) {
+            // See InvalidStateTransitionHandler above for more detail.
+            if (invalidStateTransitionHandler == InvalidStateTransitionHandler.THROW_EXCEPTION) {
+                throw new IllegalStateException(message);
+            } else {
+                lastError = new IllegalStateException(message);
+                target = State.FATAL_ERROR;

Review Comment:
   Would it make sense to also throw after we have transitioned to FATAL_ERROR?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org