Skip to content

WW-5749 fix(rest): write nothing from the XML handlers when there is no target (6.x) - #1960

Merged
lukaszlenart merged 1 commit into
support/struts-6-x-xfrom
WW-5749-6x
Sep 16, 2026
Merged

lukaszlenart merged 1 commit into
support/struts-6-x-xfrom
WW-5749-6x

Conversation

@lukaszlenart

Copy link
Copy Markdown
Member

Fixes WW-5749 on the 6.x line — backport of #1959 (fix version 6.12.0).

RestActionInvocation hands the content-type handler a null target for a clean POST/PUT/DELETE under the default restrictToGet=true, and since WW-5718 for a bare HTTP-status result code. JacksonXmlHandler.fromObject and JuneauXmlHandler.fromObject dereferenced it for a debug log line; invoke() caught the NullPointerException, set 500 and re-ran processResult() with the exception as the target, so the client received a 500 whose XML body was the serialised NPE.

Both handlers now return early on a null target and write nothing — the guard XStreamHandler already has — so the client gets the intended status with an empty body.

Testing

testNullTargetWritesNothing in JacksonXmlHandlerTest and JuneauXmlHandlerTest, both red with the NPE before the guard. ./mvnw test -DskipAssembly -pl plugins/rest — green.

🤖 Generated with Claude Code

…no target

RestActionInvocation hands the content-type handler a null target for a
clean POST, PUT or DELETE under restrictToGet and for a bare HTTP-status
result code. JacksonXmlHandler and JuneauXmlHandler dereferenced it, and
the NullPointerException that invoke() caught became a 500 whose XML body
was the serialised exception. Both now return early on a null target,
as XStreamHandler already does, so the client gets the intended status
with an empty body.

(cherry picked from commit c89ee1b)

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@lukaszlenart
lukaszlenart marked this pull request as ready for review September 16, 2026 17:44
@sonarqubecloud

Copy link
Copy Markdown

@lukaszlenart
lukaszlenart merged commit f2222fd into support/struts-6-x-x Sep 16, 2026
10 checks passed
@lukaszlenart
lukaszlenart deleted the WW-5749-6x branch September 16, 2026 18:15
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.

1 participant