Skip to content

Ticket #1843 - Fix stapler request double completion#1905

Open
pauljohnston2009 wants to merge 2 commits into
jenkinsci:masterfrom
pauljohnston2009:ticket-1843-prevent-duplicate-commit
Open

Ticket #1843 - Fix stapler request double completion#1905
pauljohnston2009 wants to merge 2 commits into
jenkinsci:masterfrom
pauljohnston2009:ticket-1843-prevent-duplicate-commit

Conversation

@pauljohnston2009

@pauljohnston2009 pauljohnston2009 commented Jun 4, 2026

Copy link
Copy Markdown

Resolves #1843

Fix issue with status pngs throwing java.lang.IllegalStateException: COMMITTED

Stapler calls getDynamic, and will keep calling getDynamic on each part of the url, eventualy it hits the end of the parts of the url and thinks the response has not been handled. Stapler sees it as 'not handled' and so eventually trys to complete the response itself, resulting in the double commit error.

Instead we can use doDynamic which means we will fill out the response in all cases, and stapler does not call the rest of the chain https://github.com/jenkinsci/stapler/blob/master/docs/reference.adoc "The doDynamic action method is the final consumer of the request.".

Testing done

Manually tested on our jenkins server, logs are no longer spamming the exception on every statsu.png request.

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests that demonstrate the feature works or the issue is fixed

@pauljohnston2009 pauljohnston2009 requested a review from a team as a code owner June 4, 2026 06:06
@github-actions github-actions Bot added the tests This PR adds/removes/updates test cases label Jun 4, 2026
Fix issue with status pngs throwing java.lang.IllegalStateException: COMMITTED

Stapler calls getDynamic, and will keep calling getDynamic on each part of the url, eventualy it hits the end of the parts of the url and thingks the response has not been handled
Stapler sees it as 'not handled' and so eventually trys to complete the response itself, resulting in the double commit error

Instead we can use doDynamic which means we will fill out the response in all cases, and stapler does not call the rest of the chain
https://github.com/jenkinsci/stapler/blob/master/docs/reference.adoc "The doDynamic action method is the final consumer of the request."
@pauljohnston2009 pauljohnston2009 force-pushed the ticket-1843-prevent-duplicate-commit branch from 9735105 to aa07105 Compare June 4, 2026 06:07
@krisstern

Copy link
Copy Markdown
Member

@pauljohnston2009 Thanks for the PR! Let me review this shortly

@krisstern krisstern added the bug For changelog: Minor bug. Will be listed after features label Jun 17, 2026
@krisstern krisstern requested a review from Copilot June 17, 2026 15:57

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.

Pull request overview

This PR fixes a Stapler “double completion”/double-commit issue (e.g., java.lang.IllegalStateException: COMMITTED) when serving status badge endpoints by switching the webhook entrypoint from getDynamic (which can be invoked repeatedly during URL traversal) to doDynamic (the final request consumer). This ensures the plugin completes the response exactly once for the request.

Changes:

  • Replace GitLabWebHook#getDynamic(projectName, req, rsp) with GitLabWebHook#doDynamic(req, rsp) to stop Stapler from continuing the traversal chain.
  • Update ActionResolver to parse the projectName from request.getRestOfPath() and adjust call sites accordingly.
  • Update ActionResolverTest expectations/mocks to reflect the new request path layout and resolver signature.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/main/java/com/dabsquared/gitlabjenkins/webhook/GitLabWebHook.java Switches the webhook handler to doDynamic so Stapler treats it as the terminal consumer and avoids double-commit.
src/main/java/com/dabsquared/gitlabjenkins/webhook/ActionResolver.java Extracts projectName from restOfPath so the resolver works with doDynamic routing.
src/test/java/com/dabsquared/gitlabjenkins/webhook/ActionResolverTest.java Updates tests to mock restOfPath including the project name and uses the new resolver signature.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

public void getDynamic(final String projectName, final StaplerRequest2 request, StaplerResponse2 response) {
LOGGER.log(Level.INFO, "WebHook called with url: {0}", request.getRequestURIWithQueryString());
actionResolver.resolve(projectName, request).execute(response);
public void doDynamic(final StaplerRequest2 request, StaplerResponse2 response) {
public void getDynamic(final String projectName, final StaplerRequest2 request, StaplerResponse2 response) {
LOGGER.log(Level.INFO, "WebHook called with url: {0}", request.getRequestURIWithQueryString());
actionResolver.resolve(projectName, request).execute(response);
public void doDynamic(final StaplerRequest2 request, StaplerResponse2 response) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug For changelog: Minor bug. Will be listed after features tests This PR adds/removes/updates test cases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

java.lang.IllegalStateException: COMMITTED when querying build status through gitlab plugin

4 participants