Index: trunk/src/org/openstreetmap/josm/Main.java
===================================================================
--- trunk/src/org/openstreetmap/josm/Main.java	(revision 9086)
+++ trunk/src/org/openstreetmap/josm/Main.java	(revision 9087)
@@ -700,5 +700,5 @@
     }
 
-    private abstract class InitializationTask implements Callable<Void> {
+    private abstract static class InitializationTask implements Callable<Void> {
 
         private final String name;
Index: trunk/src/org/openstreetmap/josm/actions/AlignInLineAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/AlignInLineAction.java	(revision 9086)
+++ trunk/src/org/openstreetmap/josm/actions/AlignInLineAction.java	(revision 9087)
@@ -81,4 +81,5 @@
      * @param nodes Nodes to be aligned.
      * @return A array of two nodes.
+     * @throws IllegalArgumentException if nodes is empty
      */
     private static Node[] nodePairFurthestApart(List<Node> nodes) {
@@ -93,4 +94,8 @@
             else
                 waysRef.retainAll(ref);
+        }
+
+        if (waysRef == null) {
+            throw new IllegalArgumentException();
         }
 
Index: trunk/src/org/openstreetmap/josm/actions/DistributeAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/DistributeAction.java	(revision 9086)
+++ trunk/src/org/openstreetmap/josm/actions/DistributeAction.java	(revision 9087)
@@ -212,4 +212,5 @@
      * @param nodes nodes to distribute
      * @return Commands to execute to perform action
+     * @throws IllegalArgumentException if nodes is empty
      */
     private static Collection<Command> distributeNodes(Collection<Node> nodes) {
@@ -234,4 +235,8 @@
         }
 
+        if (nodea == null || nodeb == null) {
+            throw new IllegalArgumentException();
+        }
+
         // Remove the nodes A and B from the list of nodes to move
         nodes.remove(nodea);
@@ -266,12 +271,14 @@
             }
 
-            // First move the node to A's position, then move it towards B
-            double dx = ax - s.getEastNorth().east() + (bx-ax)*pos/num;
-            double dy = ay - s.getEastNorth().north() + (by-ay)*pos/num;
-
-            cmds.add(new MoveCommand(s, dx, dy));
-
-            //remove moved node from the list
-            nodes.remove(s);
+            if (s != null) {
+                // First move the node to A's position, then move it towards B
+                double dx = ax - s.getEastNorth().east() + (bx-ax)*pos/num;
+                double dy = ay - s.getEastNorth().north() + (by-ay)*pos/num;
+
+                cmds.add(new MoveCommand(s, dx, dy));
+
+                //remove moved node from the list
+                nodes.remove(s);
+            }
         }
 
Index: trunk/src/org/openstreetmap/josm/actions/JoinAreasAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/JoinAreasAction.java	(revision 9086)
+++ trunk/src/org/openstreetmap/josm/actions/JoinAreasAction.java	(revision 9087)
@@ -765,4 +765,5 @@
      * @param isInner - if true, reverts the direction (for multipolygon islands)
      * @return list of parts, marked with the inside orientation.
+     * @throws IllegalArgumentException if parts is empty
      */
     private List<WayInPolygon> markWayInsideSide(List<Way> parts, boolean isInner) {
@@ -796,4 +797,8 @@
                 }
             }
+        }
+
+        if (topWay == null || topNode == null) {
+            throw new IllegalArgumentException();
         }
 
@@ -855,5 +860,5 @@
 
         //iterate till full circle is reached
-        while (true) {
+        while (curWay != null) {
 
             //add cur way
Index: trunk/src/org/openstreetmap/josm/actions/UnGlueAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/UnGlueAction.java	(revision 9086)
+++ trunk/src/org/openstreetmap/josm/actions/UnGlueAction.java	(revision 9087)
@@ -418,4 +418,7 @@
                 way = w;
             }
+        }
+        if (way == null) {
+            return false;
         }
         List<Node> oldNodes = way.getNodes();
