Skip to content

Fix #6457: Suppress spurious 'Existing CookieManager superseded by' warnings across iterations - #6737

Open
alaahong wants to merge 1 commit into
apache:masterfrom
alaahong:fix/issue-6457-superseded-warnings
Open

Fix #6457: Suppress spurious 'Existing CookieManager superseded by' warnings across iterations#6737
alaahong wants to merge 1 commit into
apache:masterfrom
alaahong:fix/issue-6457-superseded-warnings

Conversation

@alaahong

@alaahong alaahong commented Jul 26, 2026

Copy link
Copy Markdown
Member

Issue

Fixes #6457

Since 5.6, JMeter logs a flood of Existing CookieManager ... superseded by ... (and analogous CacheManager, AuthManager, DNSCacheManager warnings) on every thread-group iteration after the first one. In a long-running test plan with N iterations and M HTTP Samplers under a Thread Group, the log is filled with (N-1) × M redundant warning lines per manager type, hiding real issues and alarming users.

Root cause

HTTPSamplerBase#addTestElement(TestElement) routed CookieManager, CacheManager, AuthManager, and DNSCacheManager through their public setXxxManager methods. Those public setters unconditionally log a warning whenever the existing manager is non-null.

TestCompiler calls addTestElement on every thread-group iteration after clearTestElementChildren(), but clearTestElementChildren() only clears the HeaderManager property — the replace-mode manager references survive across iterations. As a result, the warning fires N-1 times for N iterations even though the user has attached exactly one manager.

KeystoreConfig was already exempted because its addTestElement branch already called the private setKeystoreConfigProperty, which does not warn.

Fix

Two complementary changes in HTTPSamplerBase:

  • addTestElement now routes replace-mode managers (CookieManager, CacheManager, AuthManager, DNSCacheManager) through their private setXxxManagerProperty / setDNSResolverProperty methods, mirroring the existing KeystoreConfig path. This is the path used by TestCompiler every iteration, so the warning no longer fires on legitimate re-application of the same config element.
  • The public setXxxManager methods now suppress the warning when the new value is the same instance as the existing one (defensive guard for direct callers). The reference-equality check uses == deliberately and is annotated with @SuppressWarnings("ReferenceEquality"). Genuine misuse — attaching a different manager of the same type — still produces the warning, so the diagnostic value is preserved.

Files changed

  • src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java — reroute addTestElement for the 4 replace-mode managers, add same-instance guard to 5 public setters, extract 2 new private property setters (setAuthManagerProperty, setDNSResolverProperty) mirroring the existing pattern.
  • src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/HttpSamplerManagerWarningsTest.java — new regression test (17 cases) covering: (1) addTestElement × 5 iterations for each of the 5 managers, (2) same-instance setter call, (3) different-instance setter call (must still warn), (4) HeaderManager merge path, (5) end-to-end smoke test with all 6 managers across 10 iterations.
  • xdocs/changes.xml — bug-fix entry under a new HTTP Samplers and Test Script Recorder subsection.

Verification

./gradlew --quiet :src:protocol:http:compileJava :src:protocol:http:compileTestJava \
                   :src:protocol:http:checkstyleMain :src:protocol:http:checkstyleTest
./gradlew --quiet :src:protocol:http:test --tests "org.apache.jmeter.protocol.http.sampler.HttpSamplerManagerWarningsTest"

Before / After evidence

Both runs use the same HttpSamplerManagerWarningsTest (17 cases). The "before" run is on unpatched master with the test file checked out from this branch; the "after" run is on this branch.

Before (without fix)

  • Tests: 17 completed, 10 failed (the 5 addTestElement x5 cases for CookieManager/CacheManager/AuthManager/DNSCacheManager + the end-to-end case + the 5 same-instance setter cases all fail)
  • jmeter.log superseded by lines: 62 total, broken down as:
    • 5 lines from same-instance setter calls (the 5 setXxx(sameInstance) cases) — these should not warn
    • 5 lines from different-instance setter calls — these are expected (genuine misuse detected)
    • 16 lines from addTestElement x5 iterations across 4 managers (4 spurious warnings × 4 managers; KeystoreConfig already exempted)
    • 36 lines from the end-to-end test (9 iterations × 4 replace-mode managers)

Sample spurious warnings from the same-instance setter cases (lines 26, 29, 33-35 of before-superseded-warnings.log):

2026-07-26 15:27:20,424 WARN o.a.j.p.h.s.HTTPSamplerBase: Existing CookieManager CookieManager-Same superseded by CookieManager-Same
2026-07-26 15:27:20,490 WARN o.a.j.p.h.s.HTTPSamplerBase: Existing CacheManager CacheManager-Same superseded by CacheManager-Same
2026-07-26 15:27:20,536 WARN o.a.j.p.h.s.HTTPSamplerBase: Existing AuthManager AuthManager-Same superseded by AuthManager-Same
2026-07-26 15:27:20,572 WARN o.a.j.p.h.s.HTTPSamplerBase: Existing DNSCacheManager DNSCacheManager-Same superseded by DNSCacheManager-Same
2026-07-26 15:27:20,607 WARN o.a.j.p.h.s.HTTPSamplerBase: Existing KeystoreConfig KeystoreConfig-Same superseded by KeystoreConfig-Same

Sample spurious warnings from addTestElement x5 for CookieManager (lines 41-44, 4 spurious warnings for 5 iterations):

