Skip to content

Commit 20c0513

Browse files
committed
Fix for NACKed messages in cluster
1 parent f083170 commit 20c0513

File tree

4 files changed

+58
-3
lines changed

4 files changed

+58
-3
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#
2+
# Copyright (c) 2025 Contributors to Eclipse Foundation. All rights reserved.
3+
#
4+
# This program and the accompanying materials are made available under the
5+
# terms of the Eclipse Public License v. 2.0, which is available at
6+
# http://www.eclipse.org/legal/epl-2.0.
7+
#
8+
# This Source Code may also be made available under the following Secondary
9+
# Licenses when the conditions for such availability set forth in the
10+
# Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11+
# version 2 with the GNU Classpath Exception, which is available at
12+
# https://www.gnu.org/software/classpath/license.html.
13+
#
14+
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15+
#
16+

mq/main/mq-broker/broker-core/src/main/java/com/sun/messaging/jmq/jmsserver/core/Destination.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* Copyright (c) 2000, 2020 Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2020 Payara Services Ltd.
4-
* Copyright (c) 2021, 2022 Contributors to the Eclipse Foundation
4+
* Copyright (c) 2021, 2025 Contributors to the Eclipse Foundation
55
*
66
* This program and the accompanying materials are made available under the
77
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -3000,7 +3000,7 @@ private RemoveMessageReturnInfo _removeMessage(SysMessageID id, Reason r, Hashta
30003000
if (remoteRef == null) {
30013001
ref = destMessages.remove(id, r);
30023002
} else {
3003-
PacketReference errValue = PacketReference.createReference(null, null, null);
3003+
PacketReference errValue = PacketReference.getInvalidReference();
30043004
PacketReference o = destMessages.removeWithValue(id, remoteRef, errValue, r);
30053005
if (o == errValue) { /* intended */
30063006
logger.log(((DEBUG_CLUSTER || getDEBUG()) ? Logger.INFO : Logger.DEBUG),

mq/main/mq-broker/broker-core/src/main/java/com/sun/messaging/jmq/jmsserver/core/PacketReference.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 2000, 2020 Oracle and/or its affiliates. All rights reserved.
3-
* Copyright (c) 2021, 2022 Contributors to the Eclipse Foundation
3+
* Copyright (c) 2021, 2025 Contributors to the Eclipse Foundation
44
*
55
* This program and the accompanying materials are made available under the
66
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -40,6 +40,10 @@
4040
import com.sun.messaging.jmq.util.lists.*;
4141
import com.sun.messaging.jmq.util.UID;
4242
import com.sun.messaging.jmq.util.log.Logger;
43+
44+
import lombok.AccessLevel;
45+
import lombok.NoArgsConstructor;
46+
4347
import com.sun.messaging.jmq.jmsserver.cluster.api.ClusterBroadcast;
4448
import com.sun.messaging.jmq.jmsserver.memory.MemoryGlobals;
4549
import com.sun.messaging.jmq.jmsserver.FaultInjection;
@@ -51,6 +55,7 @@
5155
*
5256
*/
5357

58+
@NoArgsConstructor(access = AccessLevel.PRIVATE)
5459
public class PacketReference implements Sized, Ordered {
5560

5661
private static FaultInjection FI = FaultInjection.getInjection();
@@ -64,6 +69,8 @@ public class PacketReference implements Sized, Ordered {
6469

6570
private boolean commit2pwait = Globals.getConfig().getBooleanProperty(Globals.IMQ + ".cluster.2pcommitAckWaitReply", false);
6671

72+
private static final PacketReference INVALID_PACKET_REFERENCE = new PacketReference();
73+
6774
static {
6875
queueUID = new ConsumerUID(true /* empty */);
6976
queueUID.setShouldStore(true);
@@ -382,6 +389,10 @@ public static ConsumerUID getQueueUID() {
382389
return queueUID;
383390
}
384391

392+
public static PacketReference getInvalidReference() {
393+
return INVALID_PACKET_REFERENCE;
394+
}
395+
385396
public static PacketReference createReferenceWithDestination(PartitionedStore ps, Packet p, Destination dest, Connection con) throws BrokerException {
386397
PacketReference ref = createReference(ps, p, dest.getDestinationUID(), con);
387398
if (dest.isDMQ()) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright (c) 2025 Contributors to the Eclipse Foundation
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License v. 2.0, which is available at
6+
* http://www.eclipse.org/legal/epl-2.0.
7+
*
8+
* This Source Code may also be made available under the following Secondary
9+
* Licenses when the conditions for such availability set forth in the
10+
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11+
* version 2 with the GNU Classpath Exception, which is available at
12+
* https://www.gnu.org/software/classpath/license.html.
13+
*
14+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15+
*/
16+
17+
package com.sun.messaging.jmq.jmsserver.core;
18+
19+
import static org.assertj.core.api.Assertions.assertThat;
20+
21+
import org.junit.jupiter.api.Test;
22+
23+
class PacketReference_getInvalidReference_Test {
24+
@Test
25+
void invalidReferenceShouldNotBeNull() {
26+
assertThat(PacketReference.getInvalidReference()).isNotNull();
27+
}
28+
}

0 commit comments

Comments
 (0)