nodece commented on code in PR #25211:
URL: https://github.com/apache/pulsar/pull/25211#discussion_r2767880003
##########
pulsar-package-management/core/src/test/java/org/apache/pulsar/packages/management/core/MockedPackagesStorage.java:
##########
@@ -45,8 +46,13 @@ public CompletableFuture<Void> writeAsync(String path,
InputStream inputStream)
CompletableFuture<Void> future = new CompletableFuture<>();
CompletableFuture.runAsync(() -> {
try {
- byte[] bytes = new byte[inputStream.available()];
- inputStream.read(bytes);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ byte[] buffer = new byte[8192];
+ int read;
+ while ((read = inputStream.read(buffer)) != -1) {
+ baos.write(buffer, 0, read);
+ }
+ byte[] bytes = baos.toByteArray();
storage.put(path, bytes);
Review Comment:
This is a better way. Given that this is only used in a test class, the
current implementation should be fine.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]