Skip to content

Commit 6a00539

Browse files
authored
Remove implicit network in KafkaContainer (#2932)
1 parent f4400a0 commit 6a00539

File tree

2 files changed

+0
-45
lines changed

2 files changed

+0
-45
lines changed

modules/kafka/src/main/java/org/testcontainers/containers/KafkaContainer.java

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,13 @@ public class KafkaContainer extends GenericContainer<KafkaContainer> {
2929

3030
private int port = PORT_NOT_ASSIGNED;
3131

32-
private boolean useImplicitNetwork = true;
33-
3432
public KafkaContainer() {
3533
this("5.2.1");
3634
}
3735

3836
public KafkaContainer(String confluentPlatformVersion) {
3937
super(TestcontainersConfiguration.getInstance().getKafkaImage() + ":" + confluentPlatformVersion);
4038

41-
super.withNetwork(Network.SHARED);
4239
withExposedPorts(KAFKA_PORT);
4340

4441
// Use two listeners with different names, it will force Kafka to communicate with itself via internal
@@ -54,26 +51,6 @@ public KafkaContainer(String confluentPlatformVersion) {
5451
withEnv("KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS", "0");
5552
}
5653

57-
@Override
58-
public KafkaContainer withNetwork(Network network) {
59-
useImplicitNetwork = false;
60-
return super.withNetwork(network);
61-
}
62-
63-
@Override
64-
public Network getNetwork() {
65-
if (useImplicitNetwork) {
66-
// TODO Only for backward compatibility, to be removed soon
67-
logger().warn(
68-
"Deprecation warning! " +
69-
"KafkaContainer#getNetwork without an explicitly set network. " +
70-
"Consider using KafkaContainer#withNetwork",
71-
new Exception("Deprecated method")
72-
);
73-
}
74-
return super.getNetwork();
75-
}
76-
7754
public KafkaContainer withEmbeddedZookeeper() {
7855
externalZookeeperConnect = null;
7956
return self();

modules/kafka/src/test/java/org/testcontainers/containers/KafkaContainerTest.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,6 @@ public void testUsage() throws Exception {
3131
}
3232
}
3333

34-
/**
35-
* @deprecated the {@link Network} should be set explicitly with {@link KafkaContainer#withNetwork(Network)}.
36-
*/
37-
@Test
38-
@Deprecated
39-
public void testExternalZookeeperWithKafkaNetwork() throws Exception {
40-
try (
41-
KafkaContainer kafka = new KafkaContainer()
42-
.withExternalZookeeper("zookeeper:2181");
43-
44-
GenericContainer zookeeper = new GenericContainer("confluentinc/cp-zookeeper:4.0.0")
45-
.withNetwork(kafka.getNetwork())
46-
.withNetworkAliases("zookeeper")
47-
.withEnv("ZOOKEEPER_CLIENT_PORT", "2181");
48-
) {
49-
zookeeper.start();
50-
kafka.start();
51-
52-
testKafkaFunctionality(kafka.getBootstrapServers());
53-
}
54-
}
55-
5634
@Test
5735
public void testExternalZookeeperWithExternalNetwork() throws Exception {
5836
try (

0 commit comments

Comments
 (0)