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

NPE while loading a save-file #4021

Closed
Dirk-c-Walter opened this issue Dec 5, 2022 · 4 comments · Fixed by #4023
Closed

NPE while loading a save-file #4021

Dirk-c-Walter opened this issue Dec 5, 2022 · 4 comments · Fixed by #4023
Assignees
Labels

Comments

@Dirk-c-Walter
Copy link
Contributor

Environment

Linux Megamek 0.49.10, java 11.0.13

Description

Loading a save game fails. After some digging through the logs and the error message it seems to be unhappy about some Arrow IV attacks made by infantry.

Files

night.sav.gz

Log message bellow;
19:35:13,427 INFO [megamek.MegaMek] {main}
megamek.MegaMek.initializeLogging(MegaMek.java:115) - Starting MegaMek v0.49.10
Build Date: N/A
Today: 2022-12-04
Origin Project: MegaMek
Java Vendor: Ubuntu
Java Version: 11.0.13
Platform: Linux 5.11.0-49-generic (amd64)
System Locale: en_US
Total memory available to MegaMek: 2 GB

19:35:13,429 INFO [megamek.MegaMek] {main}
megamek.MegaMek.handleLegacyLogging(MegaMek.java:128) - Redirecting System.out, System.err, and Throwable::printStackTrace output to legacy.log

19:35:13,546 INFO [megamek.client.ui.preferences.SuitePreferences] {main}
megamek.client.ui.preferences.SuitePreferences.loadFromFile(SuitePreferences.java:118) - Loading user preferences from: mmconf/mm.preferences

19:35:13,583 INFO [megamek.client.ui.preferences.SuitePreferences] {main}
megamek.client.ui.preferences.SuitePreferences.loadFromFile(SuitePreferences.java:138) - Finished loading user preferences

19:35:13,815 INFO [megamek.MegaMek] {main}
megamek.MegaMek.startGUI(MegaMek.java:315) - Starting MegaMekGUI.

19:35:21,528 ERROR [megamek.client.ui.swing.MegaMekGUI] {AWT-EventQueue-0}
megamek.client.ui.swing.MegaMekGUI.loadGame(MegaMekGUI.java:548) - Unable to load file: /home/dirk/apps/mekhq-0.49.10/savegames/night.sav.gz
com.thoughtworks.xstream.converters.ConversionException: Failed calling method
---- Debugging information ----
message : Failed calling method
cause-exception : java.lang.NullPointerException
cause-message : null
method : megamek.common.weapons.ArtilleryWeaponIndirectFireHandler.readObject()
class : megamek.common.weapons.ArtilleryWeaponIndirectFireHandler
required-type : megamek.common.weapons.ArtilleryWeaponIndirectFireHandler
converter-type : com.thoughtworks.xstream.converters.reflection.SerializableConverter
line number : 545411
class[1] : java.util.Vector
required-type[1] : java.util.Vector
converter-type[1] : com.thoughtworks.xstream.converters.collections.CollectionConverter
class[2] : megamek.common.Game
required-type[2] : megamek.common.Game
converter-type[2] : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
version : 1.4.14

at com.thoughtworks.xstream.core.util.SerializationMembers.callReadObject(SerializationMembers.java:136)
at com.thoughtworks.xstream.converters.reflection.SerializableConverter.doUnmarshal(SerializableConverter.java:443)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:277)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:72)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readBareItem(AbstractCollectionConverter.java:132)
at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readItem(AbstractCollectionConverter.java:117)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.addCurrentElementToCollection(CollectionConverter.java:98)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.populateCollection(CollectionConverter.java:91)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.populateCollection(CollectionConverter.java:85)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.unmarshal(CollectionConverter.java:80)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:72)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:499)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:425)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:277)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:72)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:134)
at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1404)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1383)
at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1277)
at megamek.client.ui.swing.MegaMekGUI.loadGame(MegaMekGUI.java:546)
at megamek.client.ui.swing.MegaMekGUI.lambda$new$0(MegaMekGUI.java:935)
at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1967)
at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2308)
at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405)
at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262)
at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:279)
at java.desktop/java.awt.Component.processMouseEvent(Component.java:6635)
at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3342)
at megamek.client.ui.swing.widget.MegamekButton.processMouseEvent(MegamekButton.java:242)
at java.desktop/java.awt.Component.processEvent(Component.java:6400)
at java.desktop/java.awt.Container.processEvent(Container.java:2263)
at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5011)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4843)
at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4918)
at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4547)
at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4488)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2307)
at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2772)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4843)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:772)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:743)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

Caused by: java.lang.NullPointerException
at megamek.common.weapons.WeaponHandler.readObject(WeaponHandler.java:435)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at com.thoughtworks.xstream.core.util.SerializationMembers.callReadObject(SerializationMembers.java:132)
... 65 more

@Windchild292
Copy link
Contributor

Can you please post the full log files (legacy, MM, and, if related, MHQ) from loading this file? This appears to be a critical bug at first read.

@Windchild292 Windchild292 added Needs More Info For when an issue needs more information from the user reporting Blocker labels Dec 5, 2022
@Dirk-c-Walter
Copy link
Contributor Author

I've tracked down the issue, it;s a race condition during loadign the save.

gameManager = (GameManager) Server.getServerInstance().getGameManager();

The Server Instance is still null when that is being accsessed, However after several tries I was able to get it to load.

@Dirk-c-Walter
Copy link
Contributor Author

If you still need the logs I can post them, but I'll see if I can write a patch for this over christmas vacation.

@Windchild292 Windchild292 self-assigned this Dec 5, 2022
@Windchild292 Windchild292 removed the Needs More Info For when an issue needs more information from the user reporting label Dec 5, 2022
@Windchild292
Copy link
Contributor

The error message in question normally originates from different game versions, which is why I wanted the log to check. However, I've found a location where this state of affairs can occur, namely

Game newGame;
try (InputStream is = new FileInputStream(fc.getSelectedFile()); InputStream gzi = new GZIPInputStream(is)) {
XStream xstream = SerializationHelper.getXStream();
newGame = (Game) xstream.fromXML(gzi);
} catch (Exception e) {
LogManager.getLogger().error("Unable to load file: " + fc.getSelectedFile().getAbsolutePath(), e);
JOptionPane.showMessageDialog(frame, Messages.getFormattedString("MegaMek.LoadGameAlert.message", fc.getSelectedFile().getAbsolutePath()),
Messages.getString("MegaMek.LoadGameAlert.title"), JOptionPane.ERROR_MESSAGE);
return;
}

This was added in #2458, and started showing as an issue with #3652.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants