Skip to content

#6461 Add HTTP implementations to Access Log Sampler - #6859

Open
orimarko wants to merge 3 commits into
apache:masterfrom
orimarko:gh6461-access-log-keepalive
Open

orimarko wants to merge 3 commits into
apache:masterfrom
orimarko:gh6461-access-log-keepalive

Conversation

@orimarko

@orimarko orimarko commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds an Implementation selection (Java, HttpClient4, HttpClient5) and opt-in keep-alive to the Access Log Sampler, retaining Java/no-keep-alive defaults for existing plans.

Motivation and Context

Addresses #6461 by enabling per-thread connection management through HttpClient4/5 while preserving existing Access Log Sampler behavior unless users opt in.

How Has This Been Tested?

  • .�[gradlew.bat --quiet :src:protocol:http:test --tests org.apache.jmeter.protocol.http.sampler.AccessLogSamplerTest - passed (8 tests).
  • .�[gradlew.bat --quiet classes style - passed.
  • Tested in rugGui implementation and keep alive

Screenshots (if appropriate):

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code follows the code style of this project.
  • I have updated the documentation accordingly.

@milamberspace milamberspace 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.

Thanks for following up on #6461 so quickly! The approach matches what was discussed on the issue: the implementation and keep-alive are opt-in, and existing plans keep the Java implementation without keep-alive (the empty HTTPSampler.implementation default plus DEFAULT_NOT_SAVED take care of that). The delegation mirrors HTTPSamplerProxy nicely (sample(URL, ...), threadFinished, interrupt, testIterationStart), and the outdated code sample in the documentation is replaced with the actual LogParser.parseAndConfigure API.

Requested changes

  1. Unrelated commits: the four #6591 Xalan deprecation commits (PropertiesBasedPrefixResolver*, XPathUtil, the "Deprecate Xalan" entry and the contributor line in changes.xml) belong to #6856. Please rebase this branch on master and keep only the #6461 commits, otherwise the two PRs will conflict or duplicate entries.
  2. The test does not prove the delegation: the parameterized test only checks the Connection header, which the Java implementation also sets according to useKeepAlive. If sample(URL, ...) never delegated, all six cases would still pass. Please add an implementation-specific assertion, e.g. on the User-Agent header sent by default (Java/... for Java, Apache-HttpClient/4... for HC4, Apache-HttpClient/5... for HC5), or check that the connection is actually reused.
  3. changes.xml: the entry lacks <pr>6859</pr> and does not mention the keep-alive option, which is the main motivation of the issue.

Minor

  • Tests call sampler.testEnded() but not threadFinished(), so the HC4/HC5 clients created for the test thread are not closed.
  • An empty implementation means Java here, whereas for the HTTP Request sampler it means the jmeter.httpsampler default (HttpClient4). That is the right choice for backward compatibility, but a sentence in the docs would avoid confusion.
  • In AccessLogSampler: @SuppressWarnings("RedundantOverride") is on three of the four overrides but not on getUseKeepAlive(), there is a double blank line before its Javadoc, and the Javadoc reads "Returns the keepAlive".

* {@link PrefixResolver} implementation that loads prefix configuration from jmeter property xpath.namespace.config
* @deprecated This Xalan-based class is scheduled for removal.
*/
@Deprecated(since = "6.0", forRemoval = true)

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.

This change (and those in PropertiesBasedPrefixResolverForXpath2, XPathUtil, plus the Xalan entry and contributor line in changes.xml) belongs to #6856, not to this PR. Could you rebase on master and drop the #6591 commits?

assertTrue(sampler.sampleWithParser().isSuccessful)

server.wireMock.verifyThat(
getRequestedFor(urlEqualTo("/one")).withHeader("Connection", equalTo(expectedConnection)),

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.

The Java implementation also sends Connection: keep-alive/close depending on useKeepAlive, so these assertions would pass even if the sampler never delegated to HC4/HC5. Please add something implementation-specific, for instance on the default User-Agent:

// expectedUserAgent: "Java/.*", "Apache-HttpClient/4.*" or "Apache-HttpClient/5.*"
server.wireMock.verifyThat(
    getRequestedFor(urlEqualTo("/one")).withHeader("User-Agent", matching(expectedUserAgent)),
)

Comment thread xdocs/changes.xml Outdated
<li><issue>6250</issue>Avoid adding "; charset=" automatically to <code>multipart/form-data</code> requests to align behavior with modern HTTP clients.</li>
<li><issue>6080</issue>Preserve the original HTTP method when following 307 and 308 redirects according to the HTTP specification. Contributed by LeeJiWon (github.com/dlwldnjs1009)</li>
<li><issue>6267</issue><pr>6268</pr>Add a space between key and value after <code>:</code> in View Results Tree &gt; Sampler result tab for better readability.</li>
<li><issue>6461</issue>Allow the Access Log Sampler to select the <code>Java</code>, <code>HttpClient4</code>, or <code>HttpClient5</code> implementation. The default remains <code>Java</code> with keep-alive disabled for backward compatibility.</li>

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.

Please add <pr>6859</pr> and mention the new Use Keep-Alive option, e.g.:

Suggested change
<li><issue>6461</issue>Allow the Access Log Sampler to select the <code>Java</code>, <code>HttpClient4</code>, or <code>HttpClient5</code> implementation. The default remains <code>Java</code> with keep-alive disabled for backward compatibility.</li>
<li><issue>6461</issue><pr>6859</pr>Allow the Access Log Sampler to select the <code>Java</code>, <code>HttpClient4</code>, or <code>HttpClient5</code> implementation and to use keep-alive connections. The defaults remain <code>Java</code> with keep-alive disabled for backward compatibility.</li>

orimarko and others added 3 commits November 21, 2026 19:57
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@orimarko
orimarko force-pushed the gh6461-access-log-keepalive branch from 6fc4d96 to 2dc7c07 Compare November 21, 2026 17:59
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.

2 participants