Skip to content

fix(Util): JSONConfiguration fires change events once #3903 - #5604

Merged
aleks-f merged 3 commits into
pocoproject:mainfrom
555aaditya:3903-json-configuration-duplicate-events
Oct 29, 2026
Merged

aleks-f merged 3 commits into
pocoproject:mainfrom
555aaditya:3903-json-configuration-duplicate-events

Conversation

@555aaditya

@555aaditya 555aaditya commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Closes #3903.

AbstractConfiguration::setRawWithEvent() fires propertyChanging, calls setRaw(), then fires propertyChanged. JSONConfiguration::setRaw() called setValue(), which fires both events again. So the setters that JSONConfiguration does not override (setUInt, setInt16 to setUInt64) fired each event twice. The second propertyChanging also ran while the configuration mutex was held.

  • Util/src/JSONConfiguration.cpp, JSONConfiguration.h: the storing part of setValue() moves into a private storeValue(). setValue() fires the events around it, and setRaw() calls storeValue() without events, as setRaw() does in the other configuration classes. Writes through a view, mapper or layered configuration therefore no longer fire the events of the underlying JSONConfiguration.

Tests:

  • AbstractConfigurationTest::testChangeEvents counts the events and checks that setUInt() fires each exactly once. It runs for all 10 configuration test classes.
  • JSONConfigurationTest::testWrapperEvents writes through a view, a mapper and a layered configuration backed by JSONConfiguration. Each write fires each event once, from the wrapper, and stores the value in the JSONConfiguration.
  • Without the change, both JSONConfigurationTest tests fail with "expected: 1 but was: 2". MapConfigurationTest::testChangeEvents passes without it.

Validation on macOS arm64, Apple clang 21, Debug, ENABLE_COMPILER_WARNINGS=ON (no warnings in the changed files):

  • the full Util suite with -ignore cppignore.lnx (257 tests, OK);
  • the full Util suite under ASan and UBSan;
  • clang-tidy and cppcheck, no findings on the changed lines.

Not run: Linux and Windows.

setRaw() called setValue(), which fires propertyChanging and
propertyChanged, so setters routed through setRawWithEvent() fired both
events twice. setRaw() now stores the value without events.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

An unguarded setUInt64() call breaks test compilation without POCO_HAVE_INT64, and wrapper-backed JSON writes lack regression coverage.

2 open issues
What changed in this PR

Fixes #3903 by separating JSON value storage from event notification, preventing inherited configuration setters from firing change events twice.

Changes:

  • Adds a private, event-free storeValue() helper used by setRaw().
  • Keeps notifications in setValue() while stopping underlying JSON notifications for writes through configuration wrappers.
  • Adds shared event counters and a setUInt64() regression check.
File Description
Util/​testsuite/​src/​AbstractConfigurationTest.h Adds counters for changing and changed events.
Util/​testsuite/​src/​AbstractConfigurationTest.cpp Checks that setUInt64() fires each event exactly once.
Util/​src/​JSONConfiguration.cpp Separates storage from notification to eliminate duplicate events.
Util/​include/​Poco/​Util/​JSONConfiguration.h Declares the storage helper and documents event behavior.

Review effort: Balanced

Comment thread Util/src/JSONConfiguration.cpp Resolved
…ered configuration pocoproject#3903

Use setUInt() in testChangeEvents, as setUInt64() needs POCO_HAVE_INT64.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The wrapper event counters are not reset before the first write, causing the test to fail when the fixture is reused.

1 open issue
2 resolved since last review

Review effort: Balanced

@aleks-f
aleks-f merged commit 36baf62 into pocoproject:main Oct 29, 2026
51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Possibly duplicate event firing in JSONConfiguration.cpp

3 participants