Skip to content

Commit

Permalink
Fixes #96 - Removed autoclose of FileChannel.
Browse files Browse the repository at this point in the history
  • Loading branch information
hbs authored and dain committed Jun 26, 2019
1 parent 7994065 commit 8a89086
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions leveldb/src/main/java/org/iq80/leveldb/impl/TableCache.java
Expand Up @@ -26,6 +26,7 @@
import org.iq80.leveldb.table.MMapTable;
import org.iq80.leveldb.table.Table;
import org.iq80.leveldb.table.UserComparator;
import org.iq80.leveldb.util.Closeables;
import org.iq80.leveldb.util.Finalizer;
import org.iq80.leveldb.util.InternalTableIterator;
import org.iq80.leveldb.util.Slice;
Expand Down Expand Up @@ -120,15 +121,21 @@ private TableAndFile(File databaseDir, long fileNumber, UserComparator userCompa
{
String tableFileName = Filename.tableFileName(fileNumber);
File tableFile = new File(databaseDir, tableFileName);
try (FileInputStream fis = new FileInputStream(tableFile);
FileChannel fileChannel = fis.getChannel()) {
FileInputStream fis = null;
try {
fis = new FileInputStream(tableFile);
FileChannel fileChannel = fis.getChannel();
if (Iq80DBFactory.USE_MMAP) {
table = new MMapTable(tableFile.getAbsolutePath(), fileChannel, userComparator, verifyChecksums);
}
else {
table = new FileChannelTable(tableFile.getAbsolutePath(), fileChannel, userComparator, verifyChecksums);
}
}
catch (IOException ioe) {
Closeables.closeQuietly(fis);
throw ioe;
}
}

public Table getTable()
Expand Down

0 comments on commit 8a89086

Please sign in to comment.