Skip to content

Commit

Permalink
Workaround to KafkaEmbedded memory leaks using Kafka Connect.
Browse files Browse the repository at this point in the history
  • Loading branch information
valdar committed Jun 15, 2020
1 parent fea1abb commit b9c63c9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Expand Up @@ -25,6 +25,7 @@
import org.apache.camel.kafkaconnector.common.PluginPathHelper;
import org.apache.kafka.connect.runtime.WorkerConfig;
import org.apache.kafka.connect.util.clusters.EmbeddedConnectCluster;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -95,6 +96,15 @@ public void shutdown() {
}
}

@Override
public void beforeTestExecution(ExtensionContext extensionContext) throws Exception {
initialize();
}

@Override
public void afterTestExecution(ExtensionContext context) throws Exception {
shutdown();
}

// WARNING: this may come uninitialized
public EmbeddedConnectCluster getCluster() {
Expand Down
Expand Up @@ -18,13 +18,15 @@
package org.apache.camel.kafkaconnector.common.services.kafka;

import org.junit.jupiter.api.extension.AfterAllCallback;
import org.junit.jupiter.api.extension.AfterTestExecutionCallback;
import org.junit.jupiter.api.extension.BeforeAllCallback;
import org.junit.jupiter.api.extension.BeforeTestExecutionCallback;
import org.junit.jupiter.api.extension.ExtensionContext;

/**
* Provides an interface for any type of Kafka service: remote instances, local container, etc
*/
public interface KafkaService extends BeforeAllCallback, AfterAllCallback {
public interface KafkaService extends BeforeAllCallback, BeforeTestExecutionCallback, AfterAllCallback, AfterTestExecutionCallback {


/**
Expand All @@ -44,7 +46,6 @@ public interface KafkaService extends BeforeAllCallback, AfterAllCallback {
*/
void shutdown();


@Override
default void beforeAll(ExtensionContext extensionContext) throws Exception {
initialize();
Expand Down

0 comments on commit b9c63c9

Please sign in to comment.