Skip to content

Commit

Permalink
Replace InputStream bytes with InputStream.readAllBytes in Spring Clo…
Browse files Browse the repository at this point in the history
…ud Config client

This not only results 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 34f683a commit 3d22ce5
Showing 1 changed file with 1 addition and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 3d22ce5

Please sign in to comment.