From e8f44a29ddf940a3bd254b10336c8e2c1f318fc7 Mon Sep 17 00:00:00 2001 From: Timothy Bish Date: Wed, 2 Mar 2016 17:18:30 -0500 Subject: [PATCH] https://issues.apache.org/jira/browse/AMQ-5578 Revert to previous behavior of explicit init. --- .../apache/activemq/store/kahadb/disk/journal/Journal.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/disk/journal/Journal.java b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/disk/journal/Journal.java index ba0b9f5124..2604e39096 100644 --- a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/disk/journal/Journal.java +++ b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/disk/journal/Journal.java @@ -275,7 +275,12 @@ public class Journal { private void doPreallocationZeros(RecoverableRandomAccessFile file) { ByteBuffer buffer = ByteBuffer.allocate(maxFileLength); - buffer.limit(maxFileLength); + // intentional double initialization due to interaction with the OS level + // file allocation mechanics. + for (int i = 0; i < maxFileLength; i++) { + buffer.put((byte) 0x00); + } + buffer.flip(); try { FileChannel channel = file.getChannel();