activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject [activemq-artemis] branch master updated: ARTEMIS-2088 - Page.write() should throw exception if file is closed
Date Thu, 24 Jan 2019 02:31:25 GMT
This is an automated email from the ASF dual-hosted git repository.

clebertsuconic pushed a commit to branch master
in repository

The following commit(s) were added to refs/heads/master by this push:
     new 90ca87c  ARTEMIS-2088 - Page.write() should throw exception if file is closed
     new b73ff1b  This closes #2305
90ca87c is described below

commit 90ca87c5e16df9812a65db37d05306f444dd7fb1
Author: Howard Gao <>
AuthorDate: Fri Sep 14 10:52:02 2018 +0800

    ARTEMIS-2088 - Page.write() should throw exception if file is closed
    In Page.write(final PagedMessage message) if the page file is closed
    it returns silently. The caller has no way to know that if the message
    is paged to file or not. It should throw an exception so that the
    caller can handle it correctly.
    This causes random failure PagingTest#testExpireLargeMessageOnPaging().
    The test shows that when the server stops it closes the page file.
    In the mean time a message is expired to the expiry queue and if
    the expiry queue is in paging mode, it goes to Page.write() and
    returns without any error. The result is that the message is removed
    from the original queue and not added to the expiry queue.
    If we throw exception here it makes the expiration failed, the message
    will not be removed from the orginal queue. Next time broker is started,
    the message will be reloaded and expired again. no message lost.
 .../main/java/org/apache/activemq/artemis/core/paging/impl/ | 2 +-
 .../apache/activemq/artemis/core/server/   | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/
index dfe7387..c8fbb3d 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/
@@ -223,7 +223,7 @@ public final class Page implements Comparable<Page> {
    public synchronized void write(final PagedMessage message) throws Exception {
       if (!file.isOpen()) {
-         return;
+         throw ActiveMQMessageBundle.BUNDLE.cannotWriteToClosedFile(file);
       final int messageEncodedSize = message.getEncodeSize();
       final int bufferSize = messageEncodedSize + Page.SIZE_RECORD;
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/
index 5d94da7..d649d8d 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/
@@ -44,6 +44,7 @@ import org.apache.activemq.artemis.api.core.ActiveMQUnexpectedRoutingTypeForAddr
 import org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration;
 import org.apache.activemq.artemis.api.core.RoutingType;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.postoffice.Binding;
 import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationSyncFileMessage;
@@ -444,4 +445,8 @@ public interface ActiveMQMessageBundle {
    @Message(id = 229216, value = "Invalid queue name: {0}", format = Message.Format.MESSAGE_FORMAT)
    ActiveMQIllegalStateException invalidQueueName(SimpleString queueName);
+   @Message(id = 119217, value = "Can't write to closed file: {0}", format = Message.Format.MESSAGE_FORMAT)
+   ActiveMQIOErrorException cannotWriteToClosedFile(SequentialFile file);

View raw message