Skip to content

Commit c3af206

Browse files
authored
MINOR: code cleanup (apache#20455)
- rewrite code to avoid @Suppress - remove unused code - fix test error message Reviewer: Lucas Brutschy <lbrutschy@confluent.io>
1 parent ea5b5fe commit c3af206

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/ClientTelemetryTest.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import java.time.Duration;
4747
import java.util.ArrayList;
4848
import java.util.Arrays;
49+
import java.util.Collection;
4950
import java.util.Collections;
5051
import java.util.HashMap;
5152
import java.util.List;
@@ -54,7 +55,6 @@
5455
import java.util.UUID;
5556
import java.util.concurrent.ExecutionException;
5657
import java.util.stream.Collectors;
57-
import java.util.stream.Stream;
5858

5959
import static java.util.Arrays.asList;
6060
import static org.apache.kafka.clients.admin.AdminClientConfig.METRIC_REPORTER_CLASSES_CONFIG;
@@ -123,13 +123,12 @@ public void testClientInstanceId(ClusterInstance clusterInstance) throws Interru
123123
}
124124
}
125125

126-
@SuppressWarnings("unchecked")
127126
@ClusterTest(types = {Type.CO_KRAFT, Type.KRAFT})
128127
public void testIntervalMsParser(ClusterInstance clusterInstance) {
129128
List<String> alterOpts = asList("--bootstrap-server", clusterInstance.bootstrapServers(),
130129
"--alter", "--entity-type", "client-metrics", "--entity-name", "test", "--add-config", "interval.ms=bbb");
131130
try (Admin client = clusterInstance.admin()) {
132-
ConfigCommand.ConfigCommandOptions addOpts = new ConfigCommand.ConfigCommandOptions(toArray(alterOpts));
131+
ConfigCommand.ConfigCommandOptions addOpts = new ConfigCommand.ConfigCommandOptions(toArray(Set.of(alterOpts)));
133132

134133
Throwable e = assertThrows(ExecutionException.class, () -> ConfigCommand.alterConfig(client, addOpts));
135134
assertTrue(e.getMessage().contains(InvalidConfigurationException.class.getSimpleName()));
@@ -153,16 +152,16 @@ public void testMetrics(ClusterInstance clusterInstance) {
153152
}
154153
}
155154

156-
@SuppressWarnings("unchecked")
157-
private static String[] toArray(List<String>... lists) {
158-
return Stream.of(lists).flatMap(List::stream).toArray(String[]::new);
155+
private static String[] toArray(Collection<List<String>> lists) {
156+
return lists.stream().flatMap(List::stream).toArray(String[]::new);
159157
}
160158

161159
/**
162160
* We should add a ClientTelemetry into plugins to test the clientInstanceId method Otherwise the
163161
* {@link org.apache.kafka.common.protocol.ApiKeys#GET_TELEMETRY_SUBSCRIPTIONS} command will not be supported
164162
* by the server
165163
**/
164+
@SuppressWarnings("unused")
166165
public static class GetIdClientTelemetry implements ClientTelemetry, MetricsReporter {
167166

168167

server-common/src/test/java/org/apache/kafka/server/util/CommandLineUtilsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public void testParseArgsWithMultipleDelimiters() {
8383

8484
assertEquals("=first", props.getProperty("first.property"), "Value of first property should be '=first'");
8585
assertEquals("second=", props.getProperty("second.property"), "Value of second property should be 'second='");
86-
assertEquals("thi=rd", props.getProperty("third.property"), "Value of second property should be 'thi=rd'");
86+
assertEquals("thi=rd", props.getProperty("third.property"), "Value of third property should be 'thi=rd'");
8787
}
8888

8989
Properties props = new Properties();

0 commit comments

Comments
 (0)