You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2020/05/05 17:53:36 UTC

[GitHub] [kafka] gharris1727 commented on a change in pull request #8618: KAFKA-9955: Prevent SinkTask::close from shadowing other exceptions

gharris1727 commented on a change in pull request #8618:
URL: https://github.com/apache/kafka/pull/8618#discussion_r420298081



##########
File path: connect/runtime/src/main/java/org/apache/kafka/connect/runtime/WorkerSinkTask.java
##########
@@ -193,13 +194,11 @@ public void transitionTo(TargetState state) {
     @Override
     public void execute() {
         initializeAndStart();
-        try {
+        // Make sure any uncommitted data has been committed and the task has
+        // a chance to clean up its state
+        try (QuietClosable ignored = this::closePartitions) {

Review comment:
       This PR is not changing any of the printing logic, and that's still handled by the caller, `WorkerTask::doRun`. This is roughly what a suppressed exception looks like when it gets logged (from the test setup, not a live connector):
   
   ```
   org.apache.kafka.connect.errors.ConnectException: Exiting WorkerSinkTask due to unrecoverable exception.
   	at org.apache.kafka.connect.runtime.WorkerSinkTask.deliverMessages(WorkerSinkTask.java:569)
   	at org.apache.kafka.connect.runtime.WorkerSinkTask.poll(WorkerSinkTask.java:327)
   	at org.apache.kafka.connect.runtime.WorkerSinkTask.iteration(WorkerSinkTask.java:229)
   	at org.apache.kafka.connect.runtime.WorkerSinkTask.execute(WorkerSinkTask.java:201)
   	<snipped>
   	Suppressed: java.lang.RuntimeException
   		at org.easymock.internal.MockInvocationHandler.invoke(MockInvocationHandler.java:46)
   		at org.easymock.internal.ObjectMethodsFilter.invoke(ObjectMethodsFilter.java:101)
   		at org.easymock.internal.ClassProxyFactory$MockMethodInterceptor.intercept(ClassProxyFactory.java:97)
   		at org.apache.kafka.connect.sink.SinkTask$$EnhancerByCGLIB$$713f645b.close(&lt;generated&gt;)
   		at org.apache.kafka.connect.runtime.WorkerSinkTask.commitOffsets(WorkerSinkTask.java:402)
   		at org.apache.kafka.connect.runtime.WorkerSinkTask.closePartitions(WorkerSinkTask.java:599)
   		at org.apache.kafka.connect.runtime.WorkerSinkTask.execute(WorkerSinkTask.java:202)
   		... 57 more
   Caused by: java.lang.RuntimeException
   	at org.easymock.internal.MockInvocationHandler.invoke(MockInvocationHandler.java:46)
   	at org.easymock.internal.ObjectMethodsFilter.invoke(ObjectMethodsFilter.java:101)
   	at org.easymock.internal.ClassProxyFactory$MockMethodInterceptor.intercept(ClassProxyFactory.java:68)
   	at org.apache.kafka.connect.sink.SinkTask$$EnhancerByCGLIB$$713f645b.put(&lt;generated&gt;)
   	at org.apache.kafka.connect.runtime.WorkerSinkTask.deliverMessages(WorkerSinkTask.java:547)
   	... 60 more
   ```
   Suppressed exceptions are a native Java feature, and log4j supports printing their stacktraces.




----------------------------------------------------------------
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.

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