This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-compress.git
The following commit(s) were added to refs/heads/master by this push: new 4cd7b672 Implicit narrowing conversion in compound assignment 4cd7b672 is described below commit 4cd7b6727d263dac0cf9048a12643af2b50a5d65 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Fri Nov 4 17:54:04 2022 -0400 Implicit narrowing conversion in compound assignment * Code scanning alerts * Redo equals and hashcode for DumpArchiveSummary --- .../archivers/dump/DumpArchiveSummary.java | 40 +++++----------------- 1 file changed, 8 insertions(+), 32 deletions(-) diff --git a/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveSummary.java b/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveSummary.java index 08c0943a..c6cdfbf9 100644 --- a/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveSummary.java +++ b/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveSummary.java @@ -20,6 +20,7 @@ package org.apache.commons.compress.archivers.dump; import java.io.IOException; import java.util.Date; +import java.util.Objects; import org.apache.commons.compress.archivers.zip.ZipEncoding; @@ -287,46 +288,21 @@ public class DumpArchiveSummary { @Override public int hashCode() { - int hash = 17; - - if (label != null) { - hash = label.hashCode(); - } - - hash += 31 * dumpDate; - - if (hostname != null) { - hash = (31 * hostname.hashCode()) + 17; - } - - if (devname != null) { - hash = (31 * devname.hashCode()) + 17; - } - - return hash; + return Objects.hash(devname, dumpDate, hostname); } @Override - public boolean equals(final Object o) { - if (this == o) { + public boolean equals(Object obj) { + if (this == obj) { return true; } - - if (o == null || !o.getClass().equals(getClass())) { + if (obj == null) { return false; } - - final DumpArchiveSummary rhs = (DumpArchiveSummary) o; - - if (dumpDate != rhs.dumpDate) { + if (getClass() != obj.getClass()) { return false; } - - if ((getHostname() == null) || - !getHostname().equals(rhs.getHostname())) { - return false; - } - - return (getDevname() != null) && getDevname().equals(rhs.getDevname()); + DumpArchiveSummary other = (DumpArchiveSummary) obj; + return Objects.equals(devname, other.devname) && dumpDate == other.dumpDate && Objects.equals(hostname, other.hostname); } }