Closed plytki closed 2 years ago
Please make sure a default constructor is available. Otherwise, okaeri-configs can in some cases create the instance with unsafe which does not fill default values.
What do you mean by default constructor?
A default constructor is a constructor which can be called with no arguments (either defined with an empty parameter list, or with default arguments provided for every parameter).
This can be also achieved using @NoArgsConstructor
from Lombok.
I tried this way but there is still a null value.
Please provide specific instructions where and what to add to reproduce the problem, as your configuration has multiple levels.
These variables are already added to the PluginConfiguration.java file so you just have to run the creator to see newly added null values. On line 168 you have that 2 last constructor params that are null values when you try to update the config with provided ConfigManager creator. This built-in MySQL class that produces null values is initialized on line 149.
That explains a bit. Please use fields for the default values, instead of the full constructor for the subconfig initialization, if you want okaeri-configs to add the new default values.
// don't
public MySQL mysql = new MySQL("localhost", 3306 /* ... */);
// do
public String hostname = "localhost";
public int port = 3306;
// ...
Note that this behavior is indeed correct, because you are only providing the default value for the mysql
itself, which is, in fact, already present when adding properties to the MySQL class.
When config file is updated with new variable, it sets null value for it and in the config class I have something different in my initializer.
Steps to reproduce the behavior:
Create configuration file with built-in class. Initialize class and assign it to variable at same time to create an instance of object to the config. After doing that update your configuration file by adding new String variable to constructor params and initialize it in the class also (class variable defined earlier). Try to update your configuration with preset presented on the bottom. Your updated String variable will be null after updating the config with newly added custom class variable.
All used libs are versioned in 3.4.2.
Config classes and setup routine
Try to update this config file with java class file attached. bug-files.zip