Fix race condition due to ReplaySender in async mode during setup()

The ReplaySender used to be started in async mode even before the call
to setup(). If the ReplaySender restarts the replay before the setup()
call finishes, that call may instead produce a NPE in
clientToServerHandshake().
To fix this race condition, the ReplaySender is always started in sync
mode and only switched to async after the setup() call.
This commit is contained in:
Jonas Herzig
2018-03-11 12:17:18 +01:00
parent 8ed9c75ba1
commit 34172cd737

View File

@@ -82,7 +82,7 @@ public class ReplayHandler {
markers = new ArrayList<>(replayFile.getMarkers().or(Collections.emptySet())); markers = new ArrayList<>(replayFile.getMarkers().or(Collections.emptySet()));
replaySender = new ReplaySender(this, replayFile, asyncMode); replaySender = new ReplaySender(this, replayFile, false);
setup(); setup();
@@ -90,6 +90,8 @@ public class ReplayHandler {
overlay.setVisible(true); overlay.setVisible(true);
FML_BUS.post(new ReplayOpenEvent.Post(this)); FML_BUS.post(new ReplayOpenEvent.Post(this));
replaySender.setAsyncMode(asyncMode);
} }
void restartedReplay() { void restartedReplay() {