From fcd2b8e77044a7b2600d685a4e33bb69ae22374f Mon Sep 17 00:00:00 2001 From: Martin Ocenas Date: Thu, 14 Nov 2024 13:46:47 +0100 Subject: [PATCH] Apply idea code analysis suggestions M-N --- messaging/infinispan-grpc-kafka/README.md | 6 +++--- .../infinispan/grpc/kafka/InfinispanPopulated.java | 4 ++-- .../grpc/kafka/books/BookCacheInitializer.java | 4 ++-- .../grpc/kafka/books/BookContextInitializer.java | 4 ++-- .../infinispan/grpc/kafka/books/BookResource.java | 3 +-- .../grpc/kafka/prices/PriceGenerator.java | 2 +- .../grpc/kafka/quickstart/KafkaEndpoint.java | 4 +--- .../ts/messaging/kafka/BaseKafkaAvroGroupIdIT.java | 6 +----- .../ts/messaging/kafka/producer/Application.java | 2 +- .../messaging/kafka/producer/FailureHandler.java | 3 +-- .../kafka/producer/KafkaBlockingProducer.java | 4 ++-- .../streams/WindowedLoginDeniedStream.java | 2 +- .../DevModeRedPandaDevServiceUserExperienceIT.java | 2 +- .../kafka/reactive/BaseKafkaAvroGroupIdIT.java | 6 +----- .../qe/messaging/ssl/quickstart/KafkaEndpoint.java | 4 +--- .../quarkus/ts/messaging/qpid/PriceConsumer.java | 14 ++++++-------- .../BaseOpenShiftAlertEventsReactiveIT.java | 2 +- .../kafka/reactive/KafkaAndMetricsIT.java | 1 - .../kafka/BaseOpenShiftAlertEventsIT.java | 2 +- .../prometheus/OpenShiftCustomMetricsIT.java | 2 +- .../reactive/OpenTelemetryGrpcIT.java | 4 ++-- .../opentelemetry/reactive/OpenTelemetrySseIT.java | 4 ++-- .../ts/opentelemetry/OpenTelemetryGrpcIT.java | 4 ++-- .../ts/opentelemetry/OpenTelemetrySseIT.java | 4 ++-- .../quarkus/ts/elasticsearch/DataTypesService.java | 3 +-- .../ts/elasticsearch/DevModeElasticsearchIT.java | 1 - .../quarkus/ts/elasticsearch/ElasticsearchIT.java | 4 ++-- .../ts/infinispan/client/InfinispanClientApp.java | 4 ++-- .../quarkus/ts/nosqldb/mongodb/reactive/Fruit.java | 4 +--- .../java/io/quarkus/ts/nosqldb/mongodb/Fruit.java | 4 +--- 30 files changed, 45 insertions(+), 68 deletions(-) diff --git a/messaging/infinispan-grpc-kafka/README.md b/messaging/infinispan-grpc-kafka/README.md index df5c400a9..f82aa34e2 100644 --- a/messaging/infinispan-grpc-kafka/README.md +++ b/messaging/infinispan-grpc-kafka/README.md @@ -1,7 +1,7 @@ # Table of Contents 1. [Quarkus infinispan grpc kafka](#Quarkus-infinispan-grpc-kafka) -2. [Quarkus SSL/TLS Infinispan scenario ](#Quarkus-SSL/TLS-Infinispan-scenario ) -3. [Quarkus Grateful Shutdown for Kafka connectors](#Quarkus-Grateful-Shutdown-for-Kafka-connectors) +2. [Kafka-client SASL](#Kafka-client-SASL) +3. [Quarkus Infinispan scenario](#Quarkus-Infinispan-scenario) ## Quarkus infinispan grpc kafka Module that test whether gRPC, Infinispan and Kafka extensions work together: @@ -14,7 +14,7 @@ Verifies SASL authentication through Quarkus Kafka client extension. Endpoint `SaslKafkaEndpoint` is able to produce events and consume events and check topics through `AdminClient` and `KafkaConsumer`. -## Quarkus Infinispan scenario +## Quarkus Infinispan scenario ##Infinispan server SSL/TLS TrustStore is used to store certificates from Certified Authorities (CA) that verify the certificate presented by the server diff --git a/messaging/infinispan-grpc-kafka/src/main/java/io/quarkus/ts/messaging/infinispan/grpc/kafka/InfinispanPopulated.java b/messaging/infinispan-grpc-kafka/src/main/java/io/quarkus/ts/messaging/infinispan/grpc/kafka/InfinispanPopulated.java index 65644b164..b451985b5 100644 --- a/messaging/infinispan-grpc-kafka/src/main/java/io/quarkus/ts/messaging/infinispan/grpc/kafka/InfinispanPopulated.java +++ b/messaging/infinispan-grpc-kafka/src/main/java/io/quarkus/ts/messaging/infinispan/grpc/kafka/InfinispanPopulated.java @@ -6,7 +6,7 @@ import org.infinispan.client.hotrod.RemoteCache; import org.infinispan.client.hotrod.RemoteCacheManager; -import org.infinispan.commons.configuration.XMLStringConfiguration; +import org.infinispan.commons.configuration.StringConfiguration; import org.jboss.logging.Logger; import io.quarkus.runtime.StartupEvent; @@ -26,7 +26,7 @@ public class InfinispanPopulated { void onStart(@Observes StartupEvent ev) { LOGGER.info("Create or get cache named mycache with the default configuration"); RemoteCache cache = cacheManager.administration().getOrCreateCache("mycache", - new XMLStringConfiguration(CACHE_CONFIG)); + new StringConfiguration(CACHE_CONFIG)); cache.put("hello", "Hello World, Infinispan is up!"); } } diff --git a/messaging/infinispan-grpc-kafka/src/main/java/io/quarkus/ts/messaging/infinispan/grpc/kafka/books/BookCacheInitializer.java b/messaging/infinispan-grpc-kafka/src/main/java/io/quarkus/ts/messaging/infinispan/grpc/kafka/books/BookCacheInitializer.java index f207164ac..c07b89be6 100644 --- a/messaging/infinispan-grpc-kafka/src/main/java/io/quarkus/ts/messaging/infinispan/grpc/kafka/books/BookCacheInitializer.java +++ b/messaging/infinispan-grpc-kafka/src/main/java/io/quarkus/ts/messaging/infinispan/grpc/kafka/books/BookCacheInitializer.java @@ -5,7 +5,7 @@ import jakarta.inject.Inject; import org.infinispan.client.hotrod.RemoteCacheManager; -import org.infinispan.commons.configuration.XMLStringConfiguration; +import org.infinispan.commons.configuration.StringConfiguration; import io.quarkus.runtime.StartupEvent; @@ -23,7 +23,7 @@ public class BookCacheInitializer { void onStart(@Observes StartupEvent ev) { cacheManager.administration().getOrCreateCache(CACHE_NAME, - new XMLStringConfiguration(String.format(CACHE_CONFIG, CACHE_NAME))); + new StringConfiguration(String.format(CACHE_CONFIG, CACHE_NAME))); } diff --git a/messaging/infinispan-grpc-kafka/src/main/java/io/quarkus/ts/messaging/infinispan/grpc/kafka/books/BookContextInitializer.java b/messaging/infinispan-grpc-kafka/src/main/java/io/quarkus/ts/messaging/infinispan/grpc/kafka/books/BookContextInitializer.java index f0434d6a5..e97c5718d 100644 --- a/messaging/infinispan-grpc-kafka/src/main/java/io/quarkus/ts/messaging/infinispan/grpc/kafka/books/BookContextInitializer.java +++ b/messaging/infinispan-grpc-kafka/src/main/java/io/quarkus/ts/messaging/infinispan/grpc/kafka/books/BookContextInitializer.java @@ -1,8 +1,8 @@ package io.quarkus.ts.messaging.infinispan.grpc.kafka.books; import org.infinispan.protostream.SerializationContextInitializer; -import org.infinispan.protostream.annotations.AutoProtoSchemaBuilder; +import org.infinispan.protostream.annotations.ProtoSchema; -@AutoProtoSchemaBuilder(includeClasses = { Book.class }, schemaPackageName = "book_sample") +@ProtoSchema(includeClasses = { Book.class }, schemaPackageName = "book_sample") interface BookContextInitializer extends SerializationContextInitializer { } diff --git a/messaging/infinispan-grpc-kafka/src/main/java/io/quarkus/ts/messaging/infinispan/grpc/kafka/books/BookResource.java b/messaging/infinispan-grpc-kafka/src/main/java/io/quarkus/ts/messaging/infinispan/grpc/kafka/books/BookResource.java index 3130ff97f..868a29e89 100644 --- a/messaging/infinispan-grpc-kafka/src/main/java/io/quarkus/ts/messaging/infinispan/grpc/kafka/books/BookResource.java +++ b/messaging/infinispan-grpc-kafka/src/main/java/io/quarkus/ts/messaging/infinispan/grpc/kafka/books/BookResource.java @@ -25,8 +25,7 @@ public class BookResource { @Path("/{title}") @Produces(MediaType.APPLICATION_JSON) public Book getBook(@PathParam("title") String title) { - Book found = cache.get(title); - return found; + return cache.get(title); } @POST diff --git a/messaging/infinispan-grpc-kafka/src/main/java/io/quarkus/ts/messaging/infinispan/grpc/kafka/prices/PriceGenerator.java b/messaging/infinispan-grpc-kafka/src/main/java/io/quarkus/ts/messaging/infinispan/grpc/kafka/prices/PriceGenerator.java index 88ff69856..dec2e5dff 100644 --- a/messaging/infinispan-grpc-kafka/src/main/java/io/quarkus/ts/messaging/infinispan/grpc/kafka/prices/PriceGenerator.java +++ b/messaging/infinispan-grpc-kafka/src/main/java/io/quarkus/ts/messaging/infinispan/grpc/kafka/prices/PriceGenerator.java @@ -10,7 +10,7 @@ import io.smallrye.mutiny.Multi; /** - * A bean producing random prices every 1 seconds. + * A bean producing random prices every 1 second. * The prices are written to a Kafka topic (prices). The Kafka configuration is specified in the application configuration. */ @ApplicationScoped diff --git a/messaging/infinispan-grpc-kafka/src/main/java/io/quarkus/ts/messaging/infinispan/grpc/kafka/quickstart/KafkaEndpoint.java b/messaging/infinispan-grpc-kafka/src/main/java/io/quarkus/ts/messaging/infinispan/grpc/kafka/quickstart/KafkaEndpoint.java index 5f52e2920..014847890 100644 --- a/messaging/infinispan-grpc-kafka/src/main/java/io/quarkus/ts/messaging/infinispan/grpc/kafka/quickstart/KafkaEndpoint.java +++ b/messaging/infinispan-grpc-kafka/src/main/java/io/quarkus/ts/messaging/infinispan/grpc/kafka/quickstart/KafkaEndpoint.java @@ -24,7 +24,7 @@ public abstract class KafkaEndpoint { protected void initialize(KafkaConsumer consumer) { consumer.subscribe(Collections.singleton(TOPIC)); new Thread(() -> { - try { + try (consumer) { while (true) { final ConsumerRecords consumerRecords = consumer.poll(Duration.ofSeconds(1)); @@ -38,8 +38,6 @@ protected void initialize(KafkaConsumer consumer) { } } catch (Exception e) { LOG.error(e.getMessage()); - } finally { - consumer.close(); } }).start(); } diff --git a/messaging/kafka-confluent-avro-reactive-messaging/src/test/java/io/quarkus/ts/messaging/kafka/BaseKafkaAvroGroupIdIT.java b/messaging/kafka-confluent-avro-reactive-messaging/src/test/java/io/quarkus/ts/messaging/kafka/BaseKafkaAvroGroupIdIT.java index d7d0022f9..888789d5e 100644 --- a/messaging/kafka-confluent-avro-reactive-messaging/src/test/java/io/quarkus/ts/messaging/kafka/BaseKafkaAvroGroupIdIT.java +++ b/messaging/kafka-confluent-avro-reactive-messaging/src/test/java/io/quarkus/ts/messaging/kafka/BaseKafkaAvroGroupIdIT.java @@ -3,10 +3,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -import java.util.List; import java.util.Random; import java.util.UUID; -import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; @@ -30,12 +28,11 @@ abstract class BaseKafkaAvroGroupIdIT { private String endpoint; private Client client = ClientBuilder.newClient(); - private List receive = new CopyOnWriteArrayList<>(); private boolean completed; private Random rand = new Random(); @Test - public void testAlertMonitorEventStream() throws InterruptedException { + public void testAlertMonitorEventStream() { GivenSomeStockPrices(getAppA(), EVENTS_AMOUNT); AndApplicationEndpoint(getEndpoint(getAppA()) + "/stock-price/stream"); whenRequestSomeEvents(EVENTS_AMOUNT); @@ -73,7 +70,6 @@ private void whenRequestSomeEvents(int expectedAmount) { SseEventSource source = SseEventSource.target(target).build(); source.register(inboundSseEvent -> { final var data = inboundSseEvent.readData(String.class, MediaType.APPLICATION_JSON_TYPE); - receive.add(data); totalAmountReceived.incrementAndGet(); }); diff --git a/messaging/kafka-producer/src/main/java/io/quarkus/ts/messaging/kafka/producer/Application.java b/messaging/kafka-producer/src/main/java/io/quarkus/ts/messaging/kafka/producer/Application.java index e993fa480..e42755b1a 100644 --- a/messaging/kafka-producer/src/main/java/io/quarkus/ts/messaging/kafka/producer/Application.java +++ b/messaging/kafka-producer/src/main/java/io/quarkus/ts/messaging/kafka/producer/Application.java @@ -52,7 +52,7 @@ void onStop(@Observes ShutdownEvent ev) { private void addRoute(HttpMethod method, String path, Handler handler) { Route route = this.router.route(method, path) .handler(LoggerHandler.create()) - .handler(CorsHandler.create("*")); + .handler(CorsHandler.create().addRelativeOrigin(".*")); if (method.equals(HttpMethod.POST) || method.equals(HttpMethod.PUT)) route.handler(BodyHandler.create()); diff --git a/messaging/kafka-producer/src/main/java/io/quarkus/ts/messaging/kafka/producer/FailureHandler.java b/messaging/kafka-producer/src/main/java/io/quarkus/ts/messaging/kafka/producer/FailureHandler.java index 109375814..93a032e82 100644 --- a/messaging/kafka-producer/src/main/java/io/quarkus/ts/messaging/kafka/producer/FailureHandler.java +++ b/messaging/kafka-producer/src/main/java/io/quarkus/ts/messaging/kafka/producer/FailureHandler.java @@ -13,8 +13,7 @@ public class FailureHandler { public void handler(final RoutingContext ctx) { JsonObject error = defaultError(ctx.normalizedPath()); - if (ctx.failure() instanceof HttpException) { - HttpException httpExp = (HttpException) ctx.failure(); + if (ctx.failure() instanceof HttpException httpExp) { error.put("status", httpExp.getStatusCode()); } diff --git a/messaging/kafka-producer/src/main/java/io/quarkus/ts/messaging/kafka/producer/KafkaBlockingProducer.java b/messaging/kafka-producer/src/main/java/io/quarkus/ts/messaging/kafka/producer/KafkaBlockingProducer.java index 71b2f8102..12027b9c8 100644 --- a/messaging/kafka-producer/src/main/java/io/quarkus/ts/messaging/kafka/producer/KafkaBlockingProducer.java +++ b/messaging/kafka-producer/src/main/java/io/quarkus/ts/messaging/kafka/producer/KafkaBlockingProducer.java @@ -45,7 +45,7 @@ public void pushEvent(final RoutingContext context) { } public void pushMessageEvent(final RoutingContext routingContext) { - String message = routingContext.getBodyAsString(); + String message = routingContext.body().asString(); emitter.send(message) .onFailure().invoke(exception -> { routingContext.response() @@ -73,7 +73,7 @@ public void pushEventToTopic(final RoutingContext context) { .withNack(handlerError(context, startMs)) .addMetadata(metadata); - emitter.send(msg); + emitter.sendMessageAndForget(msg); } private Function> handlerError(RoutingContext context, Long startMs) { diff --git a/messaging/kafka-streams-reactive-messaging/src/main/java/io/quarkus/ts/messaging/kafka/reactive/streams/aggregator/streams/WindowedLoginDeniedStream.java b/messaging/kafka-streams-reactive-messaging/src/main/java/io/quarkus/ts/messaging/kafka/reactive/streams/aggregator/streams/WindowedLoginDeniedStream.java index 1ee1c0403..575b6fa1c 100644 --- a/messaging/kafka-streams-reactive-messaging/src/main/java/io/quarkus/ts/messaging/kafka/reactive/streams/aggregator/streams/WindowedLoginDeniedStream.java +++ b/messaging/kafka-streams-reactive-messaging/src/main/java/io/quarkus/ts/messaging/kafka/reactive/streams/aggregator/streams/WindowedLoginDeniedStream.java @@ -47,7 +47,7 @@ public Topology buildTopology() { builder.stream(LOGIN_ATTEMPTS_TOPIC, Consumed.with(Serdes.String(), loginAttemptSerde)) .groupByKey() - .windowedBy(TimeWindows.of(Duration.ofSeconds(windowsLoginSec))) + .windowedBy(TimeWindows.ofSizeWithNoGrace(Duration.ofSeconds(windowsLoginSec))) .aggregate(LoginAggregation::new, (id, value, aggregation) -> aggregation.updateFrom(value), Materialized.> as(LOGIN_AGGREGATION_STORE) diff --git a/messaging/kafka-streams-reactive-messaging/src/test/java/io/quarkus/ts/messaging/kafka/reactive/streams/DevModeRedPandaDevServiceUserExperienceIT.java b/messaging/kafka-streams-reactive-messaging/src/test/java/io/quarkus/ts/messaging/kafka/reactive/streams/DevModeRedPandaDevServiceUserExperienceIT.java index 220d218e8..7c7087a11 100644 --- a/messaging/kafka-streams-reactive-messaging/src/test/java/io/quarkus/ts/messaging/kafka/reactive/streams/DevModeRedPandaDevServiceUserExperienceIT.java +++ b/messaging/kafka-streams-reactive-messaging/src/test/java/io/quarkus/ts/messaging/kafka/reactive/streams/DevModeRedPandaDevServiceUserExperienceIT.java @@ -20,7 +20,7 @@ @DisabledOnRHBQandWindows(reason = "QUARKUS-3434") public class DevModeRedPandaDevServiceUserExperienceIT { - private static final String RED_PANDA_VERSION = getImageVersion("redpanda.image");; + private static final String RED_PANDA_VERSION = getImageVersion("redpanda.image"); private static final String RED_PANDA_IMAGE = getImageName("redpanda.image"); @DevModeQuarkusApplication diff --git a/messaging/kafka-strimzi-avro-reactive-messaging/src/test/java/io/quarkus/ts/messaging/strimzi/kafka/reactive/BaseKafkaAvroGroupIdIT.java b/messaging/kafka-strimzi-avro-reactive-messaging/src/test/java/io/quarkus/ts/messaging/strimzi/kafka/reactive/BaseKafkaAvroGroupIdIT.java index 0b2f91b91..6f7e2826d 100644 --- a/messaging/kafka-strimzi-avro-reactive-messaging/src/test/java/io/quarkus/ts/messaging/strimzi/kafka/reactive/BaseKafkaAvroGroupIdIT.java +++ b/messaging/kafka-strimzi-avro-reactive-messaging/src/test/java/io/quarkus/ts/messaging/strimzi/kafka/reactive/BaseKafkaAvroGroupIdIT.java @@ -3,10 +3,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -import java.util.List; import java.util.Random; import java.util.UUID; -import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; @@ -30,12 +28,11 @@ abstract class BaseKafkaAvroGroupIdIT { private String endpoint; private Client client = ClientBuilder.newClient(); - private List receive = new CopyOnWriteArrayList<>(); private boolean completed; private Random rand = new Random(); @Test - public void testAlertMonitorEventStream() throws InterruptedException { + public void testAlertMonitorEventStream() { GivenSomeStockPrices(getAppA(), EVENTS_AMOUNT); AndApplicationEndpoint(getEndpoint(getAppA()) + "/stock-price/stream"); whenRequestSomeEvents(EVENTS_AMOUNT); @@ -73,7 +70,6 @@ private void whenRequestSomeEvents(int expectedAmount) { SseEventSource source = SseEventSource.target(target).build(); source.register(inboundSseEvent -> { final var data = inboundSseEvent.readData(String.class, MediaType.APPLICATION_JSON_TYPE); - receive.add(data); totalAmountReceived.incrementAndGet(); }); diff --git a/messaging/kafkaSSL/src/main/java/io/quarkus/qe/messaging/ssl/quickstart/KafkaEndpoint.java b/messaging/kafkaSSL/src/main/java/io/quarkus/qe/messaging/ssl/quickstart/KafkaEndpoint.java index 4016feb0c..9d1ca5410 100644 --- a/messaging/kafkaSSL/src/main/java/io/quarkus/qe/messaging/ssl/quickstart/KafkaEndpoint.java +++ b/messaging/kafkaSSL/src/main/java/io/quarkus/qe/messaging/ssl/quickstart/KafkaEndpoint.java @@ -24,7 +24,7 @@ public abstract class KafkaEndpoint { protected void initialize(KafkaConsumer consumer) { consumer.subscribe(Collections.singleton(TOPIC)); new Thread(() -> { - try { + try (consumer) { while (true) { final ConsumerRecords consumerRecords = consumer.poll(Duration.ofSeconds(1)); @@ -38,8 +38,6 @@ protected void initialize(KafkaConsumer consumer) { } } catch (Exception e) { LOG.error(e.getMessage()); - } finally { - consumer.close(); } }).start(); } diff --git a/messaging/qpid/src/main/java/io/quarkus/ts/messaging/qpid/PriceConsumer.java b/messaging/qpid/src/main/java/io/quarkus/ts/messaging/qpid/PriceConsumer.java index 097fd01bc..4447e458d 100644 --- a/messaging/qpid/src/main/java/io/quarkus/ts/messaging/qpid/PriceConsumer.java +++ b/messaging/qpid/src/main/java/io/quarkus/ts/messaging/qpid/PriceConsumer.java @@ -21,15 +21,13 @@ public class PriceConsumer { public String getLastPrice() { try (JMSContext context = connectionFactory.createContext(Session.AUTO_ACKNOWLEDGE); JMSConsumer consumer = context.createConsumer(context.createTopic("prices"))) { - while (true) { - Message message = consumer.receive(); - if (message == null) { - // receive returns `null` if the JMSConsumer is closed - return ""; - } - - return message.getBody(String.class); + Message message = consumer.receive(); + if (message == null) { + // receive returns `null` if the JMSConsumer is closed + return ""; } + + return message.getBody(String.class); } catch (Exception e) { throw new RuntimeException(e); } diff --git a/monitoring/micrometer-prometheus-kafka-reactive/src/test/java/io/quarkus/ts/micrometer/prometheus/kafka/reactive/BaseOpenShiftAlertEventsReactiveIT.java b/monitoring/micrometer-prometheus-kafka-reactive/src/test/java/io/quarkus/ts/micrometer/prometheus/kafka/reactive/BaseOpenShiftAlertEventsReactiveIT.java index e59a4b52b..4a3d12026 100644 --- a/monitoring/micrometer-prometheus-kafka-reactive/src/test/java/io/quarkus/ts/micrometer/prometheus/kafka/reactive/BaseOpenShiftAlertEventsReactiveIT.java +++ b/monitoring/micrometer-prometheus-kafka-reactive/src/test/java/io/quarkus/ts/micrometer/prometheus/kafka/reactive/BaseOpenShiftAlertEventsReactiveIT.java @@ -89,7 +89,7 @@ private void thenKafkaConsumerMetricsAreFound() throws Exception { thenMetricIsExposedInPrometheus(KAFKA_CONSUMER_COUNT_METRIC, any()); } - private void thenMetricIsExposedInPrometheus(String name, Predicate valueMatcher) throws Exception { + private void thenMetricIsExposedInPrometheus(String name, Predicate valueMatcher) { await().ignoreExceptions().atMost(ASSERT_PROMETHEUS_TIMEOUT_MINUTES, TimeUnit.MINUTES).untilAsserted(() -> { String output = runPrometheusCommandInPod(PROMETHEUS_POD, name); diff --git a/monitoring/micrometer-prometheus-kafka-reactive/src/test/java/io/quarkus/ts/micrometer/prometheus/kafka/reactive/KafkaAndMetricsIT.java b/monitoring/micrometer-prometheus-kafka-reactive/src/test/java/io/quarkus/ts/micrometer/prometheus/kafka/reactive/KafkaAndMetricsIT.java index d14c0d301..c9cd8228c 100644 --- a/monitoring/micrometer-prometheus-kafka-reactive/src/test/java/io/quarkus/ts/micrometer/prometheus/kafka/reactive/KafkaAndMetricsIT.java +++ b/monitoring/micrometer-prometheus-kafka-reactive/src/test/java/io/quarkus/ts/micrometer/prometheus/kafka/reactive/KafkaAndMetricsIT.java @@ -1,6 +1,5 @@ package io.quarkus.ts.micrometer.prometheus.kafka.reactive; -import static io.restassured.RestAssured.given; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; diff --git a/monitoring/micrometer-prometheus-kafka/src/test/java/io/quarkus/ts/micrometer/prometheus/kafka/BaseOpenShiftAlertEventsIT.java b/monitoring/micrometer-prometheus-kafka/src/test/java/io/quarkus/ts/micrometer/prometheus/kafka/BaseOpenShiftAlertEventsIT.java index 2f10c4365..1970793ae 100644 --- a/monitoring/micrometer-prometheus-kafka/src/test/java/io/quarkus/ts/micrometer/prometheus/kafka/BaseOpenShiftAlertEventsIT.java +++ b/monitoring/micrometer-prometheus-kafka/src/test/java/io/quarkus/ts/micrometer/prometheus/kafka/BaseOpenShiftAlertEventsIT.java @@ -91,7 +91,7 @@ private void thenKafkaConsumerMetricsAreFound() throws Exception { thenMetricIsExposedInPrometheus(KAFKA_CONSUMER_COUNT_METRIC, any()); } - private void thenMetricIsExposedInPrometheus(String name, Predicate valueMatcher) throws Exception { + private void thenMetricIsExposedInPrometheus(String name, Predicate valueMatcher) { await().ignoreExceptions().atMost(ASSERT_PROMETHEUS_TIMEOUT_MINUTES, TimeUnit.MINUTES).untilAsserted(() -> { String output = runPrometheusCommandInPod(PROMETHEUS_POD, name); assertTrue(output.contains("\"status\":\"success\""), "Verify the status was ok"); diff --git a/monitoring/micrometer-prometheus/src/test/java/io/quarkus/ts/micrometer/prometheus/OpenShiftCustomMetricsIT.java b/monitoring/micrometer-prometheus/src/test/java/io/quarkus/ts/micrometer/prometheus/OpenShiftCustomMetricsIT.java index a714ef42a..8332debe7 100644 --- a/monitoring/micrometer-prometheus/src/test/java/io/quarkus/ts/micrometer/prometheus/OpenShiftCustomMetricsIT.java +++ b/monitoring/micrometer-prometheus/src/test/java/io/quarkus/ts/micrometer/prometheus/OpenShiftCustomMetricsIT.java @@ -91,7 +91,7 @@ private void whenCheckPrimeNumber(int number) { app.given().get("/check/" + number).then().statusCode(HttpStatus.SC_OK); } - private void thenMetricIsExposedInPrometheus(String name, Integer expected) throws Exception { + private void thenMetricIsExposedInPrometheus(String name, Integer expected) { await().ignoreExceptions().atMost(ASSERT_PROMETHEUS_TIMEOUT_MINUTES, TimeUnit.MINUTES).untilAsserted(() -> { String output = runPrometheusCommandInPod(PROMETHEUS_POD, primeNumberCustomMetricName(name)); diff --git a/monitoring/opentelemetry-reactive/src/test/java/io/quarkus/ts/opentelemetry/reactive/OpenTelemetryGrpcIT.java b/monitoring/opentelemetry-reactive/src/test/java/io/quarkus/ts/opentelemetry/reactive/OpenTelemetryGrpcIT.java index 04b531c5c..6dd0dc803 100644 --- a/monitoring/opentelemetry-reactive/src/test/java/io/quarkus/ts/opentelemetry/reactive/OpenTelemetryGrpcIT.java +++ b/monitoring/opentelemetry-reactive/src/test/java/io/quarkus/ts/opentelemetry/reactive/OpenTelemetryGrpcIT.java @@ -33,14 +33,14 @@ public class OpenTelemetryGrpcIT { private static final String SAY_PONG_PROTO = "SayPong"; @Test - public void testServerClientTrace() throws InterruptedException { + public void testServerClientTrace() { // When calling ping, the rest will invoke also the pong rest endpoint. given() .when().get(PING_ENDPOINT) .then().statusCode(HttpStatus.SC_OK) .body(containsString("ping pong")); - // Then both ping and pong rest endpoints should have the same trace Id. + // Then both ping and pong rest endpoints should have the same trace ID. String pingTraceId = given() .when().get(PING_ENDPOINT + "/lastTraceId") .then().statusCode(HttpStatus.SC_OK).and().extract().asString(); diff --git a/monitoring/opentelemetry-reactive/src/test/java/io/quarkus/ts/opentelemetry/reactive/OpenTelemetrySseIT.java b/monitoring/opentelemetry-reactive/src/test/java/io/quarkus/ts/opentelemetry/reactive/OpenTelemetrySseIT.java index 652c86542..b5b4ab840 100644 --- a/monitoring/opentelemetry-reactive/src/test/java/io/quarkus/ts/opentelemetry/reactive/OpenTelemetrySseIT.java +++ b/monitoring/opentelemetry-reactive/src/test/java/io/quarkus/ts/opentelemetry/reactive/OpenTelemetrySseIT.java @@ -35,14 +35,14 @@ public class OpenTelemetrySseIT { private static final String PONG_ENDPOINT = "/server-sent-events-pong"; @Test - public void testServerClientTrace() throws InterruptedException { + public void testServerClientTrace() { // When calling ping, the rest will invoke also the pong rest endpoint. given() .when().get(PING_ENDPOINT) .then().statusCode(HttpStatus.SC_OK) .body(containsString("ping pong")); - // Then both ping and pong rest endpoints should have the same trace Id. + // Then both ping and pong rest endpoints should have the same trace ID. String pingTraceId = given() .when().get(PING_ENDPOINT + "/lastTraceId") .then().statusCode(HttpStatus.SC_OK).and().extract().asString(); diff --git a/monitoring/opentelemetry/src/test/java/io/quarkus/ts/opentelemetry/OpenTelemetryGrpcIT.java b/monitoring/opentelemetry/src/test/java/io/quarkus/ts/opentelemetry/OpenTelemetryGrpcIT.java index bdceb5a9d..859a5f171 100644 --- a/monitoring/opentelemetry/src/test/java/io/quarkus/ts/opentelemetry/OpenTelemetryGrpcIT.java +++ b/monitoring/opentelemetry/src/test/java/io/quarkus/ts/opentelemetry/OpenTelemetryGrpcIT.java @@ -33,14 +33,14 @@ public class OpenTelemetryGrpcIT { private static final String SAY_PONG_PROTO = "SayPong"; @Test - public void testServerClientTrace() throws InterruptedException { + public void testServerClientTrace() { // When calling ping, the rest will invoke also the pong rest endpoint. given() .when().get(PING_ENDPOINT) .then().statusCode(HttpStatus.SC_OK) .body(containsString("ping pong")); - // Then both ping and pong rest endpoints should have the same trace Id. + // Then both ping and pong rest endpoints should have the same trace ID. String pingTraceId = given() .when().get(PING_ENDPOINT + "/lastTraceId") .then().statusCode(HttpStatus.SC_OK).and().extract().asString(); diff --git a/monitoring/opentelemetry/src/test/java/io/quarkus/ts/opentelemetry/OpenTelemetrySseIT.java b/monitoring/opentelemetry/src/test/java/io/quarkus/ts/opentelemetry/OpenTelemetrySseIT.java index 4def12ffc..ddd589d3d 100644 --- a/monitoring/opentelemetry/src/test/java/io/quarkus/ts/opentelemetry/OpenTelemetrySseIT.java +++ b/monitoring/opentelemetry/src/test/java/io/quarkus/ts/opentelemetry/OpenTelemetrySseIT.java @@ -37,7 +37,7 @@ public class OpenTelemetrySseIT { private static final String PONG_ENDPOINT = "/server-sent-events-pong"; @Test - public void testServerClientTrace() throws InterruptedException { + public void testServerClientTrace() { // When calling ping, the rest will invoke also the pong rest endpoint. given() .when().get(PING_ENDPOINT) @@ -45,7 +45,7 @@ public void testServerClientTrace() throws InterruptedException { .contentType(MediaType.SERVER_SENT_EVENTS) .body(containsString("ping pong")); - // Then both ping and pong rest endpoints should have the same trace Id. + // Then both ping and pong rest endpoints should have the same trace ID. String pingTraceId = given() .when().get(PING_ENDPOINT + "/lastTraceId") .then().statusCode(HttpStatus.SC_OK).and().extract().asString(); diff --git a/nosql-db/elasticsearch/src/main/java/io/quarkus/ts/elasticsearch/DataTypesService.java b/nosql-db/elasticsearch/src/main/java/io/quarkus/ts/elasticsearch/DataTypesService.java index 0c27b3b86..496f8353e 100644 --- a/nosql-db/elasticsearch/src/main/java/io/quarkus/ts/elasticsearch/DataTypesService.java +++ b/nosql-db/elasticsearch/src/main/java/io/quarkus/ts/elasticsearch/DataTypesService.java @@ -31,7 +31,6 @@ public DataTypes indexAndGet(DataTypes dataTypes) throws IOException { String responseBody = EntityUtils.toString(response.getEntity()); JsonObject json = new JsonObject(responseBody); - DataTypes dataTypesRet = json.getJsonObject("_source").mapTo(DataTypes.class); - return dataTypesRet; + return json.getJsonObject("_source").mapTo(DataTypes.class); } } diff --git a/nosql-db/elasticsearch/src/test/java/io/quarkus/ts/elasticsearch/DevModeElasticsearchIT.java b/nosql-db/elasticsearch/src/test/java/io/quarkus/ts/elasticsearch/DevModeElasticsearchIT.java index d88361f1a..a2563fef3 100644 --- a/nosql-db/elasticsearch/src/test/java/io/quarkus/ts/elasticsearch/DevModeElasticsearchIT.java +++ b/nosql-db/elasticsearch/src/test/java/io/quarkus/ts/elasticsearch/DevModeElasticsearchIT.java @@ -1,6 +1,5 @@ package io.quarkus.ts.elasticsearch; -import static io.restassured.RestAssured.given; import static org.awaitility.Awaitility.await; import static org.hamcrest.CoreMatchers.containsString; diff --git a/nosql-db/elasticsearch/src/test/java/io/quarkus/ts/elasticsearch/ElasticsearchIT.java b/nosql-db/elasticsearch/src/test/java/io/quarkus/ts/elasticsearch/ElasticsearchIT.java index a10727734..7abbba52f 100644 --- a/nosql-db/elasticsearch/src/test/java/io/quarkus/ts/elasticsearch/ElasticsearchIT.java +++ b/nosql-db/elasticsearch/src/test/java/io/quarkus/ts/elasticsearch/ElasticsearchIT.java @@ -4,6 +4,7 @@ import static org.awaitility.Awaitility.await; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.is; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.Date; import java.util.List; @@ -11,7 +12,6 @@ import java.util.concurrent.TimeUnit; import org.apache.http.HttpStatus; -import org.junit.Assert; import org.junit.jupiter.api.Test; import io.quarkus.test.bootstrap.DefaultService; @@ -106,7 +106,7 @@ void dataTypesCheck() { .statusCode(HttpStatus.SC_OK); DataTypes returnedFooDataTypes = response.getBody().as(DataTypes.class); - Assert.assertEquals(fooDataTypes, returnedFooDataTypes); + assertEquals(fooDataTypes, returnedFooDataTypes); } @Test diff --git a/nosql-db/infinispan/src/main/java/io/quarkus/ts/infinispan/client/InfinispanClientApp.java b/nosql-db/infinispan/src/main/java/io/quarkus/ts/infinispan/client/InfinispanClientApp.java index dec129f06..6488a8980 100644 --- a/nosql-db/infinispan/src/main/java/io/quarkus/ts/infinispan/client/InfinispanClientApp.java +++ b/nosql-db/infinispan/src/main/java/io/quarkus/ts/infinispan/client/InfinispanClientApp.java @@ -13,7 +13,7 @@ import org.infinispan.client.hotrod.event.ClientCacheEntryCreatedEvent; import org.infinispan.client.hotrod.event.ClientCacheEntryModifiedEvent; import org.infinispan.client.hotrod.event.ClientCacheEntryRemovedEvent; -import org.infinispan.commons.configuration.XMLStringConfiguration; +import org.infinispan.commons.configuration.StringConfiguration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,7 +34,7 @@ public class InfinispanClientApp { void onStart(@Observes StartupEvent ev) { LOGGER.info("Create or get cache named mycache with the default configuration"); RemoteCache cache = cacheManager.administration().getOrCreateCache("mycache", - new XMLStringConfiguration(String.format(MYCACHE_CACHE_CONFIG, "mycache"))); + new StringConfiguration(String.format(MYCACHE_CACHE_CONFIG, "mycache"))); cache.addClientListener(new EventPrintListener()); if (cache.isEmpty()) { cache.put("counter", 0); diff --git a/nosql-db/mongodb-reactive/src/main/java/io/quarkus/ts/nosqldb/mongodb/reactive/Fruit.java b/nosql-db/mongodb-reactive/src/main/java/io/quarkus/ts/nosqldb/mongodb/reactive/Fruit.java index af6b67cea..d0e740aa4 100644 --- a/nosql-db/mongodb-reactive/src/main/java/io/quarkus/ts/nosqldb/mongodb/reactive/Fruit.java +++ b/nosql-db/mongodb-reactive/src/main/java/io/quarkus/ts/nosqldb/mongodb/reactive/Fruit.java @@ -36,12 +36,10 @@ public void setDescription(String description) { @Override public boolean equals(Object obj) { - if (!(obj instanceof Fruit)) { + if (!(obj instanceof Fruit other)) { return false; } - Fruit other = (Fruit) obj; - return Objects.equals(other.name, this.name); } diff --git a/nosql-db/mongodb/src/main/java/io/quarkus/ts/nosqldb/mongodb/Fruit.java b/nosql-db/mongodb/src/main/java/io/quarkus/ts/nosqldb/mongodb/Fruit.java index 6df33e9bc..de46d6ff1 100644 --- a/nosql-db/mongodb/src/main/java/io/quarkus/ts/nosqldb/mongodb/Fruit.java +++ b/nosql-db/mongodb/src/main/java/io/quarkus/ts/nosqldb/mongodb/Fruit.java @@ -36,12 +36,10 @@ public void setDescription(String description) { @Override public boolean equals(Object obj) { - if (!(obj instanceof Fruit)) { + if (!(obj instanceof Fruit other)) { return false; } - Fruit other = (Fruit) obj; - return Objects.equals(other.name, this.name); }