Skip to content

Commit

Permalink
Fix #23950: Fix a StackOverflowError that occurs when a self-referenc…
Browse files Browse the repository at this point in the history
…ing relation exists

Also disable StyledTiledMapRendererTest in CI for now.

git-svn-id: https://josm.openstreetmap.de/svn/trunk@19247 0c6e7542-c601-0410-84e7-c038aed88b3b
  • Loading branch information
taylor.smock committed Oct 21, 2024
1 parent 69e5ebb commit 484845c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,12 @@ private void resetTiles(IPrimitive p) {
}
} else if (p instanceof IRelation<?>) {
for (IPrimitive member : ((IRelation<?>) p).getMemberPrimitivesList()) {
resetTiles(member);
if (member instanceof IRelation) {
resetBounds(member.getBBox()); // Avoid recursive relation issues
break;
} else {
resetTiles(member);
}
}
} else {
throw new IllegalArgumentException("Unsupported primitive type: " + p.getClass().getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.apache.commons.jcs3.access.CacheAccess;
import org.awaitility.Awaitility;
import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
Expand All @@ -37,6 +38,7 @@
/**
* Test class for {@link StyledTiledMapRenderer}
*/
@DisabledIfEnvironmentVariable(disabledReason = "Needs more work; leave enabled locally but disable on CI", named = "CI", matches = "true")
@Main
@Projection
class StyledTiledMapRendererTest {
Expand Down
16 changes: 16 additions & 0 deletions test/unit/org/openstreetmap/josm/gui/layer/OsmDataLayerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.openstreetmap.josm.data.osm.Node;
import org.openstreetmap.josm.data.osm.OsmPrimitive;
import org.openstreetmap.josm.data.osm.Relation;
import org.openstreetmap.josm.data.osm.RelationMember;
import org.openstreetmap.josm.data.osm.Way;
import org.openstreetmap.josm.gui.MainApplication;
import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils;
Expand Down Expand Up @@ -334,4 +335,19 @@ void testTicket17065() {
new OsmDataLayer(new DataSet(), null, null).destroy();
assertTrue(Logging.getLastErrorAndWarnings().stream().noneMatch(s -> s.contains("UnsupportedFlavorException")));
}

/**
* Non-regression test for #23950
*/
@Test
void testTicket23950() {
final Relation first = TestUtils.newRelation("", new RelationMember("", TestUtils.newNode("")));
final DataSet ds = new DataSet();
// This is needed to cause the condition
MainApplication.getLayerManager().addLayer(new OsmDataLayer(ds, "StyledTiledMapRendererTest#testRecursiveRelation", null));
ds.addPrimitiveRecursive(first);
first.addMember(new RelationMember("", first));
ds.setSelected(first);
}

}

0 comments on commit 484845c

Please sign in to comment.