diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/IOCallback.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/IOCallback.java index fe9a527d7b..8eed9d23a2 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/IOCallback.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/IOCallback.java @@ -38,13 +38,15 @@ public interface IOCallback { void onError(int errorCode, String errorMessage); static void done(Collection delegates) { - delegates.forEach(callback -> { - try { - callback.done(); - } catch (Throwable e) { - ActiveMQJournalLogger.LOGGER.errorCompletingCallback(e); - } - }); + if (delegates != null) { + delegates.forEach(callback -> { + try { + callback.done(); + } catch (Throwable e) { + ActiveMQJournalLogger.LOGGER.errorCompletingCallback(e); + } + }); + } } static void onError(Collection delegates, int errorCode, final String errorMessage) { diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/mapped/TimedSequentialFile.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/mapped/TimedSequentialFile.java index fa93e1c13b..78ce12f40c 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/mapped/TimedSequentialFile.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/mapped/TimedSequentialFile.java @@ -18,7 +18,6 @@ package org.apache.activemq.artemis.core.io.mapped; import java.io.File; import java.io.IOException; -import java.lang.invoke.MethodHandles; import java.nio.ByteBuffer; import java.util.List; @@ -35,14 +34,9 @@ import org.apache.activemq.artemis.core.io.buffer.TimedBuffer; import org.apache.activemq.artemis.core.io.buffer.TimedBufferObserver; import org.apache.activemq.artemis.core.journal.EncodingSupport; import org.apache.activemq.artemis.core.journal.impl.SimpleWaitIOCallback; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; final class TimedSequentialFile implements SequentialFile { - private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - - private final SequentialFileFactory factory; private final SequentialFile sequentialFile; private final LocalBufferObserver observer; @@ -255,7 +249,7 @@ final class TimedSequentialFile implements SequentialFile { @Override public boolean supportSync() { - return true; + return false; } @Override @@ -277,7 +271,8 @@ final class TimedSequentialFile implements SequentialFile { buffer.flip(); } try { - blockingWriteDirect(buffer, false, releaseBuffer); + blockingWriteDirect(buffer, requestedSync, releaseBuffer); + IOCallback.done(callbacks); } catch (Throwable t) { final int code; if (t instanceof IOException) { @@ -288,20 +283,14 @@ final class TimedSequentialFile implements SequentialFile { } IOCallback.onError(callbacks, code, t.getMessage()); } + } else { + IOCallback.done(callbacks); } } @Override public void checkSync(boolean syncRequested, List callbacks) { - try { - sync(); - } catch (Exception e) { - logger.warn(e.getMessage(), e); - } finally { - if (callbacks != null) { - callbacks.forEach(c -> c.done()); - } - } + throw new UnsupportedOperationException("This method is not supported on mapped"); } @Override diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/BatchCommitTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/BatchCommitTest.java index 621d235da3..2e7786e7af 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/BatchCommitTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/BatchCommitTest.java @@ -46,6 +46,7 @@ import org.apache.activemq.artemis.utils.actors.OrderedExecutorFactory; import org.apache.activemq.artemis.utils.collections.ConcurrentHashSet; import org.junit.Assert; import org.junit.Assume; +import org.junit.Ignore; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -172,7 +173,7 @@ public class BatchCommitTest extends ActiveMQTestBase { internalTest(JournalType.NIO, "testRunNIO", false); } - @Test + @Ignore // TODO: We should fix Mapped eventually for this case public void testMapped() throws Exception { internalTest(JournalType.MAPPED, "testRunMapped", true); }