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 a093b7fe4e ARTEMIS-5851 throw on OpenWire send when TX is null
a093b7fe4e is described below
commit a093b7fe4e47bf747693fa91717e0dc025e85a1a
Author: Justin Bertram <[email protected]>
AuthorDate: Tue Jan 20 10:34:41 2026 -0600
ARTEMIS-5851 throw on OpenWire send when TX is null
---
.../core/protocol/openwire/OpenWireConnection.java | 4 +++
.../integration/openwire/SimpleOpenWireTest.java | 29 ++++++++++++++++++++++
2 files changed, 33 insertions(+)
diff --git
a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
index e414d022b2..3d4ab9757e 100644
---
a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
+++
b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
@@ -1753,6 +1753,10 @@ public class OpenWireConnection extends
AbstractRemotingConnection implements Se
Transaction tx = lookupTX(messageSend.getTransactionId(), session);
+ if (messageSend.getTransactionId() != null && tx == null) {
+ throw new IllegalStateException("Transaction not started, " +
messageSend.getTransactionId());
+ }
+
session.getCoreSession().resetTX(tx);
try {
session.send(producerInfo, messageSend, sendProducerAck);
diff --git
a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/SimpleOpenWireTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/SimpleOpenWireTest.java
index f12b93a017..d287372b5f 100644
---
a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/SimpleOpenWireTest.java
+++
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/SimpleOpenWireTest.java
@@ -1337,6 +1337,35 @@ public class SimpleOpenWireTest extends
BasicOpenWireTest {
}
}
+ @Test
+ public void testXAFailureBeforeSend() throws Exception {
+ try {
+ XAConnection connection = xaFactory.createXAConnection();
+
+ XASession xasession = connection.createXASession();
+
+ Xid xid = newXID();
+ xasession.getXAResource().start(xid, XAResource.TMNOFLAGS);
+ Queue queue = xasession.createQueue(queueName);
+ MessageProducer producer = xasession.createProducer(queue);
+ // removing the tx here should cause the send to fail on the broker
+ server.getResourceManager().removeTransaction(xid, null);
+ try {
+ producer.send(xasession.createTextMessage("hello"));
+ xasession.getXAResource().end(xid, XAResource.TMSUCCESS);
+ fail("Should have thrown an exception here");
+ } catch (XAException e) {
+ // ignore
+ }
+
+ connection.close();
+
+ assertEquals(0, server.locateQueue(queueName).getMessageCount());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
@Test
public void testAutoSend() throws Exception {
connection.start();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]