Skip to content

Commit

Permalink
Rename the variable to reflect its purpose (#18525)
Browse files Browse the repository at this point in the history
Reviewers: Andrew Schofield <[email protected]>
  • Loading branch information
pramithas authored Jan 14, 2025
1 parent 00b22b0 commit ea77352
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -421,45 +421,45 @@ public void testInflightRequestsAndIdempotenceForIdempotentProducers() {
config.getInt(ProducerConfig.MAX_IN_FLIGHT_REQUESTS_PER_CONNECTION),
"max.in.flight.requests.per.connection should be overwritten");

Properties validProps2 = new Properties() {{
Properties invalidProps1 = new Properties() {{
putAll(baseProps);
setProperty(ProducerConfig.MAX_IN_FLIGHT_REQUESTS_PER_CONNECTION, "6");
}};

ConfigException configException = assertThrows(ConfigException.class, () -> new ProducerConfig(validProps2));
ConfigException configException = assertThrows(ConfigException.class, () -> new ProducerConfig(invalidProps1));
assertEquals("To use the idempotent producer, " + ProducerConfig.MAX_IN_FLIGHT_REQUESTS_PER_CONNECTION +
" must be set to at most 5. Current value is 6.", configException.getMessage());

Properties invalidProps = new Properties() {{
Properties invalidProps2 = new Properties() {{
putAll(baseProps);
setProperty(ProducerConfig.MAX_IN_FLIGHT_REQUESTS_PER_CONNECTION, "5");
setProperty(ProducerConfig.ENABLE_IDEMPOTENCE_CONFIG, "false");
setProperty(ProducerConfig.TRANSACTIONAL_ID_CONFIG, "transactionalId");
}};
assertThrows(
ConfigException.class,
() -> new ProducerConfig(invalidProps),
() -> new ProducerConfig(invalidProps2),
"Cannot set a transactional.id without also enabling idempotence");

Properties invalidProps2 = new Properties() {{
Properties invalidProps3 = new Properties() {{
putAll(baseProps);
setProperty(ProducerConfig.MAX_IN_FLIGHT_REQUESTS_PER_CONNECTION, "6");
// explicitly enabling idempotence should still throw exception
setProperty(ProducerConfig.ENABLE_IDEMPOTENCE_CONFIG, "true");
}};
assertThrows(
ConfigException.class,
() -> new ProducerConfig(invalidProps2),
() -> new ProducerConfig(invalidProps3),
"Must set max.in.flight.requests.per.connection to at most 5 when using the idempotent producer.");

Properties invalidProps3 = new Properties() {{
Properties invalidProps4 = new Properties() {{
putAll(baseProps);
setProperty(ProducerConfig.MAX_IN_FLIGHT_REQUESTS_PER_CONNECTION, "6");
setProperty(ProducerConfig.TRANSACTIONAL_ID_CONFIG, "transactionalId");
}};
assertThrows(
ConfigException.class,
() -> new ProducerConfig(invalidProps3),
() -> new ProducerConfig(invalidProps4),
"Must set retries to non-zero when using the idempotent producer.");
}

Expand Down

0 comments on commit ea77352

Please sign in to comment.