Index: trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateWay.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateWay.java	(revision 5486)
+++ trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateWay.java	(revision 5487)
@@ -6,4 +6,5 @@
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.LinkedList;
@@ -77,8 +78,11 @@
 
     /** Bag of all ways */
-    MultiMap<WayPair, OsmPrimitive> ways;
+    private MultiMap<WayPair, OsmPrimitive> ways;
 
     /** Bag of all ways, regardless of tags */
-    MultiMap<WayPairNoTags, OsmPrimitive> waysNoTags;
+    private MultiMap<WayPairNoTags, OsmPrimitive> waysNoTags;
+    
+    /** Set of known hashcodes for list of coordinates **/
+    private Set<Integer> knownHashCodes;
 
     /**
@@ -96,4 +100,5 @@
         ways = new MultiMap<WayPair, OsmPrimitive>(1000);
         waysNoTags = new MultiMap<WayPairNoTags, OsmPrimitive>(1000);
+        knownHashCodes = new HashSet<Integer>(1000);
     }
 
@@ -136,4 +141,5 @@
         ways = null;
         waysNoTags = null;
+        knownHashCodes = null;
     }
 
@@ -150,6 +156,6 @@
         if (!w.isUsable())
             return;
-        List<Node> wNodes = w.getNodes();
-        List<LatLon> wLat = new ArrayList<LatLon>(wNodes.size());
+        List<Node> wNodes = w.getNodes();                            // The original list of nodes for this way
+        List<Node> wNodesToUse = new ArrayList<Node>(wNodes.size()); // The list that will be considered for this test
         if (w.isClosed()) {
             // In case of a closed way, build the list of lat/lon starting from the node with the lowest id
@@ -165,14 +171,31 @@
             }
             for (int i=lowestIndex; i<wNodes.size()-1; i++) {
-                wLat.add(wNodes.get(i).getCoor());
+            	wNodesToUse.add(wNodes.get(i));
             }
             for (int i=0; i<lowestIndex; i++) {
-                wLat.add(wNodes.get(i).getCoor());
-            }
-            wLat.add(wNodes.get(lowestIndex).getCoor());
-        } else {
-            for (int i=0; i<wNodes.size(); i++) {
-                wLat.add(wNodes.get(i).getCoor());
-            }
+            	wNodesToUse.add(wNodes.get(i));
+            }
+            wNodesToUse.add(wNodes.get(lowestIndex));
+        }
+        // Build the list of lat/lon
+        List<LatLon> wLat = new ArrayList<LatLon>(wNodesToUse.size());
+        for (int i=0; i<wNodesToUse.size(); i++) {
+            wLat.add(wNodesToUse.get(i).getCoor());
+        }
+        // If this way has not direction-dependant keys, make sure the list is ordered the same for all ways (fix #8015)
+        if (!w.hasDirectionKeys()) {
+        	int hash = wLat.hashCode();
+        	if (!knownHashCodes.contains(hash)) {
+            	List<LatLon> reversedwLat = new ArrayList<LatLon>(wLat);
+       			Collections.reverse(reversedwLat);
+            	int reverseHash = reversedwLat.hashCode();
+            	if (!knownHashCodes.contains(reverseHash)) {
+            		// Neither hash or reversed hash is known, remember hash
+            		knownHashCodes.add(hash);
+            	} else {
+            		// Reversed hash is known, use the reverse list then
+            		wLat = reversedwLat;
+            	}
+        	}
         }
         Map<String, String> wkeys = w.getKeys();
