You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2022/06/22 18:18:52 UTC

[GitHub] [kafka] MPeli commented on a diff in pull request #12331: KAFKA-1194: changes needed to run on Windows

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 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-unsubscribe@kafka.apache.org

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