### Eclipse Workspace Patch 1.0
#P josm
diff --git src/org/openstreetmap/josm/actions/AlignGridRotationAction.java src/org/openstreetmap/josm/actions/AlignGridRotationAction.java
index 5f7459a..e279c86 100644
--- src/org/openstreetmap/josm/actions/AlignGridRotationAction.java
+++ src/org/openstreetmap/josm/actions/AlignGridRotationAction.java
@@ -25,6 +25,8 @@
  * @since 19640
  */
 public class AlignGridRotationAction extends JosmAction {
+    
+    private static final EastNorth[] EMPTY_DIRECTION = new EastNorth[0];
 
     /**
      * Constructs a new {@code AlignGridRotationAction}.
@@ -43,28 +45,33 @@
      */
     static EastNorth[] getSelectedDirection(DataSet ds) {
         if (ds == null) {
-            return null;
+            return EMPTY_DIRECTION;
         }
-        Collection<Way> ways = ds.getSelectedWays();
-        Collection<Node> nodes = ds.getSelectedNodes();
+        final Collection<Way> ways = ds.getSelectedWays();
+        final Collection<Node> nodes = ds.getSelectedNodes();
+        
+        final int waysSize = ways.size();
+        final int nodesSize = nodes.size();
+        
         Node a = null;
         Node b = null;
-        if (ways.size() == 1 && nodes.isEmpty()) {
-            Way w = ways.iterator().next();
+        if (waysSize == 1 && nodesSize ==0) {
+            final Way w = ways.iterator().next();
             if (w.getNodesCount() >= 2) {
                 a = w.firstNode();
                 b = w.isClosed() ? w.getNode(1) : w.lastNode();
             }
-        } else if (nodes.size() == 2 && ways.isEmpty()) {
-            Iterator<Node> it = nodes.iterator();
+        } else if (nodesSize == 2 && waysSize ==0) {
+            final Iterator<Node> it = nodes.iterator();
             a = it.next();
             b = it.next();
         }
         if (a == null || b == null || !a.isLatLonKnown() || !b.isLatLonKnown()) {
-            return null;
+            return EMPTY_DIRECTION;
         }
-        EastNorth[] result = {a.getEastNorth(), b.getEastNorth()};
-        return result[0].equalsEpsilon(result[1], 1e-9) ? null : result;
+        
+        final EastNorth[] result = {a.getEastNorth(), b.getEastNorth()};
+        return result[0].equalsEpsilon(result[1], 1e-9) ? EMPTY_DIRECTION : result;
     }
 
     /**
@@ -85,7 +92,7 @@
 
     @Override
     protected void updateEnabledState() {
-        setEnabled(getSelectedDirection(getLayerManager().getEditDataSet()) != null);
+        setEnabled(getSelectedDirection(getLayerManager().getEditDataSet()).length > 0);
     }
 
     @Override
@@ -95,8 +102,8 @@
 
     @Override
     public void actionPerformed(ActionEvent e) {
-        EastNorth[] direction = getSelectedDirection(getLayerManager().getEditDataSet());
-        if (direction == null) {
+        final EastNorth[] direction = getSelectedDirection(getLayerManager().getEditDataSet());
+        if (direction.length == 0) {
             return;
         }
         MapGridPaintable.ROTATION.put(rotationOf(direction[0], direction[1]));
diff --git test/unit/org/openstreetmap/josm/actions/GridActionsTest.java test/unit/org/openstreetmap/josm/actions/GridActionsTest.java
index 37e9d66..557abca 100644
--- test/unit/org/openstreetmap/josm/actions/GridActionsTest.java
+++ test/unit/org/openstreetmap/josm/actions/GridActionsTest.java
@@ -1,6 +1,7 @@
 // License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.actions;
 
+import static org.junit.Assert.assertArrayEquals;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertNull;
@@ -164,7 +165,7 @@
             ds.addPrimitive(w);
 
             ds.setSelected();
-            assertNull(AlignGridRotationAction.getSelectedDirection(ds));
+            assertArrayEquals(new EastNorth[0], AlignGridRotationAction.getSelectedDirection(ds));
             AlignGridRotationAction action = new AlignGridRotationAction();
             assertFalse(action.isEnabled());
             ds.setSelected(a);
