Index: trunk/test/data/regress/10511/10511_mini.osm
===================================================================
--- trunk/test/data/regress/10511/10511_mini.osm	(revision 7534)
+++ trunk/test/data/regress/10511/10511_mini.osm	(revision 7534)
@@ -0,0 +1,30 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<osm version='0.6' upload='true' generator='JOSM'>
+  <node id='-68' action='modify' visible='true' lat='55.18135539257' lon='-7.98285399308'>
+    <tag k='ref' v='D' />
+  </node>
+  <node id='-66' action='modify' visible='true' lat='55.1808426071' lon='-7.98215939005'>
+    <tag k='ref' v='B' />
+  </node>
+  <node id='-64' action='modify' visible='true' lat='55.18081456395' lon='-7.98219447101'>
+    <tag k='ref' v='C' />
+  </node>
+  <node id='-62' action='modify' visible='true' lat='55.18078652078' lon='-7.98196293666'>
+    <tag k='ref' v='A' />
+  </node>
+  <node id='-60' action='modify' visible='true' lat='55.18061024901' lon='-7.98460804115'>
+    <tag k='ref' v='E' />
+  </node>
+  <way id='-70' action='modify' visible='true'>
+    <nd ref='-60' />
+    <nd ref='-62' />
+    <nd ref='-66' />
+    <nd ref='-62' />
+    <nd ref='-66' />
+    <nd ref='-64' />
+    <nd ref='-66' />
+    <nd ref='-68' />
+    <nd ref='-60' />
+    <tag k='building' v='yes' />
+  </way>
+</osm>
Index: trunk/test/unit/org/openstreetmap/josm/actions/JoinAreasActionTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/actions/JoinAreasActionTest.java	(revision 7534)
+++ trunk/test/unit/org/openstreetmap/josm/actions/JoinAreasActionTest.java	(revision 7534)
@@ -0,0 +1,49 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.actions;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openstreetmap.josm.JOSMFixture;
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.TestUtils;
+import org.openstreetmap.josm.data.osm.DataSet;
+import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.gui.layer.OsmDataLayer;
+import org.openstreetmap.josm.gui.preferences.ToolbarPreferences;
+import org.openstreetmap.josm.io.IllegalDataException;
+import org.openstreetmap.josm.io.OsmReader;
+
+/**
+ * Unit tests of {@link JoinAreasAction} class.
+ */
+public class JoinAreasActionTest {
+
+    /**
+     * Setup test.
+     */
+    @BeforeClass
+    public static void setUp() {
+        JOSMFixture.createUnitTestFixture().init();
+        Main.toolbar = new ToolbarPreferences();
+        new MainApplication();
+        Main.main.createMapFrame(null, null);
+    }
+
+    /**
+     * Non-regression test for bug #10511.
+     * @throws IOException if any I/O error occurs
+     * @throws IllegalDataException if OSM parsing fails
+     */
+    @Test
+    public void testTicket10511() throws IOException, IllegalDataException {
+        try (InputStream is = new FileInputStream(TestUtils.getRegressionDataFile(10511, "10511_mini.osm"))) {
+            DataSet ds = OsmReader.parseDataSet(is, null);
+            Main.map.mapView.addLayer(new OsmDataLayer(ds, null, null));
+            new JoinAreasAction().join(ds.getWays());
+        }
+    }
+}
