Index: trunk/src/org/openstreetmap/josm/data/osm/Storage.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/osm/Storage.java	(revision 11389)
+++ trunk/src/org/openstreetmap/josm/data/osm/Storage.java	(revision 11392)
@@ -3,4 +3,5 @@
 
 import java.util.AbstractSet;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.ConcurrentModificationException;
@@ -239,8 +240,21 @@
     public synchronized int hashCode() {
         int h = 0;
-        for (T t : this) {
-            h += hash.getHashCode(t);
+        if (hash != null) {
+            for (T t : this) {
+                h += hash.getHashCode(t);
+            }
         }
         return h;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null || getClass() != obj.getClass())
+            return false;
+        Storage<?> other = (Storage<?>) obj;
+        return Arrays.equals(data, other.data)
+                && hashCode() == obj.hashCode();
     }
 
@@ -321,5 +335,5 @@
         int hcode = rehash(ha.getHashCode(key));
         int bucket = hcode & mask;
-        while ((entry = data[bucket]) != null) {
+        while (bucket < data.length && (entry = data[bucket]) != null) {
             if (ha.equals(key, entry))
                 return bucket;
@@ -500,4 +514,5 @@
         @Override
         public boolean hasNext() {
+            if (data == null) return false;
             align();
             return slot < data.length;
@@ -533,4 +548,5 @@
         @Override
         public boolean hasNext() {
+            if (data == null) return false;
             align();
             return slot < data.length;
