Index: /trunk/src/org/openstreetmap/josm/actions/JoinAreasAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/JoinAreasAction.java	(revision 3382)
+++ /trunk/src/org/openstreetmap/josm/actions/JoinAreasAction.java	(revision 3383)
@@ -186,8 +186,10 @@
             int i = 0;
             if(checkForTagConflicts(a, b)) return true; // User aborted, so don't warn again
-            if(joinAreas(a, a))
+            if(joinAreas(a, a)) {
                 ++i;
-            if(joinAreas(b, b))
+            }
+            if(joinAreas(b, b)) {
                 ++i;
+            }
             hadChanges = i > 0;
             cmdsCount = i;
@@ -215,4 +217,6 @@
         // Join outer ways
         Way outerWay = joinOuterWays(allWays, innerWays);
+        if (outerWay == null)
+            return true;
 
         // Fix Multipolygons if there are any
@@ -605,5 +609,9 @@
 
         commitCommands(marktr("Join Areas: Remove Short Ways"));
-        return closeWay(joinWays(join));
+        Way joinedWay = joinWays(join);
+        if (joinedWay != null)
+            return closeWay(joinedWay);
+        else
+            return null;
     }
 
@@ -648,6 +656,7 @@
             a = b;
         }
-        if((a = new CombineWayAction().combineWays(ways)) != null)
+        if((a = new CombineWayAction().combineWays(ways)) != null) {
             cmdsCount++;
+        }
         return a;
     }
@@ -676,6 +685,7 @@
             for(Node n : w.getNodes()) {
                 if(outerNodes.contains(n)) {
-                    if(!selfintersect) // allow outer point for self intersection
+                    if(!selfintersect) { // allow outer point for self intersection
                         continue wayIterator;
+                    }
                 }
                 else if(!hasInnerNodes && innerNodes.contains(n)) {
@@ -715,19 +725,24 @@
                         int i = 0;
                         // w2 cannot be closed, otherwise it would have been removed above
-                        if(w1.equals(w2))
+                        if(w1.equals(w2)) {
                             continue;
-                        if(w2.isFirstLastNode(w1.firstNode()))
+                        }
+                        if(w2.isFirstLastNode(w1.firstNode())) {
                             ++i;
-                        if(w2.isFirstLastNode(w1.lastNode()))
+                        }
+                        if(w2.isFirstLastNode(w1.lastNode())) {
                             ++i;
+                        }
                         if(i == 2) // this way closes w1 - take it!
                         {
-                            if(secondary.size() > 0)
+                            if(secondary.size() > 0) {
                                 secondary.clear();
+                            }
                             secondary.add(w2);
                             break;
                         }
-                        else if(i > 0)
+                        else if(i > 0) {
                             secondary.add(w2);
+                        }
                     }
                     if(k == 0 ? secondary.size() == 1 : secondary.size() > 0)
@@ -742,5 +757,5 @@
                             possibleWays.removeAll(joinThem);
 
-                            List<Node> nodes = joined.getNodes();
+                            //List<Node> nodes = joined.getNodes();
                             // check if we added too much
                             /*for(int i = 1; i < nodes.size()-2; ++i)
