Fix StackOverflowError with JsonValueWriter re-entrancy in ValueProce… - #51589
Open
beligh-hamdi wants to merge 1 commit into
Open
Fix StackOverflowError with JsonValueWriter re-entrancy in ValueProce…#51589beligh-hamdi wants to merge 1 commit into
beligh-hamdi wants to merge 1 commit into
Conversation
…ssor - Add re-entrancy guard in JsonValueWriter#processValue using Java Streams - Add unit test verifying ValueProcessor re-entrancy protection Closes spring-projectsgh-50651 Signed-off-by: Beligh HAMDI <beligh.hamdi@gmail.com>
beligh-hamdi
force-pushed
the
fix-50651-json-value-processor-recursion
branch
from
September 4, 2026 15:51
66ff7e3 to
9808dee
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix: StackOverflowError at startup with embedded Tomcat, ecs, debug level, and members value processor
This pull request fixes issue #50651 where applications experienced a
StackOverflowErrorat startup when combining embedded Tomcat, ECS structured logging, debug log level, and a customStructuredLoggingJsonMembersCustomizerapplying a membersValueProcessor.Broken Behavior
During structured JSON serialization of log events (such as exceptions/throwables via Logback's
ThrowableProxy), evaluatingValueProcessorinstances can inadvertently trigger logging operations or class loading (TomcatEmbeddedWebappClassLoader). If these internal triggers attempt to write JSON or re-evaluate values, it leads to unconstrained re-entrancy and infinite recursion (StackOverflowError).How the Changes Fix It
processingValueflag) toJsonValueWriter#processValue(V)utilizing Java Streams and.reduce()for functional elegance.valueProcessorShouldNotAllowReentrancy) inJsonValueWriterTeststo ensure re-entrant value processing does not cause infinite recursion or throw exceptions.Fixes #50651