Retain RandomAccessFile in JournalSegmentFile
[controller.git] / atomix-storage / src / main / java / io / atomix / storage / journal / DiskFileReader.java
index 697604e60069d962f2b567877e01f409745a493f..a934a903085c28f76a06f504610ec0ee1f63be6d 100644 (file)
@@ -16,7 +16,6 @@
 package io.atomix.storage.journal;
 
 import static com.google.common.base.Verify.verify;
-import static java.util.Objects.requireNonNull;
 
 import java.io.IOException;
 import java.nio.ByteBuffer;
@@ -38,14 +37,14 @@ final class DiskFileReader extends FileReader {
     // tracks where memory's first available byte maps to in terms of FileChannel.position()
     private int bufferPosition;
 
-    DiskFileReader(final JournalSegmentFile file, final FileChannel channel, final int maxEntrySize) {
-        this(file, channel, allocateBuffer(file.maxSize(), maxEntrySize));
+    DiskFileReader(final JournalSegmentFile file, final int maxEntrySize) {
+        this(file, allocateBuffer(file.maxSize(), maxEntrySize));
     }
 
     // Note: take ownership of the buffer
-    DiskFileReader(final JournalSegmentFile file, final FileChannel channel, final ByteBuffer buffer) {
+    DiskFileReader(final JournalSegmentFile file, final ByteBuffer buffer) {
         super(file);
-        this.channel = requireNonNull(channel);
+        channel = file.channel();
         this.buffer = buffer.flip();
         bufferPosition = 0;
     }