Index: trunk/test/unit/org/openstreetmap/josm/tools/TextTagParserTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/tools/TextTagParserTest.java	(revision 16447)
+++ trunk/test/unit/org/openstreetmap/josm/tools/TextTagParserTest.java	(revision 16472)
@@ -4,6 +4,9 @@
 import static org.junit.Assert.assertEquals;
 
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
@@ -173,3 +176,14 @@
         assertEquals(expected, TextTagParser.readTagsFromText("name=Main street\nurl=https://example.com/?id=1"));
     }
+
+    /**
+     * Tests that the tags ordering is stable.
+     */
+    @Test
+    public void testStableOrder() {
+        List<String> expected = Arrays.asList("foo4", "foo3", "foo2", "foo1");
+        ArrayList<String> actual = new ArrayList<>(TextTagParser.readTagsByRegexp(
+                "foo4=bar4 foo3=bar3 foo2=bar2 foo1=bar1", " ", "(.*?)=(.*?)", true).keySet());
+        assertEquals(expected, actual);
+    }
 }
