sebastienviale commented on code in PR #16300:
URL: https://github.com/apache/kafka/pull/16300#discussion_r1689690526


##########
streams/src/test/java/org/apache/kafka/streams/processor/internals/StreamTaskTest.java:
##########
@@ -2647,6 +2657,62 @@ public void 
shouldNotCheckpointAfterRestorationWhenExactlyOnceEnabled() {
         verify(recordCollector, never()).offsets();
     }
 
+    @Test
+    public void 
shouldNotThrowStreamsExceptionWhenProcessingExceptionHandlerRepliesWithContinue()
 {
+        when(stateManager.taskId()).thenReturn(taskId);
+        when(stateManager.taskType()).thenReturn(TaskType.ACTIVE);
+        task = createStatelessTask(createConfig(AT_LEAST_ONCE, "100",
+            LogAndFailExceptionHandler.class.getName(), 
LogAndContinueProcessingExceptionHandler.class.getName()));
+
+        assertDoesNotThrow(() ->
+            task.punctuate(processorStreamTime, 1, 
PunctuationType.STREAM_TIME, timestamp -> {
+                throw new KafkaException("KABOOM!");
+            })
+        );
+    }
+
+    @Test
+    public void 
shouldThrowStreamsExceptionWhenProcessingExceptionHandlerRepliesWithFail() {
+        when(stateManager.taskId()).thenReturn(taskId);
+        when(stateManager.taskType()).thenReturn(TaskType.ACTIVE);
+        task = createStatelessTask(createConfig(AT_LEAST_ONCE, "100",
+            LogAndFailExceptionHandler.class.getName(), 
LogAndFailProcessingExceptionHandler.class.getName()));
+
+        final StreamsException streamsException = 
assertThrows(StreamsException.class,
+            () -> task.punctuate(processorStreamTime, 1, 
PunctuationType.STREAM_TIME, timestamp -> {
+                throw new KafkaException("KABOOM!");
+            }));
+
+        assertTrue(streamsException.getCause() instanceof KafkaException);
+        assertEquals("KABOOM!", streamsException.getCause().getMessage());
+    }
+
+    @Test
+    public void 
shouldThrowStreamsExceptionWhenProcessingExceptionHandlerThrowsAnException() {
+        when(stateManager.taskId()).thenReturn(taskId);
+        when(stateManager.taskType()).thenReturn(TaskType.ACTIVE);
+        task = createStatelessTask(createConfig(AT_LEAST_ONCE, "100",
+                LogAndFailExceptionHandler.class.getName(), 
ProcessingExceptionHandlerMock.class.getName()));
+
+        final StreamsException streamsException = 
assertThrows(StreamsException.class,
+            () -> task.punctuate(processorStreamTime, 1, 
PunctuationType.STREAM_TIME, timestamp -> {
+                throw new KafkaException("KABOOM!");
+            }));
+
+        final String msg = streamsException.getMessage();
+        assertTrue(msg.equals("Fatal user code error in processing error 
callback"));
+    }
+
+    public static class ProcessingExceptionHandlerMock implements 
ProcessingExceptionHandler {
+          @Override
+        public ProcessingExceptionHandler.ProcessingHandlerResponse 
handle(final ErrorHandlerContext context, final Record<?, ?> record, final 
Exception exception) {
+              throw new RuntimeException("KABOOM!");
+        }

Review Comment:
   done



-- 
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-unsubscr...@kafka.apache.org

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

Reply via email to