Skip to content

fix: NPE in AbstractLogCollector.desensitizeShenyuRequestLog on null boxed Integer/Long - #6899

Open
nikhiln64 wants to merge 1 commit into
apache:masterfrom
nikhiln64:fix/desensitize-null-boxed-numbers
Open

fix: NPE in AbstractLogCollector.desensitizeShenyuRequestLog on null boxed Integer/Long#6899
nikhiln64 wants to merge 1 commit into
apache:masterfrom
nikhiln64:fix/desensitize-null-boxed-numbers

Conversation

@nikhiln64

Copy link
Copy Markdown

Fixes #6884

desensitizeShenyuRequestLog unconditionally calls toString on three boxed numeric fields of ShenyuRequestLog. For byte type media appendResponse invokes logResponse with a null writer, so a chunked response with no Content-Length header reaches desensitize with responseContentLength still null and the collector throws an NPE inside the response doFinally, losing the access log for that request. status and upstreamResponseTime are nullable on the same class of paths.

This change guards each of the three fields with Objects.nonNull before desensitizing, matching the null tolerance the String fields already get from StringUtils.hasLength inside desensitizeForSingleWord. Added AbstractLogCollectorTest covering the null case (chunked byte response shape) and the populated case (values preserved when keywords do not match them).

Note for reviewers, the issue body on #6884 describes a different bug due to an off by one paste in the Aug 4 batch, the analysis matching this title is in the body of #6883, details in my comment on the issue.

Make sure that:

  • You have read the contribution guidelines.
  • You submit test cases (unit or integration tests) that back your changes.
  • Your local test passed ./mvnw clean install -Dmaven.javadoc.skip=true (module scoped build of shenyu-plugin-logging-common with tests).

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.

[BUG] AbstractLogCollector.desensitizeShenyuRequestLog NPE on null boxed Integer/Long (chunked byte responses)

1 participant