Skip to content

Commit

Permalink
Fix a RejectedExecutionException. (#12007)
Browse files Browse the repository at this point in the history
* Fix a RejectedExecutionException.

* Keep message type.
  • Loading branch information
asvitkine authored Oct 1, 2023
1 parent 9b72616 commit 0f16441
Showing 1 changed file with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Supplier;
Expand Down Expand Up @@ -706,14 +707,7 @@ public FightBattleDetails getBattle(
public void notifyError(final String message) {
final String displayMessage =
LocalizeHtml.localizeImgLinksInHtml(message, uiContext.getMapLocation());
messageAndDialogThreadPool.submit(
() ->
EventThreadJOptionPane.showMessageDialogWithScrollPane(
TripleAFrame.this,
displayMessage,
"Error",
JOptionPane.ERROR_MESSAGE,
getUiContext().getCountDownLatchHandler()));
showMessageDialog(displayMessage, "Error", JOptionPane.ERROR_MESSAGE);
}

/** We do NOT want to block the next player from beginning their turn. */
Expand Down Expand Up @@ -742,14 +736,22 @@ public void notifyMessage(final String message, final String title) {
}
final String displayMessage =
LocalizeHtml.localizeImgLinksInHtml(message, uiContext.getMapLocation());
messageAndDialogThreadPool.submit(
() ->
EventThreadJOptionPane.showMessageDialogWithScrollPane(
TripleAFrame.this,
displayMessage,
title,
JOptionPane.INFORMATION_MESSAGE,
getUiContext().getCountDownLatchHandler()));
showMessageDialog(displayMessage, title, JOptionPane.INFORMATION_MESSAGE);
}

private void showMessageDialog(String displayMessage, String title, int type) {
try {
messageAndDialogThreadPool.submit(
() ->
EventThreadJOptionPane.showMessageDialogWithScrollPane(
TripleAFrame.this,
displayMessage,
title,
type,
getUiContext().getCountDownLatchHandler()));
} catch (RejectedExecutionException e) {
// The thread pool may have been shutdown. Nothing to do.
}
}

/**
Expand Down

0 comments on commit 0f16441

Please sign in to comment.