Index: trunk/src/org/openstreetmap/josm/data/validation/tests/Coastlines.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/validation/tests/Coastlines.java	(revision 4072)
+++ trunk/src/org/openstreetmap/josm/data/validation/tests/Coastlines.java	(revision 4073)
@@ -14,6 +14,6 @@
 import org.openstreetmap.josm.command.ChangeCommand;
 import org.openstreetmap.josm.command.Command;
+import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
-import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.Way;
 import org.openstreetmap.josm.data.validation.Severity;
@@ -44,5 +44,5 @@
     public Coastlines() {
         super(tr("Coastlines."),
-              tr("This test checks that coastlines are correct."));
+                tr("This test checks that coastlines are correct."));
     }
 
@@ -67,5 +67,5 @@
             Node tail = c1.lastNode();
 
-            if (head.equals(tail)) {
+            if (c1.getNodesCount() == 0 || head.equals(tail)) {
                 continue;
             }
@@ -162,5 +162,5 @@
                 if (highlight.size() > 0) {
                     errors.add(new TestError(this, Severity.ERROR, tr("Unconnected coastline"),
-                                             UNCONNECTED_COASTLINE, primitives, highlight));
+                            UNCONNECTED_COASTLINE, primitives, highlight));
                 }
             }
@@ -191,9 +191,9 @@
 
                 errors.add(new TestError(this, Severity.ERROR, tr("Unordered coastline"),
-                                         UNORDERED_COASTLINE, primitives, highlight));
+                        UNORDERED_COASTLINE, primitives, highlight));
             }
             else if (reversed) {
                 errors.add(new TestError(this, Severity.ERROR, tr("Reversed coastline"),
-                                         REVERSED_COASTLINE, primitives));
+                        REVERSED_COASTLINE, primitives));
             }
         }
Index: trunk/src/org/openstreetmap/josm/data/validation/tests/UnconnectedWays.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/validation/tests/UnconnectedWays.java	(revision 4072)
+++ trunk/src/org/openstreetmap/josm/data/validation/tests/UnconnectedWays.java	(revision 4073)
@@ -60,5 +60,5 @@
     public UnconnectedWays() {
         super(tr("Unconnected ways."),
-              tr("This test checks if a way has an endpoint very near to another way."));
+                tr("This test checks if a way has an endpoint very near to another way."));
     }
 
@@ -89,8 +89,8 @@
                     }
                     if ("turning_circle".equals(en.get("highway"))
-                        || "bus_stop".equals(en.get("highway"))
-                        || "buffer_stop".equals(en.get("railway"))
-                        || OsmUtils.isTrue(en.get("noexit"))
-                        || en.hasKey("barrier")) {
+                            || "bus_stop".equals(en.get("highway"))
+                            || "buffer_stop".equals(en.get("railway"))
+                            || OsmUtils.isTrue(en.get("noexit"))
+                            || en.hasKey("barrier")) {
                         continue;
                     }
@@ -198,5 +198,5 @@
             this.isBoundary = !this.highway && "administrative".equals(w.get("boundary"));
             line = new Line2D.Double(n1.getEastNorth().east(), n1.getEastNorth().north(),
-                                     n2.getEastNorth().east(), n2.getEastNorth().north());
+                    n2.getEastNorth().east(), n2.getEastNorth().north());
             len = line.getP1().distance(line.getP2());
             this.n1 = n1;
@@ -288,10 +288,7 @@
             found_nodes.addAll(endnodes.search(new BBox(bounds.get(0), bounds.get(1))));
 
-            if (found_nodes == null)
-                return Collections.emptySet();
-
             for (Node n : found_nodes) {
                 if (!nearby(n, dist) ||
-                     (ds_area != null && !ds_area.contains(n.getCoor()))) {
+                        (ds_area != null && !ds_area.contains(n.getCoor()))) {
                     continue;
                 }
@@ -313,7 +310,7 @@
         public boolean isArea() {
             return w.hasKey("landuse")
-                || w.hasKey("leisure")
-                || w.hasKey("amenity")
-                || w.hasKey("building");
+            || w.hasKey("leisure")
+            || w.hasKey("amenity")
+            || w.hasKey("building");
         }
     }
@@ -322,6 +319,6 @@
         List<MyWaySegment> ret = new ArrayList<MyWaySegment>();
         if (!w.isUsable()
-            || w.hasKey("barrier")
-            || "cliff".equals(w.get("natural")))
+                || w.hasKey("barrier")
+                || "cliff".equals(w.get("natural")))
             return ret;
 
@@ -344,11 +341,13 @@
     @Override
     public void visit(Way w) {
-        ways.addAll(getWaySegments(w));
-        QuadBuckets<Node> set = endnodes;
-        if (w.hasKey("highway") || w.hasKey("railway")) {
-            set = endnodes_highway;
-        }
-        addNode(w.firstNode(), set);
-        addNode(w.lastNode(), set);
+        if (w.getNodesCount() > 0) {
+            ways.addAll(getWaySegments(w));
+            QuadBuckets<Node> set = endnodes;
+            if (w.hasKey("highway") || w.hasKey("railway")) {
+                set = endnodes_highway;
+            }
+            addNode(w.firstNode(), set);
+            addNode(w.lastNode(), set);
+        }
     }
 
