kamalcph commented on a change in pull request #10605: URL: https://github.com/apache/kafka/pull/10605#discussion_r622746344
########## File path: connect/runtime/src/main/java/org/apache/kafka/connect/runtime/Worker.java ########## @@ -839,7 +840,22 @@ private void stopTask(ConnectorTaskId taskId) { ClassLoader savedLoader = plugins.currentThreadLoader(); try { savedLoader = Plugins.compareAndSwapLoaders(task.loader()); - task.stop(); + CountDownLatch latch = new CountDownLatch(1); + new Thread() { + @Override + public void run() { + task.stop(); + latch.countDown(); + } + }.start(); + // Wait for thread to terminate, but not longer than timeout. + if (timeout <= 0) { Review comment: nit: This if statement is not required. The countdown latch won't wait at all if the timeout is <= 0. -- 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: us...@infra.apache.org