This is an automated email from the ASF dual-hosted git repository.

tabish pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/artemis.git


The following commit(s) were added to refs/heads/main by this push:
     new 3c77d5d780 ARTEMIS-5916 add cause to exception when sending large msg 
chunk
3c77d5d780 is described below

commit 3c77d5d780bcbb50970079f61ea307854c433684
Author: Justin Bertram <[email protected]>
AuthorDate: Fri Feb 27 13:11:21 2026 -0600

    ARTEMIS-5916 add cause to exception when sending large msg chunk
---
 .../artemis/api/core/ActiveMQException.java        |  5 +++
 artemis-core-client/pom.xml                        |  5 +++
 .../protocol/core/impl/ActiveMQSessionContext.java |  2 +-
 .../core/impl/ActiveMQSessionContextTest.java      | 52 ++++++++++++++++++++++
 4 files changed, 63 insertions(+), 1 deletion(-)

diff --git 
a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQException.java
 
b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQException.java
index e03abe8aa7..c227c93ce6 100644
--- 
a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQException.java
+++ 
b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQException.java
@@ -34,6 +34,11 @@ public class ActiveMQException extends Exception {
       type = ActiveMQExceptionType.GENERIC_EXCEPTION;
    }
 
+   public ActiveMQException(final String msg, Throwable t) {
+      super(msg, t);
+      type = ActiveMQExceptionType.GENERIC_EXCEPTION;
+   }
+
    public ActiveMQException(String msg, ActiveMQExceptionType t) {
       super(msg);
       type = t;
diff --git a/artemis-core-client/pom.xml b/artemis-core-client/pom.xml
index ae1367b2b2..ede616b541 100644
--- a/artemis-core-client/pom.xml
+++ b/artemis-core-client/pom.xml
@@ -149,6 +149,11 @@
          <artifactId>mockito-core</artifactId>
          <scope>test</scope>
       </dependency>
+      <dependency>
+         <groupId>org.apache.commons</groupId>
+         <artifactId>commons-lang3</artifactId>
+         <scope>test</scope>
+      </dependency>
    </dependencies>
 
    <profiles>
diff --git 
a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQSessionContext.java
 
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQSessionContext.java
index ca3ee1a6aa..6d7d458a86 100644
--- 
a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQSessionContext.java
+++ 
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQSessionContext.java
@@ -1102,7 +1102,7 @@ public class ActiveMQSessionContext extends 
SessionContext {
          }
          return chunkPacket.getPacketSize();
       } catch (Throwable e) {
-         throw new ActiveMQException(e.getMessage());
+         throw new ActiveMQException(e.getMessage(), e);
       }
    }
 
diff --git 
a/artemis-core-client/src/test/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQSessionContextTest.java
 
b/artemis-core-client/src/test/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQSessionContextTest.java
new file mode 100644
index 0000000000..36507e9a96
--- /dev/null
+++ 
b/artemis-core-client/src/test/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQSessionContextTest.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.artemis.core.protocol.core.impl;
+
+import io.netty.buffer.Unpooled;
+import org.apache.activemq.artemis.api.core.ActiveMQException;
+import org.apache.activemq.artemis.core.buffers.impl.ChannelBufferWrapper;
+import org.apache.activemq.artemis.core.protocol.core.CoreRemotingConnection;
+import org.apache.activemq.artemis.core.protocol.core.Packet;
+import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
+import org.apache.activemq.artemis.spi.core.remoting.Connection;
+import org.apache.commons.lang3.exception.ExceptionUtils;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.fail;
+
+public class ActiveMQSessionContextTest {
+
+   @Test
+   public void testExceptionContainsCause() throws ActiveMQException {
+      CoreRemotingConnection coreRC = 
Mockito.mock(CoreRemotingConnection.class);
+      
Mockito.when(coreRC.createTransportBuffer(Packet.INITIAL_PACKET_SIZE)).thenReturn(new
 ChannelBufferWrapper(Unpooled.buffer(Packet.INITIAL_PACKET_SIZE)));
+      
Mockito.when(coreRC.blockUntilWritable(Mockito.anyLong())).thenReturn(true);
+      
Mockito.when(coreRC.getTransportConnection()).thenReturn(Mockito.mock(Connection.class));
+      ChannelImpl channel = new ChannelImpl(coreRC, 1, 4000, null);
+
+      ActiveMQSessionContext context = new ActiveMQSessionContext("test", 
Mockito.mock(RemotingConnection.class), channel, 0, 0);
+
+      try {
+         context.sendServerLargeMessageChunk(null, 0, true, true, null, 0, 
null);
+         fail("Expected exception to be thrown");
+      } catch (ActiveMQException e) {
+         assertInstanceOf(NullPointerException.class, 
ExceptionUtils.getRootCause(e));
+      }
+   }
+}
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to