You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by "fabriziofortino (via GitHub)" <gi...@apache.org> on 2023/04/11 09:04:25 UTC

[GitHub] [jackrabbit-oak] fabriziofortino commented on a diff in pull request #893: OAK-10182: use streams to avoid buffer positioning issues leading to corrupted files

fabriziofortino commented on code in PR #893:
URL: https://github.com/apache/jackrabbit-oak/pull/893#discussion_r1162515105


##########
oak-run/src/main/java/org/apache/jackrabbit/oak/run/Downloader.java:
##########
@@ -175,19 +172,18 @@ public ItemResponse call() throws Exception {
 
             Path destinationPath = Paths.get(item.destination);
             Files.createDirectories(destinationPath.getParent());
+
             long size = 0;
-            try (ReadableByteChannel byteChannel = Channels.newChannel(sourceUrl.getInputStream());
-                 FileChannel outputChannel = FileChannel.open(destinationPath, StandardOpenOption.CREATE, StandardOpenOption.WRITE)) {
-                ByteBuffer buffer = ByteBuffer.allocate(bufferSize);
+            try (InputStream inputStream = sourceUrl.getInputStream();
+                 FileOutputStream outputStream = new FileOutputStream(destinationPath.toFile())) {

Review Comment:
   I have not tested it. But I have compared this solution with the previous one based on channels and there is no performance degradation when checksum is not enabled.



-- 
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: dev-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org