This is an automated email from the ASF dual-hosted git repository. btellier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 6e0656ab87160f50f2560df330746b50ff4edf55 Author: Quan Tran <hqt...@linagora.com> AuthorDate: Wed Nov 30 16:28:05 2022 +0700 [FIX] MessageMetaData equals and hashcode should not just depend on uid --- .../james/mailbox/model/MessageMetaData.java | 23 ++++++++++------ .../james/mailbox/model/MessageMetaDataTest.java | 31 ++++++++++++++++++++++ 2 files changed, 46 insertions(+), 8 deletions(-) diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/model/MessageMetaData.java b/mailbox/api/src/main/java/org/apache/james/mailbox/model/MessageMetaData.java index ed2e7be9a8..19fd0f7ed0 100644 --- a/mailbox/api/src/main/java/org/apache/james/mailbox/model/MessageMetaData.java +++ b/mailbox/api/src/main/java/org/apache/james/mailbox/model/MessageMetaData.java @@ -19,6 +19,7 @@ package org.apache.james.mailbox.model; import java.util.Date; +import java.util.Objects; import java.util.Optional; import javax.mail.Flags; @@ -26,8 +27,6 @@ import javax.mail.Flags; import org.apache.james.mailbox.MessageUid; import org.apache.james.mailbox.ModSeq; -import com.google.common.base.Objects; - public class MessageMetaData { private final MessageUid uid; private final Flags flags; @@ -95,16 +94,24 @@ public class MessageMetaData { } @Override - public boolean equals(Object obj) { - if (obj instanceof MessageMetaData) { - return uid.equals(((MessageMetaData) obj).getUid()); + public final boolean equals(Object o) { + if (o instanceof MessageMetaData) { + MessageMetaData that = (MessageMetaData) o; + + return Objects.equals(this.uid, that.uid) + && Objects.equals(this.size, that.size) + && Objects.equals(this.flags, that.flags) + && Objects.equals(this.internalDate, that.internalDate) + && Objects.equals(this.saveDate, that.saveDate) + && Objects.equals(this.modSeq, that.modSeq) + && Objects.equals(this.messageId, that.messageId) + && Objects.equals(this.threadId, that.threadId); } return false; } @Override - public int hashCode() { - return Objects.hashCode(uid); + public final int hashCode() { + return Objects.hash(uid, flags, size, internalDate, saveDate, modSeq, messageId, threadId); } - } diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/model/MessageMetaDataTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/model/MessageMetaDataTest.java new file mode 100644 index 0000000000..4fbc779408 --- /dev/null +++ b/mailbox/api/src/test/java/org/apache/james/mailbox/model/MessageMetaDataTest.java @@ -0,0 +1,31 @@ +/**************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one * + * or more contributor license agreements. See the NOTICE file * + * distributed with this work for additional information * + * regarding copyright ownership. The ASF licenses this file * + * to you under the Apache License, Version 2.0 (the * + * "License"); you may not use this file except in compliance * + * with the License. You may obtain a copy of the License at * + * * + * http://www.apache.org/licenses/LICENSE-2.0 * + * * + * Unless required by applicable law or agreed to in writing, * + * software distributed under the License is distributed on an * + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * + * KIND, either express or implied. See the License for the * + * specific language governing permissions and limitations * + * under the License. * + ****************************************************************/ + +package org.apache.james.mailbox.model; + +import org.junit.jupiter.api.Test; + +import nl.jqno.equalsverifier.EqualsVerifier; + +class MessageMetaDataTest { + @Test + void beanTest() { + EqualsVerifier.forClass(MessageMetaData.class).verify(); + } +} --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For additional commands, e-mail: notifications-h...@james.apache.org