to avoid persistent hash map corruption sync stream on closing file handle used for output

This commit is contained in:
Maxim.Mossienko
2016-05-18 19:54:24 +02:00
parent 50bcecaaf8
commit 8d49a09e2b
2 changed files with 10 additions and 0 deletions
@@ -76,6 +76,7 @@ public class PersistentHashMapValueStorage {
@Override
protected void disposeAccessor(DataOutputStream fileAccessor) throws IOException {
if (!useSingleFileDescriptor) IOUtil.syncStream(fileAccessor);
fileAccessor.close();
}
};
@@ -178,6 +178,7 @@ class RandomAccessFileWithLengthAndSizeTracking extends RandomAccessFile {
if (LOG.isTraceEnabled()) {
LOG.trace("Closed:" + this + "," + Thread.currentThread() );
}
force();
super.close();
}
@@ -185,4 +186,12 @@ class RandomAccessFileWithLengthAndSizeTracking extends RandomAccessFile {
public String toString() {
return myPath + "@" + Integer.toHexString(hashCode());
}
public void force() throws IOException {
if (LOG.isTraceEnabled()) {
LOG.trace("Forcing:" + this + "," + Thread.currentThread() );
}
getFD().sync();
}
}