triplea-game / triplea

TripleA is a turn based strategy game and board game engine, similar to Axis & Allies or Risk.
https://triplea-game.org/
GNU General Public License v3.0
1.33k stars 393 forks source link

ImageFactory#lambda$getImageOrThrow$0:51 - java.lang.IllegalStateException (flag Image Not Found) #11407

Open tripleabuilderbot opened 1 year ago

tripleabuilderbot commented 1 year ago

Log Message

Failed to set round icon for PlayerId named:Turkey

TripleA Version

2.6.14296

Java Version

11.0.9.1

Operating System

Windows 10

Stack Trace

Exception: java.util.concurrent.CompletionException java.lang.IllegalStateException: Image Not Found:flags/Turkey.gif
java.lang.Exception
    at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:314)
    at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319)
    at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1702)
    at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1692)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
    at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
    at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
    at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
    at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)

Exception: java.lang.IllegalStateException Image Not Found:flags/Turkey.gif
java.lang.Exception
    at games.strategy.triplea.image.ImageFactory.lambda$getImageOrThrow$0(ImageFactory.java:51)
    at java.base/java.util.Optional.orElseThrow(Optional.java:408)
    at games.strategy.triplea.image.ImageFactory.getImageOrThrow(ImageFactory.java:51)
    at games.strategy.triplea.image.FlagIconImageFactory.getFlag(FlagIconImageFactory.java:13)
    at games.strategy.triplea.ui.BottomBar.lambda$setCurrentPlayer$3(BottomBar.java:259)
    at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
    at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1692)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
    at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
    at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
    at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
    at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
asvitkine commented 6 months ago

FlagIconImageFactory.getFlag() calls ImageFactory.getImageOrThrow(), so this is expected if a map doesn't have a flag image.

The question is whether this is the right behavior - since ultimately it's a map error. I think we can just make the engine not show a flag in that case, instead of throwing up an error.

frigoref commented 2 months ago

I agree with @asvitkine this is expected behavior as of now. Therefore, it is not a bug. Furthermore, there is enough information for the user to resolved the problem himself. In addition, there ist no straightforward way how the system should react differently in this case. We would have two rewrite every place where we draw images for the option of the image not being available. This would be a lot of work and I do not see a benefit. Hence, suggesting to close this is you.