alaahong opened a new pull request, #6737:
URL: https://github.com/apache/jmeter/pull/6737
## 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`:
**B. Route replace-mode managers through private property setters in
`addTestElement`**
Mirroring the existing `KeystoreConfig` path, `CookieManager`,
`CacheManager`, `AuthManager`, and `DNSCacheManager` now go through their
`setXxxManagerProperty` / `setDNSResolverProperty` private methods inside
`addTestElement`. This is the path used by `TestCompiler` every iteration, so
the warning no longer fires on legitimate re-application of the same config
element.
**C. Suppress the warning in public setters when the new value is the same
instance**
Defensive guard for any caller that explicitly invokes
`setCookieManager(mgr)` (or any sibling setter) with the same instance already
attached. 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 of the warning is preserved.
## Files changed
-
`src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java`
— reroute `addTestElement` + 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/ReproIssue6457Test.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.ReproIssue6457Test"
```
### Before (without fix)
- Tests: 17 completed, **10 failed**
- `jmeter.log` `superseded by` lines: **62** (16 from `addTestElement`
iterations across 4 managers + 5 from same-instance setter calls + 36 from
end-to-end test + 5 expected from different-instance setter calls)
Sample spurious warnings (CookieManager, 5 addTestElement iterations — 4
spurious warnings):
```
14:41:47,064 WARN o.a.j.p.h.s.HTTPSamplerBase: Existing CookieManager
CookieManager-UnderTest superseded by CookieManager-UnderTest
14:41:47,064 WARN o.a.j.p.h.s.HTTPSamplerBase: Existing CookieManager
CookieManager-UnderTest superseded by CookieManager-UnderTest
14:41:47,064 WARN o.a.j.p.h.s.HTTPSamplerBase: Existing CookieManager
CookieManager-UnderTest superseded by CookieManager-UnderTest
14:41:47,064 WARN o.a.j.p.h.s.HTTPSamplerBase: Existing CookieManager
CookieManager-UnderTest superseded by CookieManager-UnderTest
```
End-to-end (10 iterations × 6 managers) — 36 spurious warnings:
```
14:41:47,286 WARN o.a.j.p.h.s.HTTPSamplerBase: Existing CookieManager HTTP
Cookie Manager superseded by HTTP Cookie Manager
14:41:47,286 WARN o.a.j.p.h.s.HTTPSamplerBase: Existing CacheManager HTTP
Cache Manager superseded by HTTP Cache Manager
14:41:47,286 WARN o.a.j.p.h.s.HTTPSamplerBase: Existing AuthManager HTTP
Authorization Manager superseded by HTTP Authorization Manager
14:41:47,286 WARN o.a.j.p.h.s.HTTPSamplerBase: Existing DNSCacheManager DNS
Cache Manager superseded by DNS Cache Manager
... (repeated 36 times)
```
### After (with fix)
- Tests: 17 completed, **0 failed**
- `jmeter.log` `superseded by` lines: **5** (only the expected warnings from
different-instance setter calls — genuine misuse is still detected)
```
14:43:26,470 WARN o.a.j.p.h.s.HTTPSamplerBase: Existing CookieManager
CookieManager-First superseded by CookieManager-Second
14:43:26,532 WARN o.a.j.p.h.s.HTTPSamplerBase: Existing CacheManager
CacheManager-First superseded by CacheManager-Second
14:43:26,582 WARN o.a.j.p.h.s.HTTPSamplerBase: Existing AuthManager
AuthManager-First superseded by AuthManager-Second
14:43:26,628 WARN o.a.j.p.h.s.HTTPSamplerBase: Existing DNSCacheManager
DNSCacheManager-First superseded by DNSCacheManager-Second
14:43:26,671 WARN o.a.j.p.h.s.HTTPSamplerBase: Existing KeystoreConfig
KeystoreConfig-First superseded by KeystoreConfig-Second
```
## Backwards compatibility
- Public API (`setCookieManager`, `setCacheManager`, `setAuthManager`,
`setDNSResolver`, `setKeystoreConfig`) signatures unchanged.
- The only behaviour change is: the warning is suppressed when re-applying
the *same* manager instance, which is what `TestCompiler` does on every
iteration. Users who intentionally attach multiple managers of the same type
still see the warning.
- No changes to merge-mode `HeaderManager` behaviour.
## Credit
Reported in issue #6457. Investigated and fixed locally; happy to submit
upstream.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]