Index: trunk/src/org/openstreetmap/josm/data/osm/MultipolygonBuilder.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/osm/MultipolygonBuilder.java	(revision 9086)
+++ trunk/src/org/openstreetmap/josm/data/osm/MultipolygonBuilder.java	(revision 9087)
@@ -203,5 +203,5 @@
             while (true) {
                 boolean curWayReverse = prevNode == curWay.lastNode();
-                Node nextNode = (curWayReverse) ? curWay.firstNode() : curWay.lastNode();
+                Node nextNode = curWayReverse ? curWay.firstNode() : curWay.lastNode();
 
                 //add cur way to the list
Index: trunk/src/org/openstreetmap/josm/data/validation/tests/MultipolygonTest.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/validation/tests/MultipolygonTest.java	(revision 9086)
+++ trunk/src/org/openstreetmap/josm/data/validation/tests/MultipolygonTest.java	(revision 9087)
@@ -267,5 +267,5 @@
                         addError(r, new TestError(this, Severity.WARNING, tr("Multipolygon inner way is outside"),
                                 INNER_WAY_OUTSIDE, Collections.singletonList(r), highlights));
-                    } else {
+                    } else if (outerWay != null) {
                         highlights.add(outerWay.getNodes());
                         addError(r, new TestError(this, Severity.WARNING, tr("Intersection between multipolygon ways"),
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/relation/sort/WayConnectionTypeCalculator.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/relation/sort/WayConnectionTypeCalculator.java	(revision 9086)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/relation/sort/WayConnectionTypeCalculator.java	(revision 9087)
@@ -73,5 +73,5 @@
                 }
 
-                if (!RelationSortUtils.isOneway(m)) {
+                if (!RelationSortUtils.isOneway(m) && lastWct != null) {
                     wct.direction = determineDirection(i-1, lastWct.direction, i);
                     wct.linkPrev = (wct.direction != NONE);
Index: trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Condition.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Condition.java	(revision 9086)
+++ trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Condition.java	(revision 9087)
@@ -140,11 +140,11 @@
                 return REGEX.equals(this) ? contains : !contains;
             case ONE_OF:
-                return Arrays.asList(testString.split("\\s*;\\s*")).contains(prototypeString);
+                return testString != null && Arrays.asList(testString.split("\\s*;\\s*")).contains(prototypeString);
             case BEGINS_WITH:
-                return testString.startsWith(prototypeString);
+                return testString != null && testString.startsWith(prototypeString);
             case ENDS_WITH:
-                return testString.endsWith(prototypeString);
+                return testString != null && testString.endsWith(prototypeString);
             case CONTAINS:
-                return testString.contains(prototypeString);
+                return testString != null && testString.contains(prototypeString);
             }
 
Index: trunk/src/org/openstreetmap/josm/io/OsmReader.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/OsmReader.java	(revision 9086)
+++ trunk/src/org/openstreetmap/josm/io/OsmReader.java	(revision 9087)
@@ -370,6 +370,7 @@
         if (key == null || value == null) {
             throwException(tr("Missing key or value attribute in tag."));
-        }
-        t.put(key.intern(), value.intern());
+        } else {
+            t.put(key.intern(), value.intern());
+        }
         jumpToEnd();
     }
Index: trunk/src/org/openstreetmap/josm/io/session/SessionReader.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/session/SessionReader.java	(revision 9086)
+++ trunk/src/org/openstreetmap/josm/io/session/SessionReader.java	(revision 9087)
@@ -413,7 +413,8 @@
             if (e == null) {
                 error(tr("missing layer with index {0}", idx));
-            }
-            if (!e.hasAttribute("name")) {
+                return;
+            } else if (!e.hasAttribute("name")) {
                 error(tr("missing mandatory attribute ''name'' for element ''layer''"));
+                return;
             }
             String name = e.getAttribute("name");
@@ -421,4 +422,5 @@
             if (!e.hasAttribute("type")) {
                 error(tr("missing mandatory attribute ''type'' for element ''layer''"));
+                return;
             }
             String type = e.getAttribute("type");
