diff --git a/spring-amqp/src/main/java/org/springframework/amqp/core/MessageProperties.java b/spring-amqp/src/main/java/org/springframework/amqp/core/MessageProperties.java index 44eb3898be..aacde988cd 100644 --- a/spring-amqp/src/main/java/org/springframework/amqp/core/MessageProperties.java +++ b/spring-amqp/src/main/java/org/springframework/amqp/core/MessageProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -590,9 +590,16 @@ else if (!this.contentEncoding.equals(other.contentEncoding)) { else if (!this.contentType.equals(other.contentType)) { return false; } - if (!this.correlationId.equals(other.correlationId)) { + + if (this.correlationId == null) { + if (other.correlationId != null) { + return false; + } + } + else if (!this.correlationId.equals(other.correlationId)) { return false; } + if (this.deliveryMode != other.deliveryMode) { return false; } diff --git a/spring-amqp/src/test/java/org/springframework/amqp/core/MessagePropertiesTests.java b/spring-amqp/src/test/java/org/springframework/amqp/core/MessagePropertiesTests.java index e1c8c948f1..eff9cf297d 100644 --- a/spring-amqp/src/test/java/org/springframework/amqp/core/MessagePropertiesTests.java +++ b/spring-amqp/src/test/java/org/springframework/amqp/core/MessagePropertiesTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,10 +26,13 @@ /** * @author Dave Syer * @author Artem Yakshin + * @author Artem Bilan * */ public class MessagePropertiesTests { + + @Test public void testReplyTo() throws Exception { MessageProperties properties = new MessageProperties(); @@ -61,4 +64,11 @@ public void testContentLengthSet() { assertTrue(properties.isContentLengthSet()); } + @Test + public void tesNoNullPointerInEquals() { + MessageProperties mp = new MessageProperties(); + MessageProperties mp2 = new MessageProperties(); + assertTrue(mp.equals(mp2)); + } + }