You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/11/06 16:42:06 UTC

[commons-collections] branch master updated (d22eb8951 -> b9c22565f)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-collections.git


    from d22eb8951 PMD: AbstractReferenceMap.SoftRef implements hashCode() but not equals()
     new fe28f8689 PMD: AbstractReferenceMap.WeakRef implements hashCode() but not equals()
     new b9c22565f Javadoc

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/changes/changes.xml                              |  3 +++
 .../collections4/map/AbstractReferenceMap.java       | 20 +++++++++++++++++++-
 2 files changed, 22 insertions(+), 1 deletion(-)


[commons-collections] 02/02: Javadoc

Posted by gg...@apache.org.
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-collections.git

commit b9c22565fe0ee270f434a982802fa489ea075c1e
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Nov 6 11:42:00 2022 -0500

    Javadoc
---
 .../java/org/apache/commons/collections4/map/AbstractReferenceMap.java | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/main/java/org/apache/commons/collections4/map/AbstractReferenceMap.java b/src/main/java/org/apache/commons/collections4/map/AbstractReferenceMap.java
index 346427171..bfaa3f670 100644
--- a/src/main/java/org/apache/commons/collections4/map/AbstractReferenceMap.java
+++ b/src/main/java/org/apache/commons/collections4/map/AbstractReferenceMap.java
@@ -585,7 +585,10 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
      * <p>
      * If getKey() or getValue() returns null, it means
      * the mapping is stale and should be removed.
+     * </p>
      *
+     * @param <K> the type of the keys
+     * @param <V> the type of the values
      * @since 3.1
      */
     protected static class ReferenceEntry<K, V> extends HashEntry<K, V> {


[commons-collections] 01/02: PMD: AbstractReferenceMap.WeakRef implements hashCode() but not equals()

Posted by gg...@apache.org.
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-collections.git

commit fe28f8689e3aabb08074ba048896d80077bb09c5
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Nov 6 11:41:40 2022 -0500

    PMD: AbstractReferenceMap.WeakRef implements hashCode() but not equals()
---
 src/changes/changes.xml                                 |  3 +++
 .../commons/collections4/map/AbstractReferenceMap.java  | 17 ++++++++++++++++-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 25856d352..49e5b6cc4 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -109,6 +109,9 @@
     <action type="fix" dev="ggregory" due-to="Gary Gregory">
       AbstractReferenceMap.SoftRef implements hashCode() but not equals().
     </action>
+    <action type="fix" dev="ggregory" due-to="Gary Gregory">
+      AbstractReferenceMap.WeakRef implements hashCode() but not equals().
+    </action>
     <!-- ADD -->
     <action issue="COLLECTIONS-760" dev="kinow" type="add" due-to="Isira Seneviratne">
       Add tests for MapUtils.
diff --git a/src/main/java/org/apache/commons/collections4/map/AbstractReferenceMap.java b/src/main/java/org/apache/commons/collections4/map/AbstractReferenceMap.java
index 3aab462d1..346427171 100644
--- a/src/main/java/org/apache/commons/collections4/map/AbstractReferenceMap.java
+++ b/src/main/java/org/apache/commons/collections4/map/AbstractReferenceMap.java
@@ -978,7 +978,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
             if (getClass() != obj.getClass()) {
                 return false;
             }
-            SoftRef<?> other = (SoftRef<?>) obj;
+            final SoftRef<?> other = (SoftRef<?>) obj;
             return hash == other.hash;
         }
     }
@@ -999,6 +999,21 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
         public int hashCode() {
             return hash;
         }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj == null) {
+                return false;
+            }
+            if (getClass() != obj.getClass()) {
+                return false;
+            }
+            final WeakRef<?> other = (WeakRef<?>) obj;
+            return hash == other.hash;
+        }
     }
 
     /**