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 aacde988..ad9a3764 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-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -31,6 +31,7 @@ import java.util.Map; * @author Gary Russell * @author Dmitry Chernyshov * @author Artem Bilan + * @author Csaba Soti */ public class MessageProperties implements Serializable { @@ -525,7 +526,7 @@ public class MessageProperties implements Serializable { result = prime * result + ((this.contentEncoding == null) ? 0 : this.contentEncoding.hashCode()); result = prime * result + (int) (this.contentLength ^ (this.contentLength >>> 32)); result = prime * result + ((this.contentType == null) ? 0 : this.contentType.hashCode()); - result = prime * result + this.correlationId.hashCode(); + result = prime * result + ((this.correlationId == null) ? 0 : this.correlationId.hashCode()); result = prime * result + ((this.deliveryMode == null) ? 0 : this.deliveryMode.hashCode()); result = prime * result + (int) (this.deliveryTag ^ (this.deliveryTag >>> 32)); result = prime * result + ((this.expiration == null) ? 0 : this.expiration.hashCode()); 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 eff9cf29..6aa82221 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-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -20,6 +20,9 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import java.util.HashSet; +import java.util.Set; + import org.junit.Test; @@ -27,12 +30,12 @@ import org.junit.Test; * @author Dave Syer * @author Artem Yakshin * @author Artem Bilan + * @author Csaba Soti * */ public class MessagePropertiesTests { - @Test public void testReplyTo() throws Exception { MessageProperties properties = new MessageProperties(); @@ -71,4 +74,11 @@ public class MessagePropertiesTests { assertTrue(mp.equals(mp2)); } + @Test + public void tesNoNullPointerInHashCode() { + Set messageList = new HashSet<>(); + messageList.add(new MessageProperties()); + assertEquals(1, messageList.size()); + } + }