diff --git a/spring-amqp/src/main/java/org/springframework/amqp/core/Message.java b/spring-amqp/src/main/java/org/springframework/amqp/core/Message.java index 3cb487210..403901361 100644 --- a/spring-amqp/src/main/java/org/springframework/amqp/core/Message.java +++ b/spring-amqp/src/main/java/org/springframework/amqp/core/Message.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 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. @@ -36,6 +36,7 @@ * @author Gary Russell * @author Alex Panchenko * @author Artem Bilan + * @author Ngoc Nhan */ public class Message implements Serializable { @@ -168,14 +169,9 @@ public boolean equals(Object obj) { return false; } if (this.messageProperties == null) { - if (other.messageProperties != null) { - return false; - } - } - else if (!this.messageProperties.equals(other.messageProperties)) { - return false; + return other.messageProperties == null; } - return true; + return this.messageProperties.equals(other.messageProperties); } 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 75a402a4d..81e4954d4 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 @@ -36,6 +36,7 @@ * @author Artem Bilan * @author Csaba Soti * @author Raylax Grey + * @author Ngoc Nhan */ public class MessageProperties implements Serializable { @@ -812,14 +813,9 @@ else if (!this.type.equals(other.type)) { return false; } if (this.userId == null) { - if (other.userId != null) { - return false; - } - } - else if (!this.userId.equals(other.userId)) { - return false; + return other.userId == null; } - return true; + return this.userId.equals(other.userId); } @Override // NOSONAR complexity diff --git a/spring-amqp/src/main/java/org/springframework/amqp/core/QueueInformation.java b/spring-amqp/src/main/java/org/springframework/amqp/core/QueueInformation.java index de914f943..f2d8df245 100644 --- a/spring-amqp/src/main/java/org/springframework/amqp/core/QueueInformation.java +++ b/spring-amqp/src/main/java/org/springframework/amqp/core/QueueInformation.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 the original author or authors. + * Copyright 2019-2024 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,7 @@ * Information about a queue, resulting from a passive declaration. * * @author Gary Russell + * @author Ngoc Nhan * @since 2.2 * */ @@ -70,14 +71,9 @@ public boolean equals(Object obj) { } QueueInformation other = (QueueInformation) obj; if (this.name == null) { - if (other.name != null) { - return false; - } + return other.name == null; } - else if (!this.name.equals(other.name)) { - return false; - } - return true; + return this.name.equals(other.name); } @Override