From 3d22ce5bf3352b2463600583ca272c1845843207 Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Mon, 1 Aug 2022 15:23:54 +0300 Subject: [PATCH] Replace InputStream bytes with InputStream.readAllBytes in Spring Cloud Config client This not only results is less code, but it's also more efficient as it generally results in less array copying --- .../client/runtime/VertxSpringCloudConfigGateway.java | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/extensions/spring-cloud-config-client/runtime/src/main/java/io/quarkus/spring/cloud/config/client/runtime/VertxSpringCloudConfigGateway.java b/extensions/spring-cloud-config-client/runtime/src/main/java/io/quarkus/spring/cloud/config/client/runtime/VertxSpringCloudConfigGateway.java index 30a1c78588211..fee1dc0966d97 100644 --- a/extensions/spring-cloud-config-client/runtime/src/main/java/io/quarkus/spring/cloud/config/client/runtime/VertxSpringCloudConfigGateway.java +++ b/extensions/spring-cloud-config-client/runtime/src/main/java/io/quarkus/spring/cloud/config/client/runtime/VertxSpringCloudConfigGateway.java @@ -2,7 +2,6 @@ import static io.vertx.core.spi.resolver.ResolverProvider.DISABLE_DNS_RESOLVER_PROP_NAME; -import java.io.ByteArrayOutputStream; import java.io.InputStream; import java.net.URI; import java.net.URISyntaxException; @@ -168,14 +167,7 @@ private static byte[] storeBytes(Path keyStorePath) } private static byte[] allBytes(InputStream inputStream) throws Exception { - ByteArrayOutputStream buffer = new ByteArrayOutputStream(); - int nRead; - byte[] data = new byte[1024]; - while ((nRead = inputStream.read(data, 0, data.length)) != -1) { - buffer.write(data, 0, nRead); - } - buffer.flush(); - return buffer.toByteArray(); + return inputStream.readAllBytes(); } private URI determineBaseUri(SpringCloudConfigClientConfig springCloudConfigClientConfig) throws URISyntaxException {