Skip to content

Explain why LoggingSOAPHandler calls getMessage() - #510

Open
tonygermano wants to merge 1 commit into
OpenIntegrationEngine:mainfrom
tonygermano:docs/logging-soap-handler-comment
Open

tonygermano wants to merge 1 commit into
OpenIntegrationEngine:mainfrom
tonygermano:docs/logging-soap-handler-comment

Conversation

@tonygermano

Copy link
Copy Markdown
Member

LoggingSOAPHandler.handleMessage() calls smc.getMessage() and ignores the result, so the call looks safe to remove. It isn't. In the JAX-WS RI, getMessage() converts the message to an in-memory SAAJ copy, and once the handler chain finishes, that copy replaces the original message. Two behaviors depend on this.

Converting to SAAJ parses the entire request. Without the call, JAX-WS reads only as far as it needs to bind the parameters, so a request with malformed XML after the payload element is processed and answered with 200 instead of being rejected with a fault. Comparing the call present and removed on JDK 17:

  • unclosed element after the payload: 500 / 200
  • mismatched tags after the payload: 500 / 200
  • markup after : 500 / 200
  • truncated right after the payload: 500 / 500
  • valid request: 200 / 200

Responses are serialized from the SAAJ copy. Without the call, every response would lose the empty SOAP-ENV:Header, the extra xmlns:SOAP-ENV declaration and the xmlns="" on the return element. The XML means the same thing, but clients that compare raw text would see a difference.

The channel receives the same payload from a valid request either way, and mustUnderstand faults and faults raised by the service are unchanged, because handleFault() doesn't call getMessage().

Removing the call would save building a DOM for each request and response. But keeping the current strictness would need another full parse, which gives most of that saving back.

Found while looking into #509.

Assisted-by: Claude:claude-opus-5-5

LoggingSOAPHandler.handleMessage() calls smc.getMessage() and ignores
the result, so the call looks safe to remove. It isn't. In the JAX-WS
RI, getMessage() converts the message to an in-memory SAAJ copy, and
once the handler chain finishes, that copy replaces the original
message. Two behaviors depend on this.

Converting to SAAJ parses the entire request. Without the call, JAX-WS
reads only as far as it needs to bind the parameters, so a request
with malformed XML after the payload element is processed and answered
with 200 instead of being rejected with a fault. Comparing the call
present and removed on JDK 17:

- unclosed element after the payload: 500 / 200
- mismatched tags after the payload: 500 / 200
- markup after </Envelope>: 500 / 200
- truncated right after the payload: 500 / 500
- valid request: 200 / 200

Responses are serialized from the SAAJ copy. Without the call, every
response would lose the empty SOAP-ENV:Header, the extra xmlns:SOAP-ENV
declaration and the xmlns="" on the return element. The XML means the
same thing, but clients that compare raw text would see a difference.

The channel receives the same payload from a valid request either way,
and mustUnderstand faults and faults raised by the service are
unchanged, because handleFault() doesn't call getMessage().

Removing the call would save building a DOM for each request and
response. But keeping the current strictness would need another full
parse, which gives most of that saving back.

Found while looking into OpenIntegrationEngine#509.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Tony Germano <tony@germano.name>
@github-actions

Copy link
Copy Markdown

Test Results

129 files  ±0  129 suites  ±0   3m 42s ⏱️ + 1m 18s
737 tests ±0  737 ✅ ±0  0 💤 ±0  0 ❌ ±0 
827 runs  ±0  821 ✅ ±0  6 💤 ±0  0 ❌ ±0 

Results for commit f94d1d1. ± Comparison against base commit 6d348a0.

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.

4 participants