Skip to content

Commit d6a5a75

Browse files
committed
GH-730: Fix NPE in the MessageProperties
Fixes #730
1 parent c8d66d2 commit d6a5a75

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

spring-amqp/src/main/java/org/springframework/amqp/core/MessageProperties.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,14 @@ else if (!this.contentType.equals(other.contentType)) {
568568
if (!Arrays.equals(this.correlationId, other.correlationId)) {
569569
return false;
570570
}
571+
if (this.correlationIdString == null) {
572+
if (other.correlationIdString != null) {
573+
return false;
574+
}
575+
}
576+
else if (!this.correlationIdString.equals(other.correlationIdString)) {
577+
return false;
578+
}
571579
if (this.deliveryMode != other.deliveryMode) {
572580
return false;
573581
}

spring-amqp/src/test/java/org/springframework/amqp/core/MessagePropertiesTests.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.springframework.amqp.core;
1818

1919
import static org.junit.Assert.assertEquals;
20+
import static org.junit.Assert.assertTrue;
2021

2122
import org.junit.Test;
2223

@@ -41,4 +42,11 @@ public void testReplyToNullByDefault() throws Exception {
4142
assertEquals(null, properties.getReplyToAddress());
4243
}
4344

45+
@Test
46+
public void tesNoNullPointerInEquals() {
47+
MessageProperties mp = new MessageProperties();
48+
MessageProperties mp2 = new MessageProperties();
49+
assertTrue(mp.equals(mp2));
50+
}
51+
4452
}

0 commit comments

Comments
 (0)