commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Heger <>
Subject Re: [configuration] Reloading properties does not work as expected
Date Wed, 31 Jan 2018 21:11:45 GMT

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
> (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:
> 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.


> Thank you and kind regards
> Paul.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message