Hi, Am 30.01.2018 um 10:18 schrieb Paul Wellner Bou: > Good morning, > > i am trying to implement a reloadable property using commons-reloading2 > (2.2), without success. I tried to follow the (outdated) examples on > https://commons.apache.org/proper/commons-configuration/userguide/howto_reloading.html#Reloading_File-based_Configurations > (both of them).
Could you be a bit more specific about what is outdated, so that we can update the examples? > > Now I created a unit test against this API which I would expect it to pass, > but it doesn't: > https://gist.github.com/paulwellnerbou/dfed371d67e2f19a699b248ebf5c62d7 > > Any idea what I am doing wrong? I had a deeper look at the test and the implementation, and here is what I found out: The class for checking whether a reload of a file is required is FileHandlerReloadingDetector. The class records the time of the last check and has a refreshDelay property; it only checks again after the time configured for the delay is elapsed. The default refreshDelay is 5 seconds. This is one reason why your test does not pass; you need to decrease this delay or wait longer. The other reason is that there is indeed a problem in the implementation that causes the first call to getConfiguration() to get missed by the reload checker. The CONFIGURATION_REQUEST event is already fired before the file to be loaded is properly initialized, and therefore, the checker cannot set its last check time. This is initialized only at the second call to getConfiguration(). So the test would only be successful if getConfiguration() was called another time (taking the refresh delay into account). This can be considered a bug, but is probably not very problematic in practice when the configuration is accessed on a regular basis. HTH Oliver > > Thank you and kind regards > Paul. > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
