Commits

jhouse  committed 5c80ce0

QUARTZ-625 : NullPointer in org.quartz.utils.Pair.hashCode() method

git-svn-id: http://svn.opensymphony.com/svn/quartz/branches/quartz_1-6@74769f7d36a-ea1c-0410-88ea-9fd03e4c9665

  • Participants
  • Parent commits dadf8dd
  • Branches quartz_1-6

Comments (0)

Files changed (1)

File src/java/org/quartz/utils/Pair.java

 
     private Object second;
 
+
+    public Pair()
+    {}
+
+    public Pair(Object first, Object second)
+    {
+        setFirst(first);
+        setSecond(second);
+    }
+    
     /*
      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      * 
         } else {
             try {
                 Pair other = (Pair) that;
-                return (this.first.equals(other.first) && this.second
+                if(first == null && second == null)
+                    return (other.first == null && other.second == null)
+                if(first != null && second != null)
+                    return (this.first.equals(other.first) && this.second
                         .equals(other.second));
+                if(first != null)
+                    return this.first.equals(other.first);
+                if(second != null)
+                    return this.second.equals(other.second);
+
             } catch (ClassCastException e) {
                 return false;
             }
     }
     
     public int hashCode() {
-        return (17 * first.hashCode()) + second.hashCode();
+        if(first != null && second != null)
+            return (first.hashCode() ^ second.hashCode());
+        if(first != null)
+            return (17 ^ first.hashCode());
+        if(second != null)
+            return (17 ^ second.hashCode());
+        return super.hashCode();
     }
 }