cadonna commented on code in PR #16300:
URL: https://github.com/apache/kafka/pull/16300#discussion_r1689927771
##########
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:
There is a checkstyle issue. This should solve the issue.
```suggestion
public ProcessingExceptionHandler.ProcessingHandlerResponse
handle(final ErrorHandlerContext context, final Record<?, ?> record, final
Exception exception) {
throw new RuntimeException("KABOOM!");
}
```
You can verify checkstyle issues locally with:
```
./gradlew streams:checkstyleMain streams:checkstyleTest streams:spotbugsMain
streams:spotbugsTest
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]