Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7118285

Browse files
authored
Fix ErrorProne BadImport warnings (#3643)
* fix: use qualified class names to resolve BadImport warnings Signed-off-by: dahyvuun <[email protected]> * fix: use qualified RoutingHttpServer.builder() to satisfy BadImport Signed-off-by: dahyvuun <[email protected]> * fix: replace static imports of EnumSet methods with qualified names Signed-off-by: dahyvuun <[email protected]> * fix: replace BadImport static imports with qualified KroxyliciousTesters references Signed-off-by: dahyvuun <[email protected]> * Remove accidentally committed wq file Signed-off-by: dahyvuun <[email protected]> --------- Signed-off-by: dahyvuun <[email protected]>
1 parent 9469ab3 commit 7118285

8 files changed

Lines changed: 26 additions & 32 deletions

File tree

kroxylicious-app/src/test/java/io/kroxylicious/app/KroxyliciousIT.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@
3434
import io.kroxylicious.proxy.config.Configuration;
3535
import io.kroxylicious.proxy.internal.config.Feature;
3636
import io.kroxylicious.proxy.internal.config.Features;
37+
import io.kroxylicious.testing.integration.tester.KroxyliciousTesters;
3738
import io.kroxylicious.testing.kafka.api.KafkaCluster;
3839
import io.kroxylicious.testing.kafka.junit5ext.KafkaClusterExtension;
3940

4041
import static io.kroxylicious.testing.integration.tester.KroxyliciousConfigUtils.proxy;
4142
import static io.kroxylicious.testing.integration.tester.KroxyliciousTesters.kroxyliciousTester;
42-
import static io.kroxylicious.testing.integration.tester.KroxyliciousTesters.newBuilder;
4343
import static org.assertj.core.api.Assertions.assertThat;
4444
import static org.junit.jupiter.api.Assertions.assertEquals;
4545

@@ -89,7 +89,7 @@ void shouldStartWithTestConfigurationsFeatureEnabledByEnvironmentVariable(KafkaC
8989
new NewTopic(TOPIC_1, 1, (short) 1),
9090
new NewTopic(TOPIC_2, 1, (short) 1))).all().get();
9191

