Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix internal topic handling in constructors #88

Merged
merged 2 commits into from
Oct 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,13 @@ public StrimziKafkaCluster(final int brokersNum,
final ToxiproxyContainer proxyContainer,
final boolean enableSharedNetwork) {
validateBrokerNum(brokersNum);
validateInternalTopicReplicationFactor(internalTopicReplicationFactor);
validateInternalTopicReplicationFactor(internalTopicReplicationFactor, brokersNum);

this.brokersNum = brokersNum;
this.network = enableSharedNetwork ? Network.SHARED : Network.newNetwork();
this.zookeeper = new StrimziZookeeperContainer()
.withNetwork(this.network);
this.internalTopicReplicationFactor = internalTopicReplicationFactor;

if (proxyContainer != null) {
proxyContainer.setNetwork(this.network);
Expand Down Expand Up @@ -140,7 +141,7 @@ private StrimziKafkaCluster(StrimziKafkaClusterBuilder builder) {
this.proxyContainer = builder.proxyContainer;

validateBrokerNum(this.brokersNum);
validateInternalTopicReplicationFactor(this.internalTopicReplicationFactor);
validateInternalTopicReplicationFactor(this.internalTopicReplicationFactor, this.brokersNum);

this.zookeeper = new StrimziZookeeperContainer()
.withNetwork(this.network);
Expand Down Expand Up @@ -191,8 +192,8 @@ private void validateBrokerNum(int brokersNum) {
}
}

private void validateInternalTopicReplicationFactor(int internalTopicReplicationFactor) {
if (internalTopicReplicationFactor <= 0 || internalTopicReplicationFactor > this.brokersNum) {
private void validateInternalTopicReplicationFactor(int internalTopicReplicationFactor, int brokersNum) {
if (internalTopicReplicationFactor <= 0 || internalTopicReplicationFactor > brokersNum) {
throw new IllegalArgumentException("internalTopicReplicationFactor '" + internalTopicReplicationFactor + "' must be less than brokersNum and greater than 0");
}
}
Expand Down
Loading