From 5bffc8d80b1a4013b4a626c661f6ed5bd097fd7b Mon Sep 17 00:00:00 2001 From: asvitkine Date: Wed, 12 Jul 2023 15:15:27 -0400 Subject: [PATCH 1/2] Add instrumentation to diagnose cause of CME. --- .../engine/framework/HistorySynchronizer.java | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/game-app/game-core/src/main/java/games/strategy/engine/framework/HistorySynchronizer.java b/game-app/game-core/src/main/java/games/strategy/engine/framework/HistorySynchronizer.java index e33625f17ec..b4d722c08a0 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/framework/HistorySynchronizer.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/framework/HistorySynchronizer.java @@ -5,6 +5,7 @@ import games.strategy.engine.data.GamePlayer; import games.strategy.engine.history.EventChild; import games.strategy.engine.history.HistoryWriter; +import java.util.ConcurrentModificationException; import javax.swing.SwingUtilities; /** @@ -34,7 +35,20 @@ public void gameDataChanged(final Change change) { public void startHistoryEvent(final String event, final Object renderingData) { startHistoryEvent(event); if (renderingData != null) { - setRenderingData(renderingData); + SwingUtilities.invokeLater( + () -> { + try { + final Object translatedRenderingData = translateIntoMyData(renderingData); + gameData + .getHistory() + .getHistoryWriter() + .setRenderingData(translatedRenderingData); + } catch (ConcurrentModificationException e) { + // Instrumented to diagnose what exactly is causing this. + throw new ConcurrentModificationException( + "Failed to map renderingData=" + renderingData + " for event=" + event); + } + }); } } @@ -56,14 +70,6 @@ public void addChildToEvent(final String text, final Object renderingData) { }); } - void setRenderingData(final Object renderingData) { - SwingUtilities.invokeLater( - () -> { - final Object translatedRenderingData = translateIntoMyData(renderingData); - gameData.getHistory().getHistoryWriter().setRenderingData(translatedRenderingData); - }); - } - @Override public void stepChanged( final String stepName, From f7ccdad476bd69ac68037b60233d66c3b7f9e89f Mon Sep 17 00:00:00 2001 From: asvitkine Date: Wed, 12 Jul 2023 15:46:51 -0400 Subject: [PATCH 2/2] Pass orig exception too. --- .../games/strategy/engine/framework/HistorySynchronizer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/game-app/game-core/src/main/java/games/strategy/engine/framework/HistorySynchronizer.java b/game-app/game-core/src/main/java/games/strategy/engine/framework/HistorySynchronizer.java index b4d722c08a0..d9c3197af0f 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/framework/HistorySynchronizer.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/framework/HistorySynchronizer.java @@ -46,7 +46,7 @@ public void startHistoryEvent(final String event, final Object renderingData) { } catch (ConcurrentModificationException e) { // Instrumented to diagnose what exactly is causing this. throw new ConcurrentModificationException( - "Failed to map renderingData=" + renderingData + " for event=" + event); + "Failed to map renderingData=" + renderingData + " for event=" + event, e); } }); }