92-
try (var tester = newBuilder(proxy(cluster).withDevelopment(Map.of("a", "b")))
92+
try (var tester = KroxyliciousTesters.newBuilder(proxy(cluster).withDevelopment(Map.of("a", "b")))
9393
.setKroxyliciousFactory(new SubprocessKroxyliciousFactory(tempDir))
9494
.setFeatures(Features.builder().enable(Feature.TEST_ONLY_CONFIGURATION).build())
9595
.createDefaultKroxyliciousTester();
@@ -107,7 +107,7 @@ void shouldStartWithTestConfigurationsFeatureEnabledBySystemProperty(KafkaCluste
107107
new NewTopic(TOPIC_1, 1, (short) 1),
108108
new NewTopic(TOPIC_2, 1, (short) 1))).all().get();
109109

110-
try (var tester = newBuilder(proxy(cluster).withDevelopment(Map.of("a", "b")))
110+
try (var tester = KroxyliciousTesters.newBuilder(proxy(cluster).withDevelopment(Map.of("a", "b")))
111111
.setKroxyliciousFactory(new SubprocessKroxyliciousFactory(tempDir, (features, processBuilder) -> processBuilder.inheritIO(),
112112
List.of("-D" + prefixUnlockPropertyName(Feature.TEST_ONLY_CONFIGURATION) + "=true")))
113113
.createDefaultKroxyliciousTester();

kroxylicious-filters/kroxylicious-authorization/src/test/java/io/kroxylicious/filter/authorization/AuthorizationFilterTest.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@
5151

5252
import nl.altindag.log.LogCaptor;
5353

54-
import static java.util.EnumSet.complementOf;
55-
import static java.util.EnumSet.copyOf;
56-
import static java.util.EnumSet.of;
5754
import static org.assertj.core.api.Assertions.assertThat;
5855
import static org.assertj.core.api.Assertions.fail;
5956
import static org.mockito.Mockito.when;
@@ -299,7 +296,7 @@ private static String toYaml(Object actualBody) {
299296

300297
@Test
301298
void shouldSupportApis() {
302-
EnumSet<ApiKeys> allVersionsSupported = of(ApiKeys.API_VERSIONS,
299+
EnumSet<ApiKeys> allVersionsSupported = EnumSet.of(ApiKeys.API_VERSIONS,
303300
ApiKeys.PRODUCE,
304301
ApiKeys.SASL_HANDSHAKE,
305302
ApiKeys.SASL_AUTHENTICATE,
@@ -333,10 +330,10 @@ void shouldSupportApis() {
333330
ApiKeys.DESCRIBE_TRANSACTIONS,
334331
ApiKeys.HEARTBEAT,
335332
ApiKeys.LIST_TRANSACTIONS);
336-
EnumSet<ApiKeys> someVersionsSupported = of(ApiKeys.ADD_PARTITIONS_TO_TXN,
333+
EnumSet<ApiKeys> someVersionsSupported = EnumSet.of(ApiKeys.ADD_PARTITIONS_TO_TXN,
337334
ApiKeys.CONSUMER_GROUP_HEARTBEAT,
338335
ApiKeys.INIT_PRODUCER_ID);
339-
EnumSet<ApiKeys> noVersionsSupported = complementOf(unionOf(allVersionsSupported, someVersionsSupported));
336+
EnumSet<ApiKeys> noVersionsSupported = EnumSet.complementOf(unionOf(allVersionsSupported, someVersionsSupported));
340337
for (ApiKeys apiKey : allVersionsSupported) {
341338

342339
assertThat(AuthorizationFilter.isApiSupported(apiKey))
@@ -376,7 +373,7 @@ void shouldSupportApis() {
376373
}
377374

378375
private static EnumSet<ApiKeys> unionOf(EnumSet<ApiKeys> allVersionsSupported, EnumSet<ApiKeys> someVersionsSupported) {
379-
var t = copyOf(allVersionsSupported);
376+
var t = EnumSet.copyOf(allVersionsSupported);
380377
t.addAll(someVersionsSupported);
381378
return t;
382379
}

kroxylicious-integration-tests/src/test/java/io/kroxylicious/it/ApiVersionsDowngradeIT.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import io.kroxylicious.testing.integration.codec.ByteBufAccessorImpl;
4646
import io.kroxylicious.testing.integration.codec.OpaqueRequestFrame;
4747
import io.kroxylicious.testing.integration.tester.KroxyliciousConfigUtils;
48+
import io.kroxylicious.testing.integration.tester.KroxyliciousTesters;
4849
import io.kroxylicious.testing.kafka.api.KafkaCluster;
4950
import io.kroxylicious.testing.kafka.clients.CloseableAdmin;
5051
import io.kroxylicious.testing.kafka.common.SaslMechanism;
@@ -54,7 +55,6 @@
5455

5556
import static io.kroxylicious.testing.integration.tester.KroxyliciousConfigUtils.proxy;
5657
import static io.kroxylicious.testing.integration.tester.KroxyliciousTesters.mockKafkaKroxyliciousTester;
57-
import static io.kroxylicious.testing.integration.tester.KroxyliciousTesters.newBuilder;
5858
import static org.assertj.core.api.Assertions.assertThat;
5959

6060
/**
@@ -136,7 +136,7 @@ private void doProxyRestrictedToOlderApiVersion(KafkaCluster cluster, Map<String
136136
var testConfigEnabled = Features.builder().enable(Feature.TEST_ONLY_CONFIGURATION).build();
137137
var proxy = proxy(cluster)
138138
.withDevelopment(Map.of("apiKeyIdMaxVersionOverride", Map.of(ApiKeys.API_VERSIONS.name(), apiVersion)));
139-
try (var tester = newBuilder(proxy).setFeatures(testConfigEnabled).createDefaultKroxyliciousTester();
139+
try (var tester = KroxyliciousTesters.newBuilder(proxy).setFeatures(testConfigEnabled).createDefaultKroxyliciousTester();
140140
var admin = tester.admin(clientSecurityProtocolConfig)) {
141141
// We've got no way to observe the actual version of the API versions request that is used during _negotiation_
142142
// so we make do with asserting the connection is usable.
@@ -188,7 +188,7 @@ void clientAheadOfProxyWhichIsAheadOfBroker() {
188188
var testConfigEnabled = Features.builder().enable(Feature.TEST_ONLY_CONFIGURATION).build();
189189
var proxy = proxy("localhost:9092")
190190
.withDevelopment(Map.of("apiKeyIdMaxVersionOverride", Map.of(ApiKeys.API_VERSIONS.name(), proxyApiVersion)));
191-
try (var tester = newBuilder(proxy).setFeatures(testConfigEnabled).createDefaultKroxyliciousTester();
191+
try (var tester = KroxyliciousTesters.newBuilder(proxy).setFeatures(testConfigEnabled).createDefaultKroxyliciousTester();
192192
var admin = tester.admin()) {
193193
// We've got no way to observe the actual version of the API versions request that is used during _negotiation_
194194
// so we make do with asserting the connection is usable.

kroxylicious-kms-providers/kroxylicious-kms-provider-aws-kms/src/main/java/io/kroxylicious/kms/provider/aws/kms/AwsKms.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import java.io.UncheckedIOException;
1111
import java.net.URI;
1212
import java.net.http.HttpClient;
13-
import java.net.http.HttpClient.Builder;
1413
import java.net.http.HttpRequest;
1514
import java.net.http.HttpResponse;
1615
import java.time.Duration;
@@ -87,7 +86,7 @@ public class AwsKms implements Kms<String, AwsKmsEdek> {
8786
CredentialsProvider credentialsProvider,
8887
String region,
8988
Duration timeout,
90-
UnaryOperator<Builder> tlsConfigurator) {
89+
UnaryOperator<HttpClient.Builder> tlsConfigurator) {
9190
Objects.requireNonNull(awsUrl);
9291
Objects.requireNonNull(credentialsProvider);
9392
Objects.requireNonNull(region);
@@ -100,7 +99,7 @@ public class AwsKms implements Kms<String, AwsKmsEdek> {
10099
this.client = createClient(tlsConfigurator);
101100
}
102101

103-
private HttpClient createClient(UnaryOperator<Builder> tlsConfigurator) {
102+
private HttpClient createClient(UnaryOperator<HttpClient.Builder> tlsConfigurator) {
104103
return tlsConfigurator.apply(HttpClient.newBuilder())
105104
.followRedirects(HttpClient.Redirect.NORMAL)
106105
.connectTimeout(timeout)

kroxylicious-kms-providers/kroxylicious-kms-provider-fortanix-dsm/src/main/java/io/kroxylicious/kms/provider/fortanix/dsm/FortanixDsmKms.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import java.net.URI;
1212
import java.net.http.HttpClient;
1313
import java.net.http.HttpRequest;
14-
import java.net.http.HttpRequest.Builder;
1514
import java.net.http.HttpResponse;
1615
import java.util.List;
1716
import java.util.Map;
@@ -150,7 +149,7 @@ private CompletionStage<DekPair<FortanixDsmKmsEdek>> wrapExportedTransientKey(St
150149
* {@inheritDoc}
151150
* <br/>
152151
* @see <a href="https://support.fortanix.com/apidocs/decrypt-data-using-a-symmetric-or-asymmetric-key">https://support.fortanix.com/apidocs/decrypt-data-using-a-symmetric-or-asymmetric-key</a>
153-
*/
152+
*/
154153
@Override
155154
public CompletionStage<SecretKey> decryptEdek(FortanixDsmKmsEdek edek) {
156155
var sessionFuture = getSessionFuture();
@@ -188,7 +187,7 @@ private URI getEndpointUrl() {
188187
return fortanixDsmUrl;
189188
}
190189

191-
private Builder createRequestBuilder(Object request, String path) {
190+
private HttpRequest.Builder createRequestBuilder(Object request, String path) {
192191
var body = getBody(request).getBytes(UTF_8);
193192

194193
return HttpRequest.newBuilder()
@@ -198,10 +197,11 @@ private Builder createRequestBuilder(Object request, String path) {
198197
.POST(HttpRequest.BodyPublishers.ofByteArray(body));
199198
}
200199

201-
private <T> CompletableFuture<T> sendAsync(Builder requestBuilder, TypeReference<T> valueTypeRef, BiFunction<URI, Integer, KmsException> exceptionSupplier,
200+
private <T> CompletableFuture<T> sendAsync(HttpRequest.Builder requestBuilder, TypeReference<T> valueTypeRef,
201+
BiFunction<URI, Integer, KmsException> exceptionSupplier,
202202
Session session) {
203203

204-
var request = requestBuilder.header(AUTHORIZATION_HEADER, session.authorizationHeader())
204+
HttpRequest request = requestBuilder.header(AUTHORIZATION_HEADER, session.authorizationHeader())
205205
.build();
206206

207207
return client.sendAsync(request, HttpResponse.BodyHandlers.ofByteArray())
@@ -221,7 +221,7 @@ private static <T> T decodeJson(TypeReference<T> valueTypeRef, byte[] bytes) {
221221
}
222222

223223
/**
224-
* If the response has indicates an authorization error it is likely the server has invalidated
224+
* If the response indicates an authorization error it is likely the server has invalidated
225225
* the session (before its expiry). If this case we invalidate the session.
226226
* @param session session
227227
* @param response response

kroxylicious-kms-tls-support/src/main/java/io/kroxylicious/testing/kms/tls/TlsHttpClientConfigurator.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
import java.io.FileInputStream;
1010
import java.net.http.HttpClient;
11-
import java.net.http.HttpClient.Builder;
1211
import java.security.KeyStore;
1312
import java.security.NoSuchAlgorithmException;
1413
import java.security.SecureRandom;
@@ -51,7 +50,7 @@
5150
/**
5251
* Responsible for applying TLS configuration to a {@link HttpClient.Builder}.
5352
*/
54-
public class TlsHttpClientConfigurator implements UnaryOperator<Builder> {
53+
public class TlsHttpClientConfigurator implements UnaryOperator<HttpClient.Builder> {
5554

5655
private static final Logger LOGGER = LoggerFactory.getLogger(TlsHttpClientConfigurator.class);
5756

@@ -262,14 +261,14 @@ private static TrustManager[] getDefaultTrustManagers() {
262261
}
263262

264263
/**
265-
* Applies TLS configuration to the supplied {@link Builder}. If there is no
264+
* Applies TLS configuration to the supplied {@link HttpClient.Builder}. If there is no
266265
* TLS configuration to apply, this operation is a no-op.
267266
*
268267
* @param builder HTTP client builder
269268
* @return HTTP client builder
270269
*/
271270
@Override
272-
public Builder apply(@NonNull Builder builder) {
271+
public HttpClient.Builder apply(@NonNull HttpClient.Builder builder) {
273272
Objects.requireNonNull(builder);
274273
builder.sslContext(sslContext())
275274
.sslParameters(sslParameters());

kroxylicious-runtime/src/test/java/io/kroxylicious/proxy/internal/admin/RoutingHttpServerTest.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import io.netty.handler.codec.http.HttpResponseStatus;
2020
import io.netty.handler.codec.http.HttpVersion;
2121

22-
import static io.kroxylicious.proxy.internal.admin.RoutingHttpServer.builder;
2322
import static io.kroxylicious.proxy.internal.admin.RoutingHttpServer.responseWithBody;
2423
import static io.kroxylicious.proxy.internal.admin.RoutingHttpServer.responseWithStatus;
2524
import static org.assertj.core.api.Assertions.assertThat;
@@ -31,7 +30,7 @@ void shouldRouteRequestForKnownPath() {
3130
// Given
3231

3332
var route = URI.create("https://localhost/mypath").toString();
34-
var handler = builder().withRoute(route, rq -> responseWithStatus(rq, HttpResponseStatus.OK)).build();
33+
var handler = RoutingHttpServer.builder().withRoute(route, rq -> responseWithStatus(rq, HttpResponseStatus.OK)).build();
3534
var channel = new EmbeddedChannel(handler);
3635
var request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, route);
3736

@@ -49,7 +48,7 @@ void shouldSupportResponseWithBody() {
4948
// Given
5049

5150
var route = URI.create("https://localhost/mypath").toString();
52-
var handler = builder().withRoute(route, rq -> responseWithBody(rq, HttpResponseStatus.OK, "Hello World")).build();
51+
var handler = RoutingHttpServer.builder().withRoute(route, rq -> responseWithBody(rq, HttpResponseStatus.OK, "Hello World")).build();
5352
var channel = new EmbeddedChannel(handler);
5453
var request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, route);
5554

@@ -73,7 +72,7 @@ void shouldRespond404ForUnknownPath() {
7372

7473
var route = URI.create("https://localhost/mypath").toString();
7574
var another = URI.create("https://localhost/another").toString();
76-
var handler = builder().withRoute(route, rq -> responseWithStatus(rq, HttpResponseStatus.OK)).build();
75+
var handler = RoutingHttpServer.builder().withRoute(route, rq -> responseWithStatus(rq, HttpResponseStatus.OK)).build();
7776
var channel = new EmbeddedChannel(handler);
7877
var request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, another);
7978

@@ -91,7 +90,7 @@ void shouldRejectUnsupportedMethodAndCloseConnection() {
9190
// Given
9291

9392
var route = URI.create("https://localhost/mypath").toString();
94-
var handler = builder().withRoute(route, rq -> responseWithStatus(rq, HttpResponseStatus.OK)).build();
93+
var handler = RoutingHttpServer.builder().withRoute(route, rq -> responseWithStatus(rq, HttpResponseStatus.OK)).build();
9594
var channel = new EmbeddedChannel(handler);
9695
var request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, route);
9796

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1389,7 +1389,7 @@
13891389
<arg>-XDcompilePolicy=simple</arg>
13901390
<arg>--should-stop=ifError=FLOW</arg>
13911391
<!-- The following <arg> cannot be split over multiple lines :-( -->
1392-
<arg>-Xplugin:ErrorProne -XepDisableWarningsInGeneratedCode -XepExcludedPaths:.*/target/generated-sources/.* -Xep:MissingOverride:ERROR -Xep:MutablePublicArray:ERROR -Xep:MathAbsoluteNegative:ERROR -Xep:EffectivelyPrivate:ERROR -Xep:ByteBufferBackingArray:ERROR -Xep:UnnecessaryMethodReference:ERROR -Xep:OperatorPrecedence:ERROR -Xep:ImmutableEnumChecker:ERROR -Xep:StatementSwitchToExpressionSwitch:ERROR -Xep:StaticAssignmentOfThrowable:ERROR</arg>
1392+
<arg>-Xplugin:ErrorProne -XepDisableWarningsInGeneratedCode -XepExcludedPaths:.*/target/generated-sources/.* -Xep:MissingOverride:ERROR -Xep:MutablePublicArray:ERROR -Xep:MathAbsoluteNegative:ERROR -Xep:EffectivelyPrivate:ERROR -Xep:ByteBufferBackingArray:ERROR -Xep:UnnecessaryMethodReference:ERROR -Xep:OperatorPrecedence:ERROR -Xep:ImmutableEnumChecker:ERROR -Xep:StatementSwitchToExpressionSwitch:ERROR -Xep:StaticAssignmentOfThrowable:ERROR -Xep:BadImport:ERROR</arg>
13931393
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED</arg>
13941394
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED</arg>
13951395
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED</arg>

0 commit comments

Comments
 (0)