Skip to content

Commit

Permalink
Replace InputStream bytes with InputStream.readAllBytes in Vert.x
Browse files Browse the repository at this point in the history
This not only is less code, but it's also more efficient as
it generally results in less array copying
  • Loading branch information
geoand committed Aug 1, 2022
1 parent 20280ff commit 5026a2d
Showing 1 changed file with 1 addition and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 5026a2d

Please sign in to comment.