diff --git a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/disk/page/PageFile.java b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/disk/page/PageFile.java index 052a586f5f..5699c450a2 100644 --- a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/disk/page/PageFile.java +++ b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/disk/page/PageFile.java @@ -378,7 +378,7 @@ public class PageFile { File file = getMainPageFile(); IOHelper.mkdirs(file.getParentFile()); - writeFile = new RecoverableRandomAccessFile(file, "rw"); + writeFile = new RecoverableRandomAccessFile(file, "rw", false); readFile = new RecoverableRandomAccessFile(file, "r"); if (readFile.length() > 0) { diff --git a/activemq-kahadb-store/src/main/java/org/apache/activemq/util/RecoverableRandomAccessFile.java b/activemq-kahadb-store/src/main/java/org/apache/activemq/util/RecoverableRandomAccessFile.java index 171f0c971a..309272a870 100644 --- a/activemq-kahadb-store/src/main/java/org/apache/activemq/util/RecoverableRandomAccessFile.java +++ b/activemq-kahadb-store/src/main/java/org/apache/activemq/util/RecoverableRandomAccessFile.java @@ -31,17 +31,21 @@ public class RecoverableRandomAccessFile implements java.io.DataOutput, java.io. RandomAccessFile raf; File file; String mode; + final boolean isSkipMetadataUpdate; - public RecoverableRandomAccessFile(File file, String mode) throws FileNotFoundException { + public RecoverableRandomAccessFile(File file, String mode, boolean skipMetadataUpdate) throws FileNotFoundException { this.file = file; this.mode = mode; raf = new RandomAccessFile(file, mode); + isSkipMetadataUpdate = skipMetadataUpdate; + } + + public RecoverableRandomAccessFile(File file, String mode) throws FileNotFoundException { + this(file, mode, SKIP_METADATA_UPDATE); } public RecoverableRandomAccessFile(String name, String mode) throws FileNotFoundException { - this.file = new File(name); - this.mode = mode; - raf = new RandomAccessFile(file, mode); + this(new File(name), mode); } public RandomAccessFile getRaf() throws IOException { @@ -394,7 +398,7 @@ public class RecoverableRandomAccessFile implements java.io.DataOutput, java.io. public void sync() throws IOException { try { - getRaf().getChannel().force(!SKIP_METADATA_UPDATE);; + getRaf().getChannel().force(!isSkipMetadataUpdate);; } catch (IOException ioe) { handleException(); throw ioe;