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 392 forks source link

Bot crash when joining game #2609

Closed RoiEXLab closed 6 years ago

RoiEXLab commented 6 years ago

When joining a bot in the latest version this Exception occurs on the bot side:

SEVERE: Error writing object:Message header. msg:Invocation results for method id:GUID:1fa50d35143b3c20:179a05b9:15fc147684b:-8000:503 results:Return value: '[1914-COW-Empires, 270BC, 270BC 40%, 270BC Cernel Variant, =ATARI=, =TC.ARENA_FFA=, =TC.BLITZKRIEG2=, =TC.EUTOPIA=, =TC.FRONT=, =TC.ISLANDS.FFA=, =TC.ISLANDS=, =TC.NAVAL ARENA FFA=, =TC.NAVAL ARENA=, =TC.RIVER=, =TC.SEABLITZ North VS South=, Age of Tribes: Classical, Age of Tribes: Cold War, Age of Tribes: Modern, Age of Tribes: Primeval, Age of Tribes: Renaissance, Age_Of_The_Sturlungs_0.0.2, Ancient Times, Arnhem, Barbarossa, Battle of Aventurica, Battle of Jutland, Big World 2 : Balance of Power, Big World 2 : Rise of the Axis, Big World : 1942, Big World : 1942 v3 Rules, Big World : June 1942, Big World : NekahNet's 1939, Big World : Small's 1939, Blue vs. Gray, Camp David: 1948 Arab-Israeli War, Camp David: 1956 Suez Crisis, Camp David: 1967 Six-Day War, Camp David: 1973 Yom Kippur War, Capture The Flag, Caribbean Trade War, Civil War: A House Divided, Civil War: Eastern Campaigns, Classic: Anzio, Classic: Battleship Row, Classic: Four If By Sea, Classic: Gold, Classic: Iron Blitz 1939A Historical, Classic: Iron Blitz 1939B RussiaInTheAxis, Classic: Iron Blitz 1939C US Stands Apart, Classic: Iron Blitz 1942A Russia Neutral, Classic: Iron Blitz 1945A Russia And Japan, Classic: Iron Blitz 1945B Aggressive Russia, Classic: Iron Blitz 2rd Edition, Classic: Iron Blitz 3rd Edition, Classic: Iron Blitz Cold War, Classic: Kremlin, Classic: Omaha, Classic: Sword, Classic: Utah, Cold War, Cold War Asia: 1948, Cold War Asia: 1948+Japan, D-Day, D-Day 2, Diplomacy, Diplomacy: FFA Great War, Diplomacy: FFA V3 Rules, Diplomacy: WW1, Domination, Domination 1901, Domination 1914 No Man's Land, Domination 1914-Weltpolitik, Domination_1914_Blood_And_Steel, Dragon War, Eastern Front vs AI, Eastern Front vs Humans, Elemental_Forces, Empire, Europe - Alpha, Europe - Alpha v3 Rules, Feudal Japan, Feudal Japan Warlords 3 Player, Feudal Japan Warlords 4 or 2 Player, Feudal Japan Warlords 5 Player, First Punic War, Game_of_Thrones, Global 1940 House Rules, Global 1940 House Rules with Canada, Global War, Global War 2, Global War v3 Rules, Great War, Greyhawk, Greyhawk Wars, HexGlobe FFA, HexGlobe FFA w TWW, Invasion U.S.A., Invasion U.S.A. - Apocalypse, Iron War, Iron War: Europe, Jurassic, Large Middle Earth - Third Age All Stars, Lord of the Rings: Middle Earth, Minimap, NWO Smalls, NWO_Eastern_Front, Napoleonic Empires, Napoleonic Empires: FFA 5 Player, Napoleonic Empires: FFA 8 Player, Neusch. DH's Ultimate FFA, Neuschwabenland, Neuschwabenland FFA, Neuschwabenland North vs South, New World Order, New World Order 1939 Lebowski, New World Order 5 Nations, NewWorldOrder1915Lebowski, Ozteas 1941 Global Setup, Pacific, Pacific Theater Solo Challenge, Pact of Steel, Pact of Steel 2, Pact of Steel v3 rules, Pact of Steel: China Added, Red Sun Over China, Rome Total War, Six Army Free For All, Star Trek: Dilithium War, Star Wars: Galactic War, Star Wars: Galactic War (4 teams), Star Wars: Galactic War (FFA), Star Wars: Tatooine War, Star Wars: Tatooine War (4 teams), Star Wars: Tatooine War (FFA), Steampunk 1915, Stellar Forces, TAW_Carthage_Campaign, TAW_Roman_Campaign, Test1, The Great Northern War, The Rising Sun, Total World War: December 1941, Total_Ancient_War, Tutorial, Twilight Imperium 1v1, Twilight Imperium 5player, UNDER SIEGE: America, Ultimate P Talibush 7 Alliances, Ultimate P Talibush FFA, Ultimate P Talibush Mod, Ultimate Pants, Ultimate Pants:  ww2v3, Ultimate World, Ultimate World v3 Rules, Ultimate World: Expanded, Ultimate World: Revised, Ur-Quan Slave War: Masters Edition, WAW 1940, WW2 Phillipines - v2, WW2v4 Six Army Free For All, WW2v4 Six Army Free For All v2, WWII Europe 1940 Original SeaLion-Balanced, WWII Pacific 1940 Original J1-Balanced, WWII Revised 7 powers by hoshi head, WWIIv3 1939 - 11 Nations Mod, WWIIv3 1940 - 11 Nations Mod, WWIIv3 1941 - 11 Nations Mod, WWIIv3 1941 China Mod, WWIIv3 1941 Free Tech, WWIIv3 1941 Move-Buy-Move, WWIIv3 1941 Move-Then-Buy, WWIIv3 1941 Tech Advance, WWIIv3 1941 UK Factory, WWIIv3 1942 - 11 Nations Mod, WWIIv3 1942 Move-Buy-Move, WWIIv3 1942 Move-Then-Buy, WWIIv3 3 Alliances, WWIIv3 FFA, War of the Lance, War of the Relics, Warlords FFA, World At War, World At War Variant - FUEL-AA-Range, World At War Variant - v3, World At War Variant - vXXX, World At War Variant - vXXX old, World War 2010, World War II Classic, World War II Classic 3rd Edition, World War II Europe 1940 2nd Edition, World War II Europe 1940 Original, World War II Global 1940 2nd Edition, World War II Global 1940 2nd Edition with Combat Move First, World War II Global 1940 Balanced Mod3, World War II Global 1940 Balanced Mod3 with Combat Move First, World War II Global 1940 Original, World War II Global 1942 2nd Edition, World War II Pacific 1940 2nd Edition, World War II Pacific 1940 Original, World War II Revised, World War II Revised LHTR, World War II v3 1941, World War II v3 1942, World War II v4, World War II v5 1942 SE TR, World War II v5 1942 Second Edition, World War II v6 1941, Zombieland]', exception: none to:prastle port:54083 ip:<redacted> from:Bot61_GA_USA port:4061 ip:45.79.205.242
java.io.NotSerializableException: java.util.TreeMap$KeySet
     at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184)
     at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
     at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)
     at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
     at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
     at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
     at games.strategy.engine.message.RemoteMethodCallResults.writeExternal(RemoteMethodCallResults.java:43)
     at games.strategy.engine.message.unifiedmessenger.InvocationResults.writeExternal(InvocationResults.java:37)
     at games.strategy.net.nio.Encoder.write(Encoder.java:86)
     at games.strategy.net.nio.Encoder.lambda$write$541(Encoder.java:41)
     at games.strategy.io.IoUtils.writeToMemory(IoUtils.java:68)
     at games.strategy.net.nio.Encoder.write(Encoder.java:41)
     at games.strategy.net.nio.NioSocket.send(NioSocket.java:68)
     at games.strategy.net.ServerMessenger.send(ServerMessenger.java:154)
     at games.strategy.engine.message.UnifiedMessengerHub.send(UnifiedMessengerHub.java:47)
     at games.strategy.engine.message.UnifiedMessengerHub.sendResultsToCaller(UnifiedMessengerHub.java:119)
     at games.strategy.engine.message.UnifiedMessengerHub.results(UnifiedMessengerHub.java:110)
     at games.strategy.engine.message.UnifiedMessengerHub.messageReceived(UnifiedMessengerHub.java:99)
     at games.strategy.engine.message.unifiedmessenger.UnifiedMessenger.send(UnifiedMessenger.java:224)
     at games.strategy.engine.message.unifiedmessenger.UnifiedMessenger.lambda$messageReceived$356(UnifiedMessenger.java:288)
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
     at java.lang.Thread.run(Thread.java:748)

