diff --git a/http/grpc/src/main/java/io/quarkus/ts/http/grpc/HttpReflectionResource.java b/http/grpc/src/main/java/io/quarkus/ts/http/grpc/HttpReflectionResource.java index c98cb1559..8c383c759 100644 --- a/http/grpc/src/main/java/io/quarkus/ts/http/grpc/HttpReflectionResource.java +++ b/http/grpc/src/main/java/io/quarkus/ts/http/grpc/HttpReflectionResource.java @@ -33,13 +33,11 @@ public Uni reflectionServiceInfo() { .setListServices("").build(); Uni serverReflectionResponse = invoke(request); - Uni grpcReflectionResponse = serverReflectionResponse.map(response -> { + return serverReflectionResponse.map(response -> { int serviceCount = response.getListServicesResponse().getServiceCount(); List reflectionServiceList = getReflectionServiceList(response); return new GrpcReflectionResponse(serviceCount, reflectionServiceList); }); - - return grpcReflectionResponse; } @GET diff --git a/http/grpc/src/test/java/io/quarkus/ts/http/grpc/GrpcMutualTlsSeparateServerIT.java b/http/grpc/src/test/java/io/quarkus/ts/http/grpc/GrpcMutualTlsSeparateServerIT.java index 2bf897f49..a709f8318 100644 --- a/http/grpc/src/test/java/io/quarkus/ts/http/grpc/GrpcMutualTlsSeparateServerIT.java +++ b/http/grpc/src/test/java/io/quarkus/ts/http/grpc/GrpcMutualTlsSeparateServerIT.java @@ -1,6 +1,5 @@ package io.quarkus.ts.http.grpc; -import static io.quarkus.test.security.certificate.CertificateBuilder.INSTANCE_KEY; import static io.quarkus.test.services.Certificate.Format.PEM; import org.junit.jupiter.api.Tag; diff --git a/http/http-advanced-reactive/src/main/java/io/quarkus/ts/http/advanced/reactive/CityResource.java b/http/http-advanced-reactive/src/main/java/io/quarkus/ts/http/advanced/reactive/CityResource.java index 6618725d1..ee5761abb 100644 --- a/http/http-advanced-reactive/src/main/java/io/quarkus/ts/http/advanced/reactive/CityResource.java +++ b/http/http-advanced-reactive/src/main/java/io/quarkus/ts/http/advanced/reactive/CityResource.java @@ -70,9 +70,7 @@ public String createCity(CityListDTO cityListDTO) { .build().toString(); } - String responseXML = serializer.toXML(cityListDTO); - - return responseXML; + return serializer.toXML(cityListDTO); } @POST @@ -94,13 +92,13 @@ public Response handleDTOYamlPostRequest(CityListDTO cityListDTO) { @GET @Path("/getYamlFile") @Produces("application/yaml") - public Response getYamlFile() throws IOException { + public Response getYamlFile() { try { CityListDTO cityListDTO = readYamlFile(YAML_FILE_PATH); if (cityListDTO != null) { - LOG.info("content ----! " + cityListDTO.toString()); + LOG.info("content ----! " + cityListDTO); return Response.ok(cityListDTO).build(); } else { return Response.status(Response.Status.INTERNAL_SERVER_ERROR) diff --git a/http/http-advanced-reactive/src/main/java/io/quarkus/ts/http/advanced/reactive/DownloadResource.java b/http/http-advanced-reactive/src/main/java/io/quarkus/ts/http/advanced/reactive/DownloadResource.java index 833d6d25c..58e344e07 100644 --- a/http/http-advanced-reactive/src/main/java/io/quarkus/ts/http/advanced/reactive/DownloadResource.java +++ b/http/http-advanced-reactive/src/main/java/io/quarkus/ts/http/advanced/reactive/DownloadResource.java @@ -24,7 +24,7 @@ public class DownloadResource { private static final Logger LOGGER = LoggerFactory.getLogger(DownloadResource.class); private static final String TEST_FILE = System.getProperty("java.io.tmpdir") + - File.separator + "DownloadResource-" + UUID.randomUUID().toString() + "-test.txt"; + File.separator + "DownloadResource-" + UUID.randomUUID() + "-test.txt"; private static final OpenOptions READ_ONLY = new OpenOptions().setWrite(false).setCreate(false); @Inject diff --git a/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/AbstractDevModeIT.java b/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/AbstractDevModeIT.java index ddf856787..11486aa55 100644 --- a/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/AbstractDevModeIT.java +++ b/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/AbstractDevModeIT.java @@ -5,7 +5,6 @@ import java.io.IOException; import java.nio.file.Files; import java.util.List; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.htmlunit.WebClient; @@ -67,7 +66,7 @@ public void uiChange() throws IOException { .lines(app.getServiceFolder().resolve("src/main/resources/application.properties"))) { List properties = lines .filter(line -> line.contains(PROPERTY)) - .collect(Collectors.toList()); + .toList(); if (properties.size() != 1) { LOG.warn("There should be only one property with name " + PROPERTY + ", but found these " + properties); } diff --git a/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/BaseHttpAdvancedReactiveIT.java b/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/BaseHttpAdvancedReactiveIT.java index 8cb618574..c9aa660d3 100644 --- a/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/BaseHttpAdvancedReactiveIT.java +++ b/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/BaseHttpAdvancedReactiveIT.java @@ -147,7 +147,7 @@ public void nonAppRedirections() { } @Test - public void microprofileHttpClientRedirection() throws Exception { + public void microprofileHttpClientRedirection() { io.restassured.response.Response health = getApp().given().get("api/client"); assertEquals(HttpStatus.SC_OK, health.statusCode()); } diff --git a/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/Brotli4JHttpIT.java b/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/Brotli4JHttpIT.java index 71e168de7..a61ea9819 100644 --- a/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/Brotli4JHttpIT.java +++ b/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/Brotli4JHttpIT.java @@ -58,17 +58,17 @@ public void checkTextPlainDefaultWithoutBrotli4JEncoding() { } @Test - public void checkTextPlainWithtBrotli4J() { - int textPlainDataLenght = calculateTextLength("/sample.txt"); + public void checkTextPlainWithBrotli4J() { + int textPlainDataLength = calculateTextLength("/sample.txt"); assertBrotli4JCompression("/compression/text", MediaType.TEXT_PLAIN, BROTLI_ENCODING, BROTLI_ENCODING, - textPlainDataLenght); + textPlainDataLength); } @Test - public void checkBigTextPlainWithtBrotli4J() { - int textPlainDataLenght = calculateTextLength("/big_sample.txt"); + public void checkBigTextPlainWithBrotli4J() { + int textPlainDataLength = calculateTextLength("/big_sample.txt"); assertBrotli4JCompression("/compression/text/big", MediaType.TEXT_PLAIN, BROTLI_ENCODING, BROTLI_ENCODING, - textPlainDataLenght); + textPlainDataLength); } @Test diff --git a/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/DownloadResourceIT.java b/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/DownloadResourceIT.java index 1d190f89e..838484702 100644 --- a/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/DownloadResourceIT.java +++ b/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/DownloadResourceIT.java @@ -1,13 +1,12 @@ package io.quarkus.ts.http.advanced.reactive; -import static io.restassured.RestAssured.given; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.stream.Collectors; -import org.junit.Assert; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.DisabledOnOs; import org.junit.jupiter.api.condition.OS; @@ -52,7 +51,7 @@ void ensureAsyncFileGetsClosed() throws IOException { .then() .statusCode(204); - Assert.assertEquals("AsyncFile is not closed, details:\n" + lsofOutput + "\n", 0, lsofOutput.length()); + assertEquals(0, lsofOutput.length(), "AsyncFile is not closed, details:\n" + lsofOutput + "\n"); } } diff --git a/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/NonJsonPayLoadIT.java b/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/NonJsonPayLoadIT.java index 5e79a2b4b..ed2c82abf 100644 --- a/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/NonJsonPayLoadIT.java +++ b/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/NonJsonPayLoadIT.java @@ -15,7 +15,6 @@ import java.util.Map; import jakarta.ws.rs.core.MediaType; -import jakarta.xml.bind.JAXBException; import org.apache.commons.io.IOUtils; import org.apache.http.HttpStatus; @@ -67,7 +66,7 @@ public void testExpectedXmlResponse() { } @Test - public void testXMLPayloadPostRequest() throws JAXBException { + public void testXMLPayloadPostRequest() { City city = new City("Paris", "France"); List cityList = new ArrayList<>(); diff --git a/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/brotli4j/Brotli4JResource.java b/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/brotli4j/Brotli4JResource.java index a7271957f..b01b04ba0 100644 --- a/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/brotli4j/Brotli4JResource.java +++ b/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/brotli4j/Brotli4JResource.java @@ -38,8 +38,7 @@ public String xmlHttpCompressionResponse() { @Path("/decompression") @Produces(MediaType.TEXT_PLAIN) public String decompressionHttpResponse(byte[] compressedData) { - String decompressedData = new String(compressedData); - return decompressedData; + return new String(compressedData); } @GET diff --git a/http/http-advanced/src/main/java/io/quarkus/ts/http/advanced/GrpcClientInterceptors.java b/http/http-advanced/src/main/java/io/quarkus/ts/http/advanced/GrpcClientInterceptors.java index 10cc79e47..895d83390 100644 --- a/http/http-advanced/src/main/java/io/quarkus/ts/http/advanced/GrpcClientInterceptors.java +++ b/http/http-advanced/src/main/java/io/quarkus/ts/http/advanced/GrpcClientInterceptors.java @@ -39,7 +39,7 @@ abstract static class Base implements ClientInterceptor { public ClientCall interceptCall(MethodDescriptor method, CallOptions options, Channel next) { String interceptedTarget = getClass().getName(); - return new ForwardingClientCall.SimpleForwardingClientCall(next.newCall(method, options)) { + return new ForwardingClientCall.SimpleForwardingClientCall<>(next.newCall(method, options)) { @Override public void start(Listener responseListener, Metadata headers) { if (interceptedTarget.contains("MethodTarget")) { diff --git a/http/http-advanced/src/main/java/io/quarkus/ts/http/advanced/GrpcServerInterceptors.java b/http/http-advanced/src/main/java/io/quarkus/ts/http/advanced/GrpcServerInterceptors.java index d92a03607..5636d2fd3 100644 --- a/http/http-advanced/src/main/java/io/quarkus/ts/http/advanced/GrpcServerInterceptors.java +++ b/http/http-advanced/src/main/java/io/quarkus/ts/http/advanced/GrpcServerInterceptors.java @@ -39,7 +39,7 @@ abstract static class Base implements ServerInterceptor { @Override public ServerCall.Listener interceptCall(ServerCall call, Metadata metadata, ServerCallHandler next) { - Context ctx = null; + Context ctx; String interceptedTarget = getClass().getName(); // Determine where was grpc call intercepted and put client side intercepted data to Context. if (interceptedTarget.contains("MethodTarget")) { diff --git a/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/DomainSocketIT.java b/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/DomainSocketIT.java index 6bcf8d73c..f61fc7076 100644 --- a/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/DomainSocketIT.java +++ b/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/DomainSocketIT.java @@ -46,7 +46,7 @@ public void ensureApplicationStartsWithDomainSocketConfigured() { } @Test - public void ensureApplicationProvidesContent() throws InterruptedException { + public void ensureApplicationProvidesContent() { Vertx vertx = Vertx.vertx(new VertxOptions().setPreferNativeTransport(true)); WebClient client = WebClient.create(vertx, new WebClientOptions().setFollowRedirects(false)); SocketAddress serverAddress = SocketAddress.domainSocketAddress("/tmp/io.quarkus.app.socket"); diff --git a/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/GzipMaxInputIT.java b/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/GzipMaxInputIT.java index d08e03ec9..e6c6c9c3d 100644 --- a/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/GzipMaxInputIT.java +++ b/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/GzipMaxInputIT.java @@ -74,7 +74,7 @@ void sendInvalidContent() { } @Test - void sendZeroBytesPayload() throws IOException { + void sendZeroBytesPayload() { ByteArrayInputStream compressedData = generateCompressedDataStream(0); Response response = sendDataToGzipEndpoint(compressedData); assertEquals(HttpStatus.SC_OK, response.statusCode(), @@ -82,7 +82,7 @@ void sendZeroBytesPayload() throws IOException { } @Test - void sendPayloadBelowMaxInputLimit() throws IOException { + void sendPayloadBelowMaxInputLimit() { ByteArrayInputStream compressedData = generateCompressedDataStream(SMALL_PAYLOAD); Response response = sendDataToGzipEndpoint(compressedData); assertEquals(HttpStatus.SC_OK, response.statusCode(), @@ -91,7 +91,7 @@ void sendPayloadBelowMaxInputLimit() throws IOException { @Tag("https://github.com/quarkusio/quarkus/issues/39636") @Test - void sendMaximumAllowedPayload() throws IOException { + void sendMaximumAllowedPayload() { ByteArrayInputStream compressedData = generateCompressedDataStream(LIMIT_PAYLOAD); Response response = sendDataToGzipEndpoint(compressedData); assertEquals(HttpStatus.SC_OK, response.statusCode(), @@ -101,7 +101,7 @@ void sendMaximumAllowedPayload() throws IOException { } @Test - void sendMoreThanMaximumAllowedPayload() throws IOException { + void sendMoreThanMaximumAllowedPayload() { ByteArrayInputStream compressedData = generateCompressedDataStream(OVER_LIMIT_PAYLOAD); Response response = sendDataToGzipEndpoint(compressedData); assertEquals(HttpStatus.SC_REQUEST_TOO_LONG, response.statusCode(), diff --git a/http/http-static/src/test/java/io/quarkus/ts/httpstatic/GenerateLargeFile.java b/http/http-static/src/test/java/io/quarkus/ts/http/GenerateLargeFile.java similarity index 92% rename from http/http-static/src/test/java/io/quarkus/ts/httpstatic/GenerateLargeFile.java rename to http/http-static/src/test/java/io/quarkus/ts/http/GenerateLargeFile.java index 165e3ae40..863858dd1 100644 --- a/http/http-static/src/test/java/io/quarkus/ts/httpstatic/GenerateLargeFile.java +++ b/http/http-static/src/test/java/io/quarkus/ts/http/GenerateLargeFile.java @@ -11,7 +11,7 @@ private GenerateLargeFile() { public static void main(String[] args) throws Exception { // args[0] is expected to be something like {path to repository}/http/http-static/target/classes - try (RandomAccessFile f = new RandomAccessFile(args[0] + "/META-INF/resources/big-file", "rw");) { + try (RandomAccessFile f = new RandomAccessFile(args[0] + "/META-INF/resources/big-file", "rw")) { f.setLength(HALF_GIGABYTE); } } diff --git a/http/http-static/src/test/java/io/quarkus/ts/httpstatic/LargeStaticResourceIT.java b/http/http-static/src/test/java/io/quarkus/ts/http/LargeStaticResourceIT.java similarity index 100% rename from http/http-static/src/test/java/io/quarkus/ts/httpstatic/LargeStaticResourceIT.java rename to http/http-static/src/test/java/io/quarkus/ts/http/LargeStaticResourceIT.java diff --git a/http/jakarta-rest-reactive/src/main/java/io/quarkus/ts/http/jakartarest/reactive/CompressionResource.java b/http/jakarta-rest-reactive/src/main/java/io/quarkus/ts/http/jakartarest/reactive/CompressionResource.java index 6c02eb5a9..799fb227d 100644 --- a/http/jakarta-rest-reactive/src/main/java/io/quarkus/ts/http/jakartarest/reactive/CompressionResource.java +++ b/http/jakarta-rest-reactive/src/main/java/io/quarkus/ts/http/jakartarest/reactive/CompressionResource.java @@ -131,7 +131,7 @@ public Uni forceNoCompression(RoutingContext rc) { @Path("/big/payload") @Compressed public Uni bigCompression(@RestQuery("bodyCharSize") String bodyCharSize) { - byte[] payload = new byte[Integer.valueOf(bodyCharSize)]; + byte[] payload = new byte[Integer.parseInt(bodyCharSize)]; new Random().nextBytes(payload); LOG.info("Big compression payload generated."); return Uni.createFrom().item(payload); diff --git a/http/jakarta-rest/src/main/java/io/quarkus/ts/http/jakartarest/MultipartResource.java b/http/jakarta-rest/src/main/java/io/quarkus/ts/http/jakartarest/MultipartResource.java index b1b09ddb6..4d238291e 100644 --- a/http/jakarta-rest/src/main/java/io/quarkus/ts/http/jakartarest/MultipartResource.java +++ b/http/jakarta-rest/src/main/java/io/quarkus/ts/http/jakartarest/MultipartResource.java @@ -50,7 +50,7 @@ public byte[] postFormReturnData(@MultipartForm MultipartBody multipartBody) thr @Path("/echo") @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces(MediaType.TEXT_PLAIN) - public String echo(String requestBody) throws Exception { + public String echo(String requestBody) { return requestBody; } } diff --git a/http/reactive-routes/src/test/java/io/quarkus/ts/http/reactiveroutes/validation/utils/ValidationAssertions.java b/http/reactive-routes/src/test/java/io/quarkus/ts/http/reactiveroutes/validation/utils/ValidationAssertions.java index dd0eb8dfd..319197733 100644 --- a/http/reactive-routes/src/test/java/io/quarkus/ts/http/reactiveroutes/validation/utils/ValidationAssertions.java +++ b/http/reactive-routes/src/test/java/io/quarkus/ts/http/reactiveroutes/validation/utils/ValidationAssertions.java @@ -4,7 +4,6 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import java.util.List; -import java.util.stream.Collectors; import java.util.stream.Stream; public class ValidationAssertions { @@ -31,7 +30,7 @@ public static final void assertValidationErrorCount(ValidationErrorResponse resp public static final void assertValidationErrorField(ValidationErrorResponse response, String fieldName, String message) { List violations = Stream.of(response.getViolations()).filter(v -> fieldName.equals(v.getField())) - .collect(Collectors.toList()); + .toList(); assertFalse(violations.isEmpty(), "No violations found for field: " + fieldName); assertEquals(1, violations.size(), "More than one violation found for field: " + fieldName); assertEquals(message, violations.get(0).getMessage()); diff --git a/http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/fault/tolerance/RequestIdContainerRequestFilter.java b/http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/fault/tolerance/RequestIdContainerRequestFilter.java index e68d5df48..f746c6e3b 100644 --- a/http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/fault/tolerance/RequestIdContainerRequestFilter.java +++ b/http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/fault/tolerance/RequestIdContainerRequestFilter.java @@ -33,7 +33,7 @@ public class RequestIdContainerRequestFilter implements ContainerRequestFilter { public void filter(ContainerRequestContext requestContext) { MultivaluedMap headers = requestContext.getHeaders(); if (headers.containsKey("REQUEST_ID")) { - int requestId = Integer.valueOf(headers.getFirst("REQUEST_ID")); + int requestId = Integer.parseInt(headers.getFirst("REQUEST_ID")); requestIdManagerImpl.overrideRequestId(requestId); } diff --git a/http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/files/JavaUtils.java b/http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/files/JavaUtils.java new file mode 100644 index 000000000..fe0ce8e38 --- /dev/null +++ b/http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/files/JavaUtils.java @@ -0,0 +1,41 @@ +package io.quarkus.ts.http.restclient.reactive.files; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.io.RandomAccessFile; +import java.nio.file.Files; +import java.nio.file.Path; +import java.security.DigestOutputStream; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +import jakarta.xml.bind.DatatypeConverter; + +class JavaUtils extends OsUtils { + + @Override + public String getSum(Path path) { + try { + final MessageDigest digest = MessageDigest.getInstance("MD5"); + try (BufferedInputStream stream = new BufferedInputStream(Files.newInputStream(path))) { + DigestOutputStream digestStream = new DigestOutputStream(OutputStream.nullOutputStream(), digest); + stream.transferTo(digestStream); + return DatatypeConverter.printHexBinary(digest.digest()).toLowerCase(); + } catch (IOException e) { + throw new IllegalStateException(e); + } + } catch (NoSuchAlgorithmException e) { + throw new IllegalStateException(e); + } + } + + @Override + public void createFile(Path path, long size) { + try (RandomAccessFile f = new RandomAccessFile(path.toAbsolutePath().toString(), "rw")) { + f.setLength(size); + } catch (IOException e) { + throw new IllegalStateException(e); + } + } +} diff --git a/http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/files/OsUtils.java b/http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/files/OsUtils.java index 68c283984..567ad6ada 100644 --- a/http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/files/OsUtils.java +++ b/http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/files/OsUtils.java @@ -1,16 +1,6 @@ package io.quarkus.ts.http.restclient.reactive.files; -import java.io.BufferedInputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.io.RandomAccessFile; -import java.nio.file.Files; import java.nio.file.Path; -import java.security.DigestOutputStream; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; - -import jakarta.xml.bind.DatatypeConverter; public abstract class OsUtils { public static final long SIZE_2049MiB = 2148532224L; @@ -23,31 +13,3 @@ public static OsUtils get() { return new JavaUtils(); } } - -class JavaUtils extends OsUtils { - - @Override - public String getSum(Path path) { - try { - final MessageDigest digest = MessageDigest.getInstance("MD5"); - try (BufferedInputStream stream = new BufferedInputStream(Files.newInputStream(path))) { - DigestOutputStream digestStream = new DigestOutputStream(OutputStream.nullOutputStream(), digest); - stream.transferTo(digestStream); - return DatatypeConverter.printHexBinary(digest.digest()).toLowerCase(); - } catch (IOException e) { - throw new IllegalStateException(e); - } - } catch (NoSuchAlgorithmException e) { - throw new IllegalStateException(e); - } - } - - @Override - public void createFile(Path path, long size) { - try (RandomAccessFile f = new RandomAccessFile(path.toAbsolutePath().toString(), "rw");) { - f.setLength(size); - } catch (IOException e) { - throw new IllegalStateException(e); - } - } -} diff --git a/http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/filter/VersionHeaderFilter.java b/http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/filter/VersionHeaderFilter.java index 651adc3b7..91790b9a5 100644 --- a/http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/filter/VersionHeaderFilter.java +++ b/http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/filter/VersionHeaderFilter.java @@ -1,7 +1,5 @@ package io.quarkus.ts.http.restclient.reactive.filter; -import java.io.IOException; - import jakarta.ws.rs.client.ClientRequestContext; import jakarta.ws.rs.client.ClientRequestFilter; import jakarta.ws.rs.container.ContainerRequestContext; @@ -25,7 +23,7 @@ public void filter(ContainerRequestContext requestContext, ContainerResponseCont } @Override - public void filter(ClientRequestContext requestContext) throws IOException { + public void filter(ClientRequestContext requestContext) { requestContext.getHeaders().add("clientFilter", "clientFilterInvoked"); } } diff --git a/http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/resources/ReactiveClientBookResource.java b/http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/resources/ReactiveClientBookResource.java index e67f269d0..d4c24431d 100644 --- a/http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/resources/ReactiveClientBookResource.java +++ b/http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/resources/ReactiveClientBookResource.java @@ -103,20 +103,14 @@ public Uni> getRestQuery() { @Produces(MediaType.APPLICATION_JSON) public Uni getSuffixed(@QueryParam("content") String text, @PathParam("type") String type) { - switch (type) { - case "complete": - return bookInterface.getCompleteType(text); - case "subtype": - return bookInterface.getWithSubType(text); - case "suffix": - return bookInterface.getWithSuffix(text); - case "other": - return bookInterface.getUnrelated(text); - case "priority": - return bookInterface.getPriorities(text); - default: - throw new IllegalStateException("Unexpected value: " + type); - } + return switch (type) { + case "complete" -> bookInterface.getCompleteType(text); + case "subtype" -> bookInterface.getWithSubType(text); + case "suffix" -> bookInterface.getWithSuffix(text); + case "other" -> bookInterface.getUnrelated(text); + case "priority" -> bookInterface.getPriorities(text); + default -> throw new IllegalStateException("Unexpected value: " + type); + }; } @POST diff --git a/http/rest-client-reactive/src/test/java/io/quarkus/ts/http/restclient/reactive/ReactiveRestClientRetryIT.java b/http/rest-client-reactive/src/test/java/io/quarkus/ts/http/restclient/reactive/ReactiveRestClientRetryIT.java index 055aab193..8944dd5f9 100644 --- a/http/rest-client-reactive/src/test/java/io/quarkus/ts/http/restclient/reactive/ReactiveRestClientRetryIT.java +++ b/http/rest-client-reactive/src/test/java/io/quarkus/ts/http/restclient/reactive/ReactiveRestClientRetryIT.java @@ -56,7 +56,7 @@ void shouldPerformRetryOfFailingBlockingClientCall() { .statusCode(500); // Check number of server events, one failing call plus 3 retries by default - Assertions.assertEquals(4, mockServer.getServeEvents().getServeEvents().stream().count()); + Assertions.assertEquals(4, (long) mockServer.getServeEvents().getServeEvents().size()); List> headers = app.given() .get("/fault/headers") diff --git a/http/rest-client/src/test/java/io/quarkus/ts/http/restclient/RestClientIT.java b/http/rest-client/src/test/java/io/quarkus/ts/http/restclient/RestClientIT.java index 497f7a367..d53064215 100644 --- a/http/rest-client/src/test/java/io/quarkus/ts/http/restclient/RestClientIT.java +++ b/http/rest-client/src/test/java/io/quarkus/ts/http/restclient/RestClientIT.java @@ -1,6 +1,5 @@ package io.quarkus.ts.http.restclient; -import static io.restassured.RestAssured.given; import static org.hamcrest.CoreMatchers.is; import org.apache.http.HttpStatus; diff --git a/http/servlet-undertow/src/main/java/io/quarkus/ts/http/undertow/servlets/HelloWorld.java b/http/servlet-undertow/src/main/java/io/quarkus/ts/http/undertow/servlets/HelloWorld.java index d7b9aa730..a4898127f 100644 --- a/http/servlet-undertow/src/main/java/io/quarkus/ts/http/undertow/servlets/HelloWorld.java +++ b/http/servlet-undertow/src/main/java/io/quarkus/ts/http/undertow/servlets/HelloWorld.java @@ -4,7 +4,6 @@ import java.io.PrintWriter; import jakarta.enterprise.context.ApplicationScoped; -import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; @@ -19,7 +18,7 @@ public class HelloWorld extends HttpServlet { private static final String MESSAGE = "Hello World"; @Override - protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { + protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws IOException { LOG.info(req.getSession().getId()); PrintWriter writer = resp.getWriter(); writer.write(MESSAGE); diff --git a/http/servlet-undertow/src/main/java/io/quarkus/ts/http/undertow/servlets/SecuredWorld.java b/http/servlet-undertow/src/main/java/io/quarkus/ts/http/undertow/servlets/SecuredWorld.java index b881e2ee9..c90024576 100644 --- a/http/servlet-undertow/src/main/java/io/quarkus/ts/http/undertow/servlets/SecuredWorld.java +++ b/http/servlet-undertow/src/main/java/io/quarkus/ts/http/undertow/servlets/SecuredWorld.java @@ -5,7 +5,6 @@ import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; -import jakarta.servlet.ServletException; import jakarta.servlet.annotation.HttpConstraint; import jakarta.servlet.annotation.ServletSecurity; import jakarta.servlet.annotation.WebInitParam; @@ -30,7 +29,7 @@ public class SecuredWorld extends HttpServlet { RoutingContext routingContext; @Override - protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { + protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws IOException { LOG.info(req.getSession().getId()); PrintWriter writer = resp.getWriter(); writer.write(routingContext.queryParam("secured-servlet-key").get(0)); diff --git a/http/servlet-undertow/src/test/java/io/quarkus/ts/http/undertow/HttpServletWithSessionListenerIT.java b/http/servlet-undertow/src/test/java/io/quarkus/ts/http/undertow/HttpServletWithSessionListenerIT.java index 582a9eacd..ae0549a98 100644 --- a/http/servlet-undertow/src/test/java/io/quarkus/ts/http/undertow/HttpServletWithSessionListenerIT.java +++ b/http/servlet-undertow/src/test/java/io/quarkus/ts/http/undertow/HttpServletWithSessionListenerIT.java @@ -83,22 +83,20 @@ public void undertowHttp2Servlet(Vertx vertx, VertxTestContext vertxTestContext) .setProtocolVersion(HttpVersion.HTTP_2); httpClient = vertx.createHttpClient(options); vertxTestContext - .verify(() -> { - httpClient - .request(HttpMethod.GET, app.getURI(Protocol.HTTPS).getPort(), app.getURI().getHost(), - "/app/servlet/hello") - .compose(request -> request.send() - .compose(httpClientResponse -> { - requestCheckpoint.flag(); - assertEquals(HttpStatus.SC_OK, httpClientResponse.statusCode()); - assertEquals(HttpVersion.HTTP_2, httpClientResponse.version()); - return httpClientResponse.body(); - })) - .onSuccess(body -> { - assertThat("Body response", body.toString().contains("Hello World")); - requestCheckpoint.flag(); - }).onFailure(throwable -> vertxTestContext.failNow(throwable.getMessage())); - }); + .verify(() -> httpClient + .request(HttpMethod.GET, app.getURI(Protocol.HTTPS).getPort(), app.getURI().getHost(), + "/app/servlet/hello") + .compose(request -> request.send() + .compose(httpClientResponse -> { + requestCheckpoint.flag(); + assertEquals(HttpStatus.SC_OK, httpClientResponse.statusCode()); + assertEquals(HttpVersion.HTTP_2, httpClientResponse.version()); + return httpClientResponse.body(); + })) + .onSuccess(body -> { + assertThat("Body response", body.toString().contains("Hello World")); + requestCheckpoint.flag(); + }).onFailure(throwable -> vertxTestContext.failNow(throwable.getMessage()))); } private double getActiveSessions() { diff --git a/http/vertx-web-client/README.md b/http/vertx-web-client/README.md index 68855beb8..f6e6038c6 100644 --- a/http/vertx-web-client/README.md +++ b/http/vertx-web-client/README.md @@ -12,7 +12,7 @@ To compile and run this demo you will need: ## Scope of the testing -Vert.x Mutiny webClient exploratory test. +Vert.x Mutiny webClient exploratory test. * Vert.x WebClient * Quarkus Resteasy Mutiny / Jsonb * Quarkus configuration converters diff --git a/http/vertx-web-client/src/test/java/io/quarkus/ts/http/vertx/webclient/VertxWebClientIT.java b/http/vertx-web-client/src/test/java/io/quarkus/ts/http/vertx/webclient/VertxWebClientIT.java index 4b2349cc0..3415d930f 100644 --- a/http/vertx-web-client/src/test/java/io/quarkus/ts/http/vertx/webclient/VertxWebClientIT.java +++ b/http/vertx-web-client/src/test/java/io/quarkus/ts/http/vertx/webclient/VertxWebClientIT.java @@ -77,7 +77,7 @@ public void getChuckJokeAsJSON() { @Test @DisplayName("Vert.x WebClient [flavor: mutiny] -> Mapped json response by 'as' mutiny method.") - public void getChuckJokeByJsonBodyCodec() throws InterruptedException { + public void getChuckJokeByJsonBodyCodec() { setupMockHttpServer(); vertx.given() .when() diff --git a/http/vertx/src/test/java/io/quarkus/ts/vertx/AbstractVertxIT.java b/http/vertx/src/test/java/io/quarkus/ts/vertx/AbstractVertxIT.java index 4d39ea0e9..7d9f383f0 100644 --- a/http/vertx/src/test/java/io/quarkus/ts/vertx/AbstractVertxIT.java +++ b/http/vertx/src/test/java/io/quarkus/ts/vertx/AbstractVertxIT.java @@ -24,6 +24,7 @@ import io.vertx.core.Vertx; import io.vertx.core.http.HttpClient; import io.vertx.core.http.HttpClientOptions; +import io.vertx.core.http.HttpClientRequest; import io.vertx.core.http.HttpClientResponse; import io.vertx.core.http.HttpMethod; import io.vertx.core.http.HttpVersion; @@ -109,7 +110,7 @@ public void vertxHttpClientWithNameParameter() { httpClient.request(HttpMethod.GET, service.getPort(), service.getURI(Protocol.NONE).getHost(), "/hello?name=" + jsonObject.getString("name")) - .compose(request -> request.send()) + .compose(HttpClientRequest::send) .compose(HttpClientResponse::body) .onSuccess(body -> { assertThat("Body response", body.toString().contains("Hello, Bender!"));