Open Saloniemi opened 1 month ago
Full error explanation here:
The selected code snippet is from a Java application that encounters a NullPointerException
due to a null
inStream
parameter. This exception occurs during an attempt to load properties from a null
input stream, which is not allowed in Java. The stack trace indicates that the exception originates from the java.util.Properties.load()
method, which requires a non-null InputStream
object to read properties.
The process begins with a call to org.cobweb.util.Versionator.getVersion()
, which likely attempts to load version information from a properties file. However, it seems that the expected properties file is not found or not passed correctly, leading to a null
input stream. This is evident from the line:
at org.cobweb.util.Versionator.getVersion(Versionator.java:24)
Subsequently, the null
stream is passed to java.util.Properties.load()
, triggering the exception:
at java.base/java.util.Properties.load(Properties.java:408)
The exception is caught by the application's uncaught exception handler, org.cobweb.cobweb2.ui.LoggingExceptionHandler.uncaughtException
, indicating that it was not anticipated or handled at the point of occurrence. This suggests a lack of validation for the inStream
parameter before its use.
The context of this error involves the Cobweb2Serializer.saveConfig()
method, which is part of the application's functionality to save configuration settings. The error occurs when the application tries to save these settings, specifically during the serialization process initiated by a user action, as indicated by the SimulationConfigEditor$OkButtonListener.actionPerformed()
method invocation:
at org.cobweb.cobweb2.ui.swing.SimulationConfigEditor$OkButtonListener.actionPerformed(SimulationConfigEditor.java:49)
This suggests that the application's configuration saving feature relies on version information that it fails to load properly, leading to the NullPointerException
. The repeated occurrences of this exception in the log file indicate a persistent issue with loading the necessary properties file across different operations within the application.
I made some changes to the source code to address some of these issues.
The NullPointerException was caused by "git.properties" being read from, and subsequently used for the inStream parameter, and it isn't even a file in the class' path. It was temporarily commented out as a band-aid fix for now -- I'll look into it more in-depth later; I'm still in the process of reading through the source code and its documentation.
After doing that, I noticed there was a crash caused by an unhandled DOMException. XML element names weren't being sanitized properly upon creation, so I updated the class responsible for that with a method to deal with it.
For example, everytime a new seed is selected, or a band is added, the program crashes and initialFile.xml is cleared. "Reload from Disk" in Intellij is responsible for deleting the contents of the XML file, but we don't know why this happens.