Skip to content

Commit

Permalink
Add instrumentation to diagnose cause of CME. (#11772)
Browse files Browse the repository at this point in the history
* Add instrumentation to diagnose cause of CME.

* Pass orig exception too.
  • Loading branch information
asvitkine committed Jul 12, 2023
1 parent 559f26c commit 9744b90
Showing 1 changed file with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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, e);
}
});
}
}

Expand All @@ -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,
Expand Down

0 comments on commit 9744b90

Please sign in to comment.