2026-07-26 15:27:20,870 WARN o.a.j.p.h.s.HTTPSamplerBase: Existing CookieManager CookieManager-UnderTest superseded by CookieManager-UnderTest
2026-07-26 15:27:20,870 WARN o.a.j.p.h.s.HTTPSamplerBase: Existing CookieManager CookieManager-UnderTest superseded by CookieManager-UnderTest
2026-07-26 15:27:20,870 WARN o.a.j.p.h.s.HTTPSamplerBase: Existing CookieManager CookieManager-UnderTest superseded by CookieManager-UnderTest
2026-07-26 15:27:20,870 WARN o.a.j.p.h.s.HTTPSamplerBase: Existing CookieManager CookieManager-UnderTest superseded by CookieManager-UnderTest

Sample spurious warnings from the end-to-end test (lines 57-92, 36 lines for 9 iterations × 4 managers):

2026-07-26 15:27:21,060 WARN o.a.j.p.h.s.HTTPSamplerBase: Existing CookieManager HTTP Cookie Manager superseded by HTTP Cookie Manager
2026-07-26 15:27:21,061 WARN o.a.j.p.h.s.HTTPSamplerBase: Existing CacheManager HTTP Cache Manager superseded by HTTP Cache Manager
2026-07-26 15:27:21,061 WARN o.a.j.p.h.s.HTTPSamplerBase: Existing AuthManager HTTP Authorization Manager superseded by HTTP Authorization Manager
2026-07-26 15:27:21,061 WARN o.a.j.p.h.s.HTTPSamplerBase: Existing DNSCacheManager DNS Cache Manager superseded by DNS Cache Manager
... (repeated 36 times across 9 iterations)

before-superseded-warnings.log

After (with fix)

  • Tests: 17 completed, 0 failed
  • jmeter.log superseded by lines: 5 total — only the expected warnings from the different-instance setter cases (lines 31-35 of after-superseded-warnings.log). Genuine misuse is still detected.
2026-07-26 15:26:03,348 WARN o.a.j.p.h.s.HTTPSamplerBase: Existing CookieManager CookieManager-First superseded by CookieManager-Second
2026-07-26 15:26:03,397 WARN o.a.j.p.h.s.HTTPSamplerBase: Existing CacheManager CacheManager-First superseded by CacheManager-Second
2026-07-26 15:26:03,442 WARN o.a.j.p.h.s.HTTPSamplerBase: Existing AuthManager AuthManager-First superseded by AuthManager-Second
2026-07-26 15:26:03,484 WARN o.a.j.p.h.s.HTTPSamplerBase: Existing DNSCacheManager DNSCacheManager-First superseded by DNSCacheManager-Second
2026-07-26 15:26:03,511 WARN o.a.j.p.h.s.HTTPSamplerBase: Existing KeystoreConfig KeystoreConfig-First superseded by KeystoreConfig-Second

after-superseded-warnings.log

Summary

Metric Before After
Tests passing 7/17 17/17
addTestElement x5 spurious warnings (4 managers × 4) 16 0
Same-instance setter spurious warnings (5 managers) 5 0
End-to-end spurious warnings (9 iterations × 4 managers) 36 0
Different-instance setter warnings (expected, kept) 5 5
Total superseded by lines 62 5

@alaahong
alaahong force-pushed the fix/issue-6457-superseded-warnings branch 2 times, most recently from 9e03e1d to 97e5a0b Compare July 26, 2026 07:37
…arnings across iterations

HTTPSamplerBase.addTestElement routed CookieManager, CacheManager,
AuthManager and DNSCacheManager through their public setXxxManager methods,
which unconditionally log a warning whenever the existing manager is non-null.
TestCompiler calls addTestElement on every thread-group iteration after
clearTestElementChildren, but clearTestElementChildren only clears the
HeaderManager property, so the replace-mode manager references survive
across iterations and the warning fires N-1 times for N iterations.

Fix:
- addTestElement now routes replace-mode managers through their private
  setXxxManagerProperty methods, mirroring the existing KeystoreConfig path
  that was already exempted.
- The public setXxxManager methods now suppress the warning when the new
  value is the same instance as the existing one (defensive guard for direct
  callers). Genuine misuse (attaching a *different* manager of the same type)
  still produces the warning, so the diagnostic value is preserved.

Added HttpSamplerManagerWarningsTest with 17 cases covering: addTestElement x5
iterations for each of the 5 managers, same-instance setter call,
different-instance setter call (must still warn), HeaderManager merge path,
and an end-to-end smoke test with all 6 managers across 10 iterations.

Before fix: 17 tests, 10 failed; 62 "superseded by" log lines.
After fix:  17 tests, 0 failed; 5 "superseded by" log lines (expected,
            from different-instance setter calls only).
@alaahong
alaahong force-pushed the fix/issue-6457-superseded-warnings branch from 97e5a0b to 07a91ec Compare July 26, 2026 07:49
@alaahong

Copy link
Copy Markdown
Member Author

The batchServerBatchTestLocal failure on macOS/JDK17 is a known pre-existing flaky test tracked by #6674 . The failing test plan BatchTestLocal.jmx uses only JavaSampler/JSR223Sampler and does not touch any HTTP component modified by this PR. The same failure occurs on master and is caused by a thread-group scheduling race in server mode on macOS. All non-macOS matrix jobs pass.

@alaahong
alaahong marked this pull request as ready for review July 26, 2026 08:48
@alaahong
alaahong force-pushed the fix/issue-6457-superseded-warnings branch from 09965b4 to 07a91ec Compare July 26, 2026 10:17
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.

Thread Group Iterations getting unexpected warning - Existing CookieManager HTTP Cookie Manager superseded by HTTP Cookie Manager

1 participant