You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Utility methods SystemUtil#loadPropertiesFile and SystemUtil#loadPropertiesFiles work by overwriting system properties with the values from the given file(s). That makes sense especially when multiple files are used since the later files overwrite values of the previous files.
However this behavior is surprising for people come from frameworks such as Spring. In Spring for example explicitly set system property takes precedence over values in the property files. So the following is working with Spring but not with Agrona:
With Spring value of my.prop will be IMPORTANT but with Agrona it will be DEFAULT (i.e. value from the default.properties file).
Therefore we should probably consider providing a version that can preserve property value if it is already set. One interesting question is how to do SystemUtil#loadPropertiesFilesPreserveExisting. We want to honor already set property when the method was called but if one is not set it should behave the same as the original SystemUtil#loadPropertiesFiles, i.e. next file should overwrite previous file values in the list.
The text was updated successfully, but these errors were encountered:
We could provide an override of the loadPropertiesFiles method that takes an enum as the first argument. The enum can specify which priority is applied. The existing method can stay with it defaulting to one of the enum values.
Utility methods SystemUtil#loadPropertiesFile and SystemUtil#loadPropertiesFiles work by overwriting system properties with the values from the given file(s). That makes sense especially when multiple files are used since the later files overwrite values of the previous files.
However this behavior is surprising for people come from frameworks such as Spring. In Spring for example explicitly set system property takes precedence over values in the property files. So the following is working with Spring but not with Agrona:
With Spring value of
my.prop
will beIMPORTANT
but with Agrona it will beDEFAULT
(i.e. value from thedefault.properties
file).Therefore we should probably consider providing a version that can preserve property value if it is already set. One interesting question is how to do
SystemUtil#loadPropertiesFilesPreserveExisting
. We want to honor already set property when the method was called but if one is not set it should behave the same as the originalSystemUtil#loadPropertiesFiles
, i.e. next file should overwrite previous file values in the list.The text was updated successfully, but these errors were encountered: