Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numetalfan ojectives.properties 2.5 Release Problem #8214

Closed
beelee1 opened this issue Nov 20, 2020 · 16 comments · Fixed by #8384
Closed

Numetalfan ojectives.properties 2.5 Release Problem #8214

beelee1 opened this issue Nov 20, 2020 · 16 comments · Fixed by #8384
Labels
Problem A problem, bug, defect - something to fix

Comments

@beelee1
Copy link
Contributor

beelee1 commented Nov 20, 2020

How can the problem be recreated?

Do you have any ideas for an expected fix?

Attach a Save Game

testgame-playbyemail-2.5xx-after-italys-move.zip

testgame_1.9.xx-after-italys-move.zip

If playing a prerelease, which version are you using?

Game Version:

If playing a prerelease, does this happen on the latest release?

  • [] yes
  • [] no

Is there anything else we should know?

This is created on Numetalfan's behalf. I will tell him to add more details. Here is his xml:

ww2v4-1941.xml.zip

Originally discussed here:
https://forums.triplea-game.org/topic/2435/post-turn-summary/4

@beelee1 beelee1 added the Problem A problem, bug, defect - something to fix label Nov 20, 2020
@Numetalfan
Copy link

2.5.22294: TechActivationDelegate#start:64 - java.lang.NullPointerException

Map

world_war_ii_v4

TripleA Version

2.5.22294

Java Version

11.0.4

Operating System

Windows 7

Memory

Heap utilization statistics [MB]
Used Memory: 75
Free memory: 914
Total memory: 989
Max memory: 989

Stack Trace

Exception: java.lang.NullPointerException
java.lang.Exception
	at java.base/java.util.Objects.requireNonNull(Unknown Source)
	at java.base/java.util.ImmutableCollections$Set12.<init>(Unknown Source)
	at java.base/java.util.Set.of(Unknown Source)
	at games.strategy.triplea.delegate.TechActivationDelegate.start(TechActivationDelegate.java:64)
	at games.strategy.engine.framework.ServerGame.startStep(ServerGame.java:519)
	at games.strategy.engine.framework.ServerGame.runStep(ServerGame.java:398)
	at games.strategy.engine.framework.ServerGame.startGame(ServerGame.java:297)
	at games.strategy.engine.framework.startup.launcher.LocalLauncher.launchInternal(LocalLauncher.java:82)
	at games.strategy.engine.framework.startup.launcher.LocalLauncher.lambda$launch$0(LocalLauncher.java:56)
	at java.base/java.lang.Thread.run(Unknown Source)


@Numetalfan
Copy link

hope this helps

@DanVanAtta
Copy link
Member

Thanks, that does help!

@CharlieAtlas
Copy link
Contributor

As an attempt to learn, can you walk me through what all helped here?

@Numetalfan
Copy link

Hi all,

anyone an Idea, why the game is playable until Italy and after Italys tun - it crashes.
I have to mention that my game has no US as in the original wii-v3-1941.
I have a player calles "Americans_west" and another player called "USA". This is the only thing I can imagine to be the reason for the crash, but I don't see why it works at 1.9.xx and it does not at 2.5.xx

please help

@beelee1
Copy link
Contributor Author

beelee1 commented Dec 8, 2020

@Numetalfan I replied at the triplea site

@Numetalfan
Copy link

Hi,

thats the error with 2.5 with the newest xml:

Dez. 08, 2020 10:45:07 VORM. org.triplea.game.client.HeadedGameRunner lambda$initializeClientSettingAndLogging$0
SCHWERWIEGEND: null
java.lang.NullPointerException
at java.base/java.util.Objects.requireNonNull(Unknown Source)
at java.base/java.util.ImmutableCollections$Set12.(Unknown Source)
at java.base/java.util.Set.of(Unknown Source)
at games.strategy.triplea.delegate.TechActivationDelegate.start(TechActivationDelegate.java:64)
at games.strategy.engine.framework.ServerGame.startStep(ServerGame.java:519)
at games.strategy.engine.framework.ServerGame.runStep(ServerGame.java:398)
at games.strategy.engine.framework.ServerGame.startGame(ServerGame.java:297)
at games.strategy.engine.framework.startup.launcher.LocalLauncher.launchInternal(LocalLauncher.java:82)
at games.strategy.engine.framework.startup.launcher.LocalLauncher.lambda$launch$0(LocalLauncher.java:56)
at java.base/java.lang.Thread.run(Unknown Source)

the crashing of the game ist still the same, it occurs after Italys move.

@trevan
Copy link
Contributor

trevan commented Dec 8, 2020

@Numetalfan , can you post the entire map zip or tell me which map this is based off of and what changes I need to make to it so that I can play this map? I tried loading the save but it failed because I don't have the map.

@trevan
Copy link
Contributor

trevan commented Dec 8, 2020

@CharlieAtlas , the two things that helps is the stack trace and the saved game. The stack trace shows that the error is happening at games.strategy.triplea.delegate.TechActivationDelegate.start(TechActivationDelegate.java:64) and it is because a null value is being passed into the Set.of() call there. Here's a link to the code: https://github.com/triplea-game/triplea/blob/master/game-core/src/main/java/games/strategy/triplea/delegate/TechActivationDelegate.java#L64. Looking at that line, you can see that the player variable is the only thing being passed into it, so it must be null.

That brings up two questions:

  1. Why is player null? Is it ok to be null?
  2. Did this change between 1.9 and 2.0 somehow?

I can't play the game yet, so I can't answer 1 but I can go through the git history and answer 2. Using git blame or git log, you can see how the code line changes. Going back a few changes, I see that the line was changed from Collections.singleton(player) to Set.of(player) (see https://github.com/triplea-game/triplea/blame/2339753b59c0d9b328ea95ead830215f2f78bc2a/game-core/src/main/java/games/strategy/triplea/delegate/TechActivationDelegate.java#L67). If you read the documentation for Collections.singleton, you'll see that it is fine with a null value, while Set.of isn't fine with a null value.

So, it looks like in <1.9, the code allowed for player to be null. The change in 2.0 now throws an exception when player is null.

One fix would be to change the code back to Collections.singleton. But I'd like to play the game and step through that code to try and understand why player is null. It could be that player shouldn't be null and so 1.9 was having other "hidden" bugs.

@Numetalfan
Copy link

Hi,

please download the map for testing issues

https://storage.driveonweb.de/dowdoc/c84fc4098f53f8a891526fe7c7ba3a61288eec3f04cf9286

password is TripleAAA

@Numetalfan
Copy link

https://forums.triplea-game.org/topic/2435/post-turn-summary/21

here there are some more error messages from my latest try to play the game, but it crashed again.

@Numetalfan
Copy link

...
So, it looks like in <1.9, the code allowed for player to be null. The change in 2.0 now throws an exception when player is null.

.

Thx, looks we are getting close to the missing link.
However, why does the game not directly crash at Germanys turn, it always crashes afters Italys turn - what is the reason for that?

@trevan
Copy link
Contributor

trevan commented Dec 8, 2020

@Numetalfan , I found the issue. In your xml, you have:

      <step name="american_westTechActivation" delegate="tech_activation" player="Americans_west "/>

Notice the extra space at the end of "Americans_west ". That space means that it can't find the player and so it uses a null player. If you remove the space, it will work.

I'm going to push a change that will throw an error if a player is specified but it couldn't be found.

@trevan
Copy link
Contributor

trevan commented Dec 8, 2020

@CharlieAtlas , here's some details on how I figured out the issue.

I downloaded the map files that @Numetalfan provided. I unzipped them in my downloadedMaps directory that triplea reads. I then added a breakpoint to the first line in TechActivationDelegate#start. I started the game in debug mode from my IDE and loaded the map. The breakpoint caught and I noticed that player was indeed null.

Going up the stack trace, I can see that TechActivationDelegate#start was called from ServerGame#startStep. And right before the call to #start is a call to delegate.setDelegateBridgeAndPlayer. So I put a break point at delegate.setDelegateBridgeAndPlayer and restarted the map. When the breakpoint triggered, I stepped through the setDelegateBridgeAndPlayer code to see how it found the player. I noticed that it would call GameSequence.getStep and in the debugger, I looked through all of the items in the steps list. I noticed that most of them had a valid player except the american_westTechActivation step. I then opened up the xml file, went to that definition, and looked at it closely and found the errant space.

@tvleavitt
Copy link

tvleavitt commented Dec 8, 2020 via email

@Numetalfan
Copy link

thx@all
the problem was indeed the extra space after americans_west - Oh lord.
Topic closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Problem A problem, bug, defect - something to fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants