0

Considering the scenario where 'file' is a symbolic link to a real one

file -> real_file

if I configure PropertiesConfiguration (from Apache Commons Config) to open the symbolic link it doens't reload it if I update the real file

String filePath = new File(path).getCanonicalPath();
PropertiesConfiguration configuration = new PropertiesConfiguration(new File(filePath));
configuration.setReloadingStrategy(new FileChangedReloadingStrategy());

Of course, in this case the update date of the symbolic link is unchanged, unlike the real one.

Is there a way to force PropertiesConfiguration to follow symbolic link and recognize changes on real file?

Alessio Fiore
  • 467
  • 1
  • 7
  • 18
  • `.getCanonicalPath()` will give you the _real path_ of the file. So in your code example, you are watching the actual file, not the symbolic link. So it does not need to follow the symbolic link in this example. Doesn't this code reload on the changes on the real file? – Utku Özdemir Oct 01 '20 at 09:06
  • Yes, I just discover that the problem is that the pointed file has been replaced by another file, so PropertiecConfiguration is pointing to an not existing file. That's why the reload not works – Alessio Fiore Oct 01 '20 at 10:09
  • Got it. I recommend then writing an answer to your own question, so it can be helpful to the community. – Utku Özdemir Oct 01 '20 at 10:12

1 Answers1

0

The problem is that .getCanonicalPath() open the pointed file and not the symblink. If someone replace the real file with another one PropertiecConfiguration is still pointing to an not existing file, so the reload doens't work

Alessio Fiore
  • 467
  • 1
  • 7
  • 18