MPeli commented on code in PR #12331:
URL: https://github.com/apache/kafka/pull/12331#discussion_r904097378


##########
clients/src/main/java/org/apache/kafka/common/record/FileRecords.java:
##########
@@ -461,14 +461,15 @@ private static FileChannel openChannel(File file,
                                            int initFileSize,
                                            boolean preallocate) throws 
IOException {
         if (mutable) {
-            if (fileAlreadyExists || !preallocate) {
-                return FileChannel.open(file.toPath(), 
StandardOpenOption.CREATE, StandardOpenOption.READ,
-                        StandardOpenOption.WRITE);
-            } else {
-                RandomAccessFile randomAccessFile = new RandomAccessFile(file, 
"rw");
-                randomAccessFile.setLength(initFileSize);
-                return randomAccessFile.getChannel();
+            if (preallocate && !fileAlreadyExists) {
+                try (RandomAccessFile randomAccessFile = new 
RandomAccessFile(file, "rw")) {

Review Comment:
   Thank you, I replaced `RandomAccessFile.setLength()` with 
`SeekableByteChannel`.



-- 
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: jira-unsubscr...@kafka.apache.org

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

Reply via email to