Skip to content

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

Merged
lukaszlenart merged 1 commit into
mainfrom
WW-5749
Sep 16, 2026
Merged

lukaszlenart merged 1 commit into
mainfrom
WW-5749

Conversation

@lukaszlenart

Copy link
Copy Markdown
Member

Fixes WW-5749

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. The JSON handler is untouched (Jackson writes null there; pre-existing, harmless).

Testing

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

Same change due on support/struts-6-x-x (fix version 6.12.0).

🤖 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.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@lukaszlenart
lukaszlenart merged commit 2e01eaa into main Sep 16, 2026
13 checks passed
@lukaszlenart
lukaszlenart deleted the WW-5749 branch September 16, 2026 18:04
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