Index: /trunk/src/org/openstreetmap/josm/gui/layer/gpx/DownloadAlongTrackAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/layer/gpx/DownloadAlongTrackAction.java	(revision 9816)
+++ /trunk/src/org/openstreetmap/josm/gui/layer/gpx/DownloadAlongTrackAction.java	(revision 9817)
@@ -81,4 +81,7 @@
                 latcnt++;
             }
+        }
+        if (latcnt == 0) {
+            return null;
         }
         double avglat = latsum / latcnt;
@@ -190,5 +193,8 @@
     @Override
     public void actionPerformed(ActionEvent e) {
-        Main.worker.submit(createTask());
+        PleaseWaitRunnable task = createTask();
+        if (task != null) {
+            Main.worker.submit(task);
+        }
     }
 }
Index: /trunk/test/data/empty.gpx
===================================================================
--- /trunk/test/data/empty.gpx	(revision 9817)
+++ /trunk/test/data/empty.gpx	(revision 9817)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
+<gpx xmlns="http://www.topografix.com/GPX/1/1" creator="custom" version="1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
+
+  <metadata>
+    <time>1970-01-01T00:00:00Z</time>
+    <bounds maxlat="0.0" maxlon="0.0" minlat="0.0" minlon="0.0"/>
+  </metadata>
+
+</gpx>
Index: /trunk/test/unit/org/openstreetmap/josm/gui/layer/gpx/DownloadAlongTrackActionTest.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/gui/layer/gpx/DownloadAlongTrackActionTest.java	(revision 9816)
+++ /trunk/test/unit/org/openstreetmap/josm/gui/layer/gpx/DownloadAlongTrackActionTest.java	(revision 9817)
@@ -3,4 +3,5 @@
 
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 
 import org.junit.BeforeClass;
@@ -28,17 +29,11 @@
     }
 
-    /**
-     * Test action.
-     * @throws Exception if an error occurs
-     */
-    @Test
-    public void testDownload() throws Exception {
-        final OsmDataLayer layer = new OsmDataLayer(new DataSet(), getClass().getName(), null);
+    private static PleaseWaitRunnable createTask(String file) throws Exception {
+        final OsmDataLayer layer = new OsmDataLayer(new DataSet(), DownloadAlongTrackActionTest.class.getName(), null);
         try {
             Main.main.addLayer(layer);
             // Perform action
-            final GpxData gpx = GpxReaderTest.parseGpxData(TestUtils.getTestDataRoot() + "minimal.gpx");
-            PleaseWaitRunnable task = new DownloadAlongTrackAction(gpx).createTask();
-            assertNotNull(task);
+            final GpxData gpx = GpxReaderTest.parseGpxData(TestUtils.getTestDataRoot() + file);
+            return new DownloadAlongTrackAction(gpx).createTask();
         } finally {
             // Ensure we clean the place before leaving, even if test fails.
@@ -46,3 +41,21 @@
         }
     }
+
+    /**
+     * Test action with nominal data set.
+     * @throws Exception if an error occurs
+     */
+    @Test
+    public void testDownload() throws Exception {
+        assertNotNull(createTask("minimal.gpx"));
+    }
+
+    /**
+     * Test action with empty data set.
+     * @throws Exception if an error occurs
+     */
+    @Test
+    public void testDownloadEmpty() throws Exception {
+        assertNull(createTask("empty.gpx"));
+    }
 }
