GH-730: Fix NPE in the MessageProperties

Fixes https://github.com/spring-projects/spring-amqp/issues/730
This commit is contained in:
Gary Russell
2018-03-28 14:53:08 -04:00
parent c8d66d24fa
commit d6a5a7555b
2 changed files with 16 additions and 0 deletions

View File

@@ -568,6 +568,14 @@ public class MessageProperties implements Serializable {
if (!Arrays.equals(this.correlationId, other.correlationId)) {
return false;
}
if (this.correlationIdString == null) {
if (other.correlationIdString != null) {
return false;
}
}
else if (!this.correlationIdString.equals(other.correlationIdString)) {
return false;
}
if (this.deliveryMode != other.deliveryMode) {
return false;
}

View File

@@ -17,6 +17,7 @@
package org.springframework.amqp.core;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
@@ -41,4 +42,11 @@ public class MessagePropertiesTests {
assertEquals(null, properties.getReplyToAddress());
}
@Test
public void tesNoNullPointerInEquals() {
MessageProperties mp = new MessageProperties();
MessageProperties mp2 = new MessageProperties();
assertTrue(mp.equals(mp2));
}
}