Closed acavalli-lunalabs closed 11 months ago
Thanks for the bug report, generally gestalt fails if there is no data. But i will try and make it a little more flexible to meet your needs.
Yes, but in some formats, like hocon, an array with 0 elements is different than "null", it's impossible to get that property even if it's valid
Gestalt supports loading from 7 different formats, and has the capability to merge them. So we load each format, but then convert it into an internal representation. Unfortunately, From there we lose some of the special properties of each format.
I have added a new configuration flag treatEmptyCollectionAsErrors you can set on the builder. Please set this to false, to get your desired behavior. By default Gestalt will treat empty (null, size 0) collections as an error. By setting this to false, if there is an empty collection it will simply return an empty collection.
Hopefully this will resolve the issue. But i haven't tested specifically with a proxy object, but only with a list, set and array.
Once this is released please let me know if this works for you.
It doesn't work on empty arrays. Attempting to get the empty array causes the following error:
org.github.gestalt.config.exceptions.GestaltException: Failed getting config path: database, for class: it.cavallium.rockserver.core.config.DatabaseConfig
- level: MISSING_VALUE, message: Array on path: database.global.volumes, has no value attempting to decode Array
- level: ERROR, message: Decoding object : GlobalDatabaseConfig on path: database.global.volumes, field volumes results in null value
The config looks like this:
database: {
global: {
volumes: []
}
}
If I set .setTreatNullValuesInClassAsErrors(false), it still doesn't help:
org.github.gestalt.config.exceptions.GestaltException: Failed to get cached object from proxy config while calling method: volumes with type: class [Lit.cavallium.rockserver.core.config.VolumeConfig; in path: database.global.
at org.github.gestalt.core/org.github.gestalt.config.decoder.ProxyDecoder$ProxyCacheInvocationHandler.invoke(ProxyDecoder.java:194)
at jdk.proxy2/jdk.proxy2.$Proxy8.volumes(Unknown Source)
Can you please try version 0.24.2 and let me know if it fixes the issue for you.
It works, thanks!
I have the following hocon config file:
If the volumes array is empty, i get the following error when I try to read
globalCfg.getVolumes();
:I noticed that the class ProxyInvocationHandler inside ProxyDecoder.java does not have any value related to null properties and empty array properties.