Index: trunk/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java	(revision 17586)
+++ trunk/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java	(revision 17587)
@@ -650,5 +650,5 @@
             return Collections.emptySet();
         }
-        if (keys.length == 1) {
+        if (keys.length == 2) {
             return Collections.singleton(keys[0]);
         }
@@ -666,5 +666,5 @@
         if (k == null) {
             return Stream.empty();
-        } else if (k.length == 1) {
+        } else if (k.length == 2) {
             return Stream.of(k[0]);
         } else {
Index: trunk/test/unit/org/openstreetmap/josm/data/osm/OsmPrimitiveKeyHandlingTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/data/osm/OsmPrimitiveKeyHandlingTest.java	(revision 17586)
+++ trunk/test/unit/org/openstreetmap/josm/data/osm/OsmPrimitiveKeyHandlingTest.java	(revision 17587)
@@ -4,4 +4,5 @@
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
@@ -12,4 +13,7 @@
 
 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+
+import java.util.Collections;
+import java.util.HashSet;
 
 /**
@@ -50,4 +54,7 @@
 
         testGetKey(n, "akey", "avalue");
+        assertEquals(Collections.singleton("akey"), n.keySet());
+        assertNotEquals(HashSet.class, n.keySet().getClass()); // expect Collections.singleton
+
     }
 
