Skip to content

PropertyFileConfiguration does not persist deletion of last key from included property files #5340

@stevandjokic94

Description

@stevandjokic94

Describe the bug

When using a property-file configuration that supports !include files and preserves source-file provenance, deleting a property or an entire property branch from an included file may update the in-memory configuration but leave the removed key(s) in the physical included file on disk.

This is especially visible when the removed key is the last key from that included file, or when a whole prefix/branch is removed. After saving, the UI or runtime state may look correct temporarily, but after reload/restart the deleted property can reappear because the stale line still exists in the included property file.

To Reproduce

  1. Create a main properties file that includes another properties file.
  2. Put one or more properties in the included file, for example a nested branch such as:
    • some.group.item.name
    • some.group.item.value
  3. Load the main properties file through the configuration API.
  4. Remove either:
    • a single property from the included file, especially if it is the last remaining property in that file, or
    • a whole branch/prefix such as some.group.
  5. Save the configuration back to the main file.
  6. Inspect the included file on disk.
  7. Reload the configuration from disk.

Expected behavior

Removed properties should also be removed from the physical file they originated from, including included files.

If a property branch/prefix is removed, all matching keys should be removed from the relevant source files on disk.

After saving and reloading, the deleted properties should not reappear.

Logs

No specific logs are required to reproduce this. The issue is visible by inspecting the included properties file after save and then reloading the configuration.

Screenshots

Not applicable.

Please add relevant environment information:

  • OS Type and Version: Any
  • POCO Version: Affected version unknown / current development version
  • Third-party product type and version: Not applicable

Additional context

This appears related to source-file provenance tracking during save. The configuration knows which file a property originally came from, but when all keys from a source file are removed, that file may not be rewritten during save. As a result, stale entries remain on disk even though they were removed from the in-memory configuration.

A robust fix would ensure that source files affected by removals are also rewritten during save, even if they no longer have any remaining active keys assigned to them.

Metadata

Metadata

Assignees

Labels

Type

No fields configured for Bug.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions