Skip to content
4 changes: 3 additions & 1 deletion checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@
<module name="EqualsHashCode"/>
<module name="SimplifyBooleanExpression"/>
<module name="OneStatementPerLine"/>
<module name="UnnecessaryParentheses" />
<module name="UnnecessaryParentheses">
<property name="tokens" value="IDENT, NUM_DOUBLE, LAMBDA, TEXT_BLOCK_LITERAL_BEGIN, UNARY_MINUS, UNARY_PLUS, INC, DEC, POST_INC, POST_DEC" />
</module>
<module name="SimplifyBooleanReturn"/>

<!-- style -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4822,12 +4822,12 @@ AddRaftVoterRequest.Builder createRequest(int timeoutMs) {
setHost(endpoint.host()).
setPort(endpoint.port())));
return new AddRaftVoterRequest.Builder(
new AddRaftVoterRequestData().
setClusterId(options.clusterId().orElse(null)).
setTimeoutMs(timeoutMs).
setVoterId(voterId) .
setVoterDirectoryId(voterDirectoryId).
setListeners(listeners));
new AddRaftVoterRequestData().
setClusterId(options.clusterId().orElse(null)).
setTimeoutMs(timeoutMs).
setVoterId(voterId) .
setVoterDirectoryId(voterDirectoryId).
setListeners(listeners));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public final class OffsetsForLeaderEpochUtils {

private static final Logger LOG = LoggerFactory.getLogger(OffsetsForLeaderEpochUtils.class);

private OffsetsForLeaderEpochUtils(){}
private OffsetsForLeaderEpochUtils() {}

static AbstractRequest.Builder<OffsetsForLeaderEpochRequest> prepareRequest(
Map<TopicPartition, SubscriptionState.FetchPosition> requestData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,14 @@ op, new ResourcePattern(resourceType, "hardcode", PatternType.LITERAL),

EnumMap<PatternType, Set<String>> denyPatterns =
new EnumMap<>(PatternType.class) {{
put(PatternType.LITERAL, new HashSet<>());
put(PatternType.PREFIXED, new HashSet<>());
}};
put(PatternType.LITERAL, new HashSet<>());
put(PatternType.PREFIXED, new HashSet<>());
}};
EnumMap<PatternType, Set<String>> allowPatterns =
new EnumMap<>(PatternType.class) {{
put(PatternType.LITERAL, new HashSet<>());
put(PatternType.PREFIXED, new HashSet<>());
}};
put(PatternType.LITERAL, new HashSet<>());
put(PatternType.PREFIXED, new HashSet<>());
}};

boolean hasWildCardAllow = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2061,9 +2061,9 @@ public void testDescribeBrokerAndLogConfigs() throws Exception {
new DescribeConfigsResponseData().setResults(asList(new DescribeConfigsResponseData.DescribeConfigsResult()
.setResourceName(brokerResource.name()).setResourceType(brokerResource.type().id()).setErrorCode(Errors.NONE.code())
.setConfigs(emptyList()),
new DescribeConfigsResponseData.DescribeConfigsResult()
.setResourceName(brokerLoggerResource.name()).setResourceType(brokerLoggerResource.type().id()).setErrorCode(Errors.NONE.code())
.setConfigs(emptyList())))), env.cluster().nodeById(0));
new DescribeConfigsResponseData.DescribeConfigsResult()
.setResourceName(brokerLoggerResource.name()).setResourceType(brokerLoggerResource.type().id()).setErrorCode(Errors.NONE.code())
.setConfigs(emptyList())))), env.cluster().nodeById(0));
Map<ConfigResource, KafkaFuture<Config>> result = env.adminClient().describeConfigs(asList(
brokerResource,
brokerLoggerResource)).values();
Expand Down Expand Up @@ -2102,9 +2102,9 @@ public void testDescribeConfigsUnrequested() throws Exception {
new DescribeConfigsResponseData().setResults(asList(new DescribeConfigsResponseData.DescribeConfigsResult()
.setResourceName(topic.name()).setResourceType(topic.type().id()).setErrorCode(Errors.NONE.code())
.setConfigs(emptyList()),
new DescribeConfigsResponseData.DescribeConfigsResult()
.setResourceName(unrequested.name()).setResourceType(unrequested.type().id()).setErrorCode(Errors.NONE.code())
.setConfigs(emptyList())))));
new DescribeConfigsResponseData.DescribeConfigsResult()
.setResourceName(unrequested.name()).setResourceType(unrequested.type().id()).setErrorCode(Errors.NONE.code())
.setConfigs(emptyList())))));
Map<ConfigResource, KafkaFuture<Config>> result = env.adminClient().describeConfigs(singletonList(
topic)).values();
assertEquals(new HashSet<>(singletonList(topic)), result.keySet());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,11 @@ public void testSuccessfulHandleResponseWithOnePartitionErrorWithMultipleGroups(
Map<TopicPartition, OffsetAndMetadata> offsetAndMetadataMapTwo =
Collections.singletonMap(t2p2, new OffsetAndMetadata(10L));
Map<String, Map<TopicPartition, OffsetAndMetadata>> expectedResult =
new HashMap<String, Map<TopicPartition, OffsetAndMetadata>>() {{
put(groupZero, offsetAndMetadataMapZero);
put(groupOne, offsetAndMetadataMapOne);
put(groupTwo, offsetAndMetadataMapTwo);
}};
new HashMap<>() {{
put(groupZero, offsetAndMetadataMapZero);
put(groupOne, offsetAndMetadataMapOne);
put(groupTwo, offsetAndMetadataMapTwo);
}};

assertCompletedForMultipleGroups(
handleWithPartitionErrorMultipleGroups(Errors.UNKNOWN_TOPIC_OR_PARTITION), expectedResult);
Expand Down Expand Up @@ -304,11 +304,11 @@ private OffsetFetchResponse buildResponseWithPartitionErrorWithMultipleGroups(Er
responseDataTwo.put(t2p2, new OffsetFetchResponse.PartitionData(10, Optional.empty(), "", Errors.NONE));

Map<String, Map<TopicPartition, PartitionData>> responseData =
new HashMap<String, Map<TopicPartition, PartitionData>>() {{
put(groupZero, responseDataZero);
put(groupOne, responseDataOne);
put(groupTwo, responseDataTwo);
}};
new HashMap<>() {{
put(groupZero, responseDataZero);
put(groupOne, responseDataOne);
put(groupTwo, responseDataTwo);
}};

Map<String, Errors> errorMap = errorMap(groups, Errors.NONE);
return new OffsetFetchResponse(0, errorMap, responseData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@ public void serializeDeserializeConsumerProtocolSubscriptionAllVersions() {
if (version >= 1) {
assertEquals(
Set.of(
new ConsumerProtocolSubscription.TopicPartition().setTopic("foo").setPartitions(Collections.singletonList(0)),
new ConsumerProtocolSubscription.TopicPartition().setTopic("bar").setPartitions(Collections.singletonList(0)
new ConsumerProtocolSubscription.TopicPartition().setTopic("foo").setPartitions(Collections.singletonList(0)),
new ConsumerProtocolSubscription.TopicPartition().setTopic("bar").setPartitions(Collections.singletonList(0)
)),
Set.copyOf(parsedSubscription.ownedPartitions())
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1815,10 +1815,10 @@ public void testMultipleAddPartitionsPerForOneProduce() throws InterruptedExcept

@ParameterizedTest
@EnumSource(names = {
"UNKNOWN_TOPIC_OR_PARTITION",
"REQUEST_TIMED_OUT",
"COORDINATOR_LOAD_IN_PROGRESS",
"CONCURRENT_TRANSACTIONS"
"UNKNOWN_TOPIC_OR_PARTITION",
"REQUEST_TIMED_OUT",
"COORDINATOR_LOAD_IN_PROGRESS",
"CONCURRENT_TRANSACTIONS"
})
public void testRetriableErrors(Errors error) {
// Ensure FindCoordinator retries.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -907,8 +907,8 @@ public void testLowestPriorityChannel() throws Exception {
}
assertNotNull(selector.lowestPriorityChannel());
for (int i = conns - 1; i >= 0; i--) {
if (i != 2)
assertEquals("", blockingRequest(String.valueOf(i), ""));
if (i != 2)
assertEquals("", blockingRequest(String.valueOf(i), ""));
time.sleep(10);
}
assertEquals("2", selector.lowestPriorityChannel().id());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,16 +390,16 @@ public void testUseDefaultLeaderEpochV0ToV7() {
.setErrorCode(Errors.NOT_COORDINATOR.code())
.setThrottleTimeMs(throttleTimeMs)
.setTopics(Collections.singletonList(
new OffsetFetchResponseTopic()
.setName(topicOne)
.setPartitions(Collections.singletonList(
new OffsetFetchResponsePartition()
.setPartitionIndex(partitionOne)
.setCommittedOffset(offset)
.setCommittedLeaderEpoch(RecordBatch.NO_PARTITION_LEADER_EPOCH)
.setErrorCode(Errors.UNKNOWN_TOPIC_OR_PARTITION.code())
.setMetadata(metadata))
))
new OffsetFetchResponseTopic()
.setName(topicOne)
.setPartitions(Collections.singletonList(
new OffsetFetchResponsePartition()
.setPartitionIndex(partitionOne)
.setCommittedOffset(offset)
.setCommittedLeaderEpoch(RecordBatch.NO_PARTITION_LEADER_EPOCH)
.setErrorCode(Errors.UNKNOWN_TOPIC_OR_PARTITION.code())
.setMetadata(metadata))
))
);
assertEquals(expectedData, response.data());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2187,9 +2187,9 @@ private JoinGroupRequest createJoinGroupRequest(short version) {
JoinGroupRequestData.JoinGroupRequestProtocolCollection protocols =
new JoinGroupRequestData.JoinGroupRequestProtocolCollection(
Collections.singleton(
new JoinGroupRequestData.JoinGroupRequestProtocol()
.setName("consumer-range")
.setMetadata(new byte[0])).iterator()
new JoinGroupRequestData.JoinGroupRequestProtocol()
.setName("consumer-range")
.setMetadata(new byte[0])).iterator()
);

JoinGroupRequestData data = new JoinGroupRequestData()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,10 @@ public void testAclFiltering() {
new DefaultReplicationPolicy(), x -> true, getConfigPropertyFilter());
assertFalse(connector.shouldReplicateAcl(
new AclBinding(new ResourcePattern(ResourceType.TOPIC, "test_topic", PatternType.LITERAL),
new AccessControlEntry("kafka", "", AclOperation.WRITE, AclPermissionType.ALLOW))), "should not replicate ALLOW WRITE");
new AccessControlEntry("kafka", "", AclOperation.WRITE, AclPermissionType.ALLOW))), "should not replicate ALLOW WRITE");
assertTrue(connector.shouldReplicateAcl(
new AclBinding(new ResourcePattern(ResourceType.TOPIC, "test_topic", PatternType.LITERAL),
new AccessControlEntry("kafka", "", AclOperation.ALL, AclPermissionType.ALLOW))), "should replicate ALLOW ALL");
new AccessControlEntry("kafka", "", AclOperation.ALL, AclPermissionType.ALLOW))), "should replicate ALLOW ALL");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,7 @@ protected void addConfigKey(Map<String, ConfigDef.ConfigKey> keys, String name,
keys.putAll(configDef.configKeys());
}

protected void addValue(List<ConfigValue> values, String name, String value, String...errors) {
protected void addValue(List<ConfigValue> values, String name, String value, String... errors) {
values.add(new ConfigValue(name, value, new ArrayList<>(), Arrays.asList(errors)));
}

Expand All @@ -1211,7 +1211,7 @@ protected void assertNoInfoKey(ConfigInfos infos, String name) {
assertNull(info.configKey());
}

protected void assertInfoValue(ConfigInfos infos, String name, String value, String...errors) {
protected void assertInfoValue(ConfigInfos infos, String name, String value, String... errors) {
ConfigValueInfo info = findInfo(infos, name).configValue();
assertEquals(name, info.name());
assertEquals(value, info.value());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ public class HasHeaderKey<R extends ConnectRecord<R>> implements Predicate<R>, V
private static final String NAME_CONFIG = "name";
public static final String OVERVIEW_DOC = "A predicate which is true for records with at least one header with the configured name.";
public static final ConfigDef CONFIG_DEF = new ConfigDef()
.define(NAME_CONFIG, ConfigDef.Type.STRING, ConfigDef.NO_DEFAULT_VALUE,
new ConfigDef.NonEmptyString(), ConfigDef.Importance.MEDIUM,
"The header name.");
.define(NAME_CONFIG, ConfigDef.Type.STRING, ConfigDef.NO_DEFAULT_VALUE,
new ConfigDef.NonEmptyString(), ConfigDef.Importance.MEDIUM, "The header name.");
private String name;

@Override
Expand Down
10 changes: 5 additions & 5 deletions core/src/test/java/kafka/admin/AdminFenceProducersTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@
import static org.junit.jupiter.api.Assertions.assertTrue;

@ClusterTestDefaults(serverProperties = {
@ClusterConfigProperty(key = ServerLogConfigs.AUTO_CREATE_TOPICS_ENABLE_CONFIG, value = "false"),
@ClusterConfigProperty(key = TransactionLogConfig.TRANSACTIONS_TOPIC_PARTITIONS_CONFIG, value = "1"),
@ClusterConfigProperty(key = TransactionLogConfig.TRANSACTIONS_TOPIC_REPLICATION_FACTOR_CONFIG, value = "1"),
@ClusterConfigProperty(key = TransactionLogConfig.TRANSACTIONS_TOPIC_MIN_ISR_CONFIG, value = "1"),
@ClusterConfigProperty(key = TransactionStateManagerConfig.TRANSACTIONS_ABORT_TIMED_OUT_TRANSACTION_CLEANUP_INTERVAL_MS_CONFIG, value = "2000")
@ClusterConfigProperty(key = ServerLogConfigs.AUTO_CREATE_TOPICS_ENABLE_CONFIG, value = "false"),
@ClusterConfigProperty(key = TransactionLogConfig.TRANSACTIONS_TOPIC_PARTITIONS_CONFIG, value = "1"),
@ClusterConfigProperty(key = TransactionLogConfig.TRANSACTIONS_TOPIC_REPLICATION_FACTOR_CONFIG, value = "1"),
@ClusterConfigProperty(key = TransactionLogConfig.TRANSACTIONS_TOPIC_MIN_ISR_CONFIG, value = "1"),
@ClusterConfigProperty(key = TransactionStateManagerConfig.TRANSACTIONS_ABORT_TIMED_OUT_TRANSACTION_CLEANUP_INTERVAL_MS_CONFIG, value = "2000")
})
@ExtendWith(ClusterTestExtensions.class)
public class AdminFenceProducersTest {
Expand Down
2 changes: 1 addition & 1 deletion core/src/test/java/kafka/admin/ClientTelemetryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public class ClientTelemetryTest {
types = Type.KRAFT,
brokers = 3,
serverProperties = {
@ClusterConfigProperty(key = METRIC_REPORTER_CLASSES_CONFIG, value = "kafka.admin.ClientTelemetryTest$GetIdClientTelemetry"),
@ClusterConfigProperty(key = METRIC_REPORTER_CLASSES_CONFIG, value = "kafka.admin.ClientTelemetryTest$GetIdClientTelemetry"),
})
public void testClientInstanceId(ClusterInstance clusterInstance) throws InterruptedException, ExecutionException {
Map<String, Object> configs = new HashMap<>();
Expand Down
4 changes: 2 additions & 2 deletions core/src/test/java/kafka/admin/ConfigCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ public void testParseConfigsToBeAddedForAddConfigFile() throws IOException {
assertEquals("[[1, 2], [3, 4]]", addedProps.getProperty("nested"));
}

public void testExpectedEntityTypeNames(List<String> expectedTypes, List<String> expectedNames, List<String> connectOpts, String...args) {
public void testExpectedEntityTypeNames(List<String> expectedTypes, List<String> expectedNames, List<String> connectOpts, String... args) {
ConfigCommand.ConfigCommandOptions createOpts = new ConfigCommand.ConfigCommandOptions(toArray(Arrays.asList(connectOpts.get(0), connectOpts.get(1), "--describe"), Arrays.asList(args)));
createOpts.checkArgs();
assertEquals(createOpts.entityTypes().toSeq(), seq(expectedTypes));
Expand Down Expand Up @@ -1434,7 +1434,7 @@ public static List<String> concat(List<String>... lists) {
}

@SafeVarargs
public static <K, V> Map<K, V> concat(Map<K, V>...maps) {
public static <K, V> Map<K, V> concat(Map<K, V>... maps) {
Map<K, V> res = new HashMap<>();
Stream.of(maps)
.map(Map::entrySet)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ public ConfigCommandResult(String stdout, OptionalInt exitStatus) {
}
}

private ConfigCommandResult runConfigCommandViaBroker(String...args) {
private ConfigCommandResult runConfigCommandViaBroker(String... args) {
AtomicReference<OptionalInt> exitStatus = new AtomicReference<>(OptionalInt.empty());
Exit.setExitProcedure((status, __) -> {
exitStatus.set(OptionalInt.of((Integer) status));
exitStatus.set(OptionalInt.of(status));
throw new RuntimeException();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,16 +311,16 @@ private static List<List<Integer>> translatePartitionInfoToNodeIdList(List<Topic
}

@ClusterTest(serverProperties = {
@ClusterConfigProperty(key = StandardAuthorizer.SUPER_USERS_CONFIG, value = "User:ANONYMOUS"),
@ClusterConfigProperty(key = AUTHORIZER_CLASS_NAME_CONFIG, value = "org.apache.kafka.metadata.authorizer.StandardAuthorizer")
@ClusterConfigProperty(key = StandardAuthorizer.SUPER_USERS_CONFIG, value = "User:ANONYMOUS"),
@ClusterConfigProperty(key = AUTHORIZER_CLASS_NAME_CONFIG, value = "org.apache.kafka.metadata.authorizer.StandardAuthorizer")
})
public void testAclsByControllers(ClusterInstance clusterInstance) throws Exception {
testAcls(clusterInstance, true);
}

@ClusterTest(serverProperties = {
@ClusterConfigProperty(key = StandardAuthorizer.SUPER_USERS_CONFIG, value = "User:ANONYMOUS"),
@ClusterConfigProperty(key = AUTHORIZER_CLASS_NAME_CONFIG, value = "org.apache.kafka.metadata.authorizer.StandardAuthorizer")
@ClusterConfigProperty(key = StandardAuthorizer.SUPER_USERS_CONFIG, value = "User:ANONYMOUS"),
@ClusterConfigProperty(key = AUTHORIZER_CLASS_NAME_CONFIG, value = "org.apache.kafka.metadata.authorizer.StandardAuthorizer")
})
public void testAcls(ClusterInstance clusterInstance) throws Exception {
testAcls(clusterInstance, false);
Expand Down
5 changes: 1 addition & 4 deletions gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ versions += [
// but currently, tests are failing in >=3.1.2. Therefore, we are temporarily using version 3.1.1.
// The failing tests should be fixed under KAFKA-18089, allowing us to upgrade to >=3.1.2.
caffeine: "3.1.1",
// when updating checkstyle, check whether the exclusion of
// CVE-2023-2976 and CVE-2020-8908 can be dropped from
// gradle/resources/dependencycheck-suppressions.xml
checkstyle: project.hasProperty('checkstyleVersion') ? checkstyleVersion : "8.36.2",
checkstyle: project.hasProperty('checkstyleVersion') ? checkstyleVersion : "10.20.2",
commonsCli: "1.4",
commonsIo: "2.14.0", // ZooKeeper dependency. Do not use, this is going away.
commonsValidator: "1.9.0",
Expand Down
11 changes: 0 additions & 11 deletions gradle/resources/dependencycheck-suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,6 @@
]]></notes>
<cve>CVE-2023-35116</cve>
</suppress>
<suppress>
<notes><![CDATA[
This older version of Guava is only included in checkstyle.
CVE-2023-2976 and CVE-2020-8908 are irrelevant for checkstyle,
as it is not executed with elevated privileges.
This suppression will no longer be needed when checkstyle
is updated to 10.5.0 or later.
]]></notes>
<cve>CVE-2020-8908</cve>
<cve>CVE-2023-2976</cve>
</suppress>
<suppress>
<notes><![CDATA[
Kafka does not use CgiServlet
Expand Down
Loading