Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -282,13 +282,24 @@ public void doConfigurationEvent(ConfigurationEvent configurationEvent)
{
props.remove(key);
}
try (Writer fw = new OutputStreamWriter(new FileOutputStream(file), encoding()))

// re-writing a config file must be guarded by a write lock as otherwise DirectoryWatcher
// might pick up an empty file and as a result, write this file to disk in a follow-up event
fileInstall.lock.writeLock().lockInterruptibly();
try
{
try (Writer fw = new OutputStreamWriter(new FileOutputStream(file), encoding()))
{
props.save( fw );
}
// we're just writing out what's already loaded into ConfigAdmin, so
// update file checksum since lastModified gets updated when writing
fileInstall.updateChecksum(file);
}
finally
{
props.save( fw );
fileInstall.lock.writeLock().unlock();
}
// we're just writing out what's already loaded into ConfigAdmin, so
// update file checksum since lastModified gets updated when writing
fileInstall.updateChecksum(file);
}
}
catch (Exception e)
Expand Down