cswinter / CodeCraftGame

The CodeCraft programming game.
http://www.codecraftgame.org
35 stars 10 forks source link

NPE when running publishLocal sbt task #6

Closed barrybecker4 closed 6 years ago

barrybecker4 commented 6 years ago

When I run publishLocal, it appears to work, but in the log, I see the following NullPinterException. Is this expected? Does it indicate a problem, or can it be safely ignored?

[warn] This usage is deprecated and will be removed in sbt 1.0. at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) java.lang.NullPointerException at cwinter.codecraft.core.multiplayer.MultiplayerServer$$anonfun$cwinter$codecraft$core$multiplayer$MultiplayerServer$$stopGame$2$$anon$2.run(Server.scala:251) at scala.concurrent.impl.ExecutionContextImpl$AdaptedForkJoinTask.exec(ExecutionContextImpl.scala:121) at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)

cswinter commented 6 years ago

This is not expected, and publishLocal seems to work fine in my checkout. I think publishLocal is running all tests and the MultiplayerSemanticsTest is crashing. Are you able to run sbt test successfully? My best guess as to why is that the test is being prevented from creating and connecting to a multiplayer server on localhost (which I suppose there should better error handling/reporting for).

barrybecker4 commented 6 years ago

I ran publishLocal again and it seems to be OK (I do not see the NPE) so I will close this issue. When I run sbt test, I see the following output - which is probably ok (in spite of 2 warnings and the final akka error).

.... [info] - should not cause the drones to move through each other [INFO] [10/22/2017 18:55:48.919] [default-akka.actor.default-dispatcher-3] [akka://default/user/IO-UHTTP/listener-0] Bound to /0.0.0.0:8080 [INFO] [10/22/2017 18:55:48.921] [default-akka.actor.default-dispatcher-4] [akka://default/deadLetters] Message [akka.io.Tcp$Bound] from Actor[akka://default/user/IO-UHTTP/listener-0#-135525705] to Actor[akka://default/deadLetters] was not delivered. [1] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'. [WARN] [10/22/2017 18:55:50.228] [default-akka.actor.default-dispatcher-2] [akka://default/user/IO-UHTTP/listener-0/0] Illegal request header: Illegal 'Origin' header: Illegal origin, unexpected character '8' at position 10: localhost:8080 ^

[WARN] [10/22/2017 18:55:50.360] [default-akka.actor.default-dispatcher-4] [akka://default/user/IO-UHTTP/listener-0/1] Illegal request header: Illegal 'Origin' header: Illegal origin, unexpected character '8' at position 10: localhost:8080 ^

[info] ReplayTest: [info] A replayer [info] - should work [info] MultiplayerSemanticsTest: [info] A multiplayer game (map -1970076892) [info] - should yield the same output as an identical singleplayer game Game has ended: ServerStopped [info] Run completed in 5 seconds, 551 milliseconds. [info] Total number of tests run: 15 [info] Suites: completed 8, aborted 0 [info] Tests: succeeded 15, failed 0, canceled 0, ignored 0, pending 0 [info] All tests passed. [INFO] [10/22/2017 18:55:52.992] [default-akka.actor.default-dispatcher-7] [akka://default/user/IO-UHTTP/listener-0/0] Message [akka.dispatch.sysmsg.Suspend] from Actor[akka://default/user/IO-UHTTP/listener-0/0#-1023699830] to Actor[akka://default/user/IO-UHTTP/listener-0/0#-1023699830] was not delivered. [2] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'. [INFO] [10/22/2017 18:55:52.992] [default-akka.actor.default-dispatcher-7] [akka://default/user/IO-UHTTP/listener-0/1] Message [akka.dispatch.sysmsg.Suspend] from Actor[akka://default/user/IO-UHTTP/listener-0/1#-1313032560] to Actor[akka://default/user/IO-UHTTP/listener-0/1#-1313032560] was not delivered. [3] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'. [ERROR] [10/22/2017 18:55:52.997] [default-akka.actor.default-dispatcher-7] [akka://default/user/IO-UHTTP/listener-0] Monitored actor [Actor[akka://default/user/websocket#-827850305]] terminated (akka.actor.DeathPactException) [success] Total time: 16 s, completed Oct 22, 2017 6:55:53 PM

barrybecker4 commented 6 years ago

I ran publishLocal a few more times, and did still see the NPE occasionally, so it does appear to be some sort of intermittent problem. Then I just ran it a bunch more times and don't see it anymore, so I'm not sure what is going on.

cswinter commented 6 years ago

Yay, race conditions. Could be something to do with how I shut down the Akka actor that controls the websocket, the correct way of doing that still eludes me. If it keeps popping up adding a null check on the context or rawConnection variable should work as a bandaid.