commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Wellner Bou <>
Subject Re: [configuration] Reloading properties does not work as expected
Date Thu, 01 Feb 2018 09:26:53 GMT

thank you very much.

Yes, this helps. This is more or less what I found out as well. That's why
I introduced the 6 seconds delay in my original example, to wait for this
5s timeout.
I tried to call getProperty more than once, too, because I noticed
debugging that the check time is only filled after the first call.

But somehow I wrote my test code in a way, that the reloading time was the
same as the time the file changed (which may happen in unit tests, its the
same millisecond). So the test failed again.

Now I reordered the statements a bit, and it works now. I just need to add
a call in the very beginning of the test. The timeouts I introduced in the
first approach are already enough.

So it works now. Thanks very much!

> 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?

Maybe you could add that commons-beanutils:1.9.3 is required to avoid the
NoClassDefFoundException (


> > 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.
> Oliver

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message