C0urante commented on code in PR #13165: URL: https://github.com/apache/kafka/pull/13165#discussion_r1204337446
########## connect/runtime/src/main/java/org/apache/kafka/connect/cli/AbstractConnectCli.java: ########## @@ -119,36 +120,37 @@ public Connect startConnect(Map<String, String> workerProps, String... extraArgs log.info("Scanning for plugin classes. This might take a moment ..."); Plugins plugins = new Plugins(workerProps); - plugins.compareAndSwapWithDelegatingLoader(); - T config = createConfig(workerProps); - log.debug("Kafka cluster ID: {}", config.kafkaClusterId()); + try (LoaderSwap loaderSwap = plugins.withClassLoader(plugins.delegatingLoader())) { Review Comment: I think it's brittle to change the context classloader back. Currently there's no additional logic that requires it, but we have a choice between adding the potential for bugs related to the context classloader and not adding it. I get that the approach on trunk requires special treatment for integration tests, but since that's already a solved problem, I'd prefer to keep things as they are, especially since it's preferable to keep the risk in the testing portions of the code base over the main parts. ########## connect/runtime/src/test/java/org/apache/kafka/connect/util/clusters/EmbeddedConnectCluster.java: ########## @@ -89,9 +88,6 @@ public class EmbeddedConnectCluster { private final String workerNamePrefix; private final AtomicInteger nextWorkerId = new AtomicInteger(0); private final EmbeddedConnectClusterAssertions assertions; - // we should keep the original class loader and set it back after connector stopped since the connector will change the class loader, - // and then, the Mockito will use the unexpected class loader to generate the wrong proxy instance, which makes mock failed - private final ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); Review Comment: (Discussed above) -- 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