Closed LeMikaelF closed 4 years ago
Because of the way Spring context initialization works, the CommandRegistry
held by the dispatcher gets initialized before the application context exists, so Module
instances are pretty much unable to access any fields from the main class at initialization. I think the only way to fix this is to just move config initialization into getConfig()
.
I'll fix this sometime before 1.1.
Staged for fix in ecdc9fd.
Fixed on master: 7947559
Describe the bug
Trying to access
Ghost2Application.getApplicationInstance().getConfig()
in a module's field or initializer block will throw aNullPointerException
and cause the module to not get loaded, and output:This error is difficult to debug, since it has no line number attached and since it doesn't necessarily come from the module's constructor. It can also come from a field or an initializer block.
Reproduction Steps to reproduce the bug.
Ghost2Application.getApplicationInstance().getConfig()
before theinvoke
method is called (for example in the initializer block, field or constructor).Expected behavior The system properties should be accessible during creation of the module, for example if one wants to store them in
final
fields. The current API design doesn't warn against it or prevent it, and leads to potential bugs.Actual behavior
Ghost2Application.getApplicationInstance()
returnsnull
if called beforeinvoke
method.Platform