I currently don't have the time to dig into it, but this defenitely needs fixing

ssoloff commented 6 years ago

This seems to fix it:

diff --git a/src/main/java/games/strategy/engine/framework/headlessGameServer/AvailableGames.java b/src/main/java/games/strategy/engine/framework/headlessGameServer/AvailableGames.java
index c15b3e74e..6951556fd 100644
--- a/src/main/java/games/strategy/engine/framework/headlessGameServer/AvailableGames.java
+++ b/src/main/java/games/strategy/engine/framework/headlessGameServer/AvailableGames.java
@@ -48,7 +48,7 @@ public class AvailableGames {
   }

   Set<String> getGameNames() {
-    return Collections.unmodifiableSet(availableGames.keySet());
+    return new HashSet<>(availableGames.keySet());
   }

   Set<String> getAvailableMapFolderOrZipNames() {

AvailableGames#getGameNames() is called by HeadlessGameServer#getAvailableGames(), which is called by getAvailableGames() in the anonymous implementation of IServerStartupRemote stored in ServerModel#m_serverStartupRemote. I'm pretty sure the return value of that method is then serialized during RMI.

Not sure if there's a better fix. You could move the defensive copy to the anonymous IServerStartupRemote implementation, but there should probably be a comment noting why it is necessary.

Also, in general, callers assume they get a mutable copy of a collection returned by a method unless the Javadocs state otherwise. For those methods in AvailableGames that return immutable collections, that should probably be noted in the Javadocs.

prastle commented 6 years ago

@ssoloff If you could implement those changes and help me test with the GA server I would appreciate it greatly! A few new maps using the new code cant be played unless the bots get the new engine. Thanks! Pras

ssoloff commented 6 years ago

@prastle I can make that change and merge it now, but I am going to be unavailable for 5-6 hours beginning in about 15 minutes.

prastle commented 6 years ago

Ok so make the change hopefully Roir or dan is back to test

prastle commented 6 years ago

ATM unfortunately a second problem has been found.

Only you three have sudo to the bots

prastle commented 6 years ago

triplea user cant update

ssoloff commented 6 years ago

2610 has been merged. Fix should be available in the next pre-release build (7534).

RoiEXLab commented 6 years ago

@prastle I can apply the update to the bots, no worries

prastle commented 6 years ago

Ok so since it is the middle of the week please apply and relaunch Ga bots when you have time @RoiEXLab . Hopefully we can test them with the new tww or frosti map

prastle commented 6 years ago

Loads fine with trains ty @RoiEXLab @ssoloff

prastle commented 6 years ago

Bot 63 mia for some reason but I will try to relaunch it later. TY for all of your hard work! We will use this as the test bots. :)