From 5026a2d6262e7d34da415f72db739ebec74b8e44 Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Mon, 1 Aug 2022 14:17:15 +0300 Subject: [PATCH] Replace InputStream bytes with InputStream.readAllBytes in Vert.x This not only is less code, but it's also more efficient as it generally results in less array copying --- .../io/quarkus/vertx/http/runtime/VertxHttpRecorder.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java index f31d110c4f606..1b83d98176840 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java @@ -3,7 +3,6 @@ import static io.quarkus.vertx.core.runtime.context.VertxContextSafetyToggle.setContextSafe; import static io.quarkus.vertx.core.runtime.context.VertxContextSafetyToggle.setCurrentContextSafe; -import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -998,13 +997,7 @@ private static String findKeystoreFileType(Path storePath) { } private static byte[] doRead(InputStream is) throws IOException { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - byte[] buf = new byte[1024]; - int r; - while ((r = is.read(buf)) > 0) { - out.write(buf, 0, r); - } - return out.toByteArray(); + return is.readAllBytes(); } private static HttpServerOptions createHttpServerOptions(