Logging a Path object using structured logging throws StackOverflowError#44507
Closed
nosan wants to merge 1 commit intospring-projects:3.4.xfrom
Closed
Logging a Path object using structured logging throws StackOverflowError#44507nosan wants to merge 1 commit intospring-projects:3.4.xfrom
nosan wants to merge 1 commit intospring-projects:3.4.xfrom
Conversation
Contributor
Author
|
Pretty simple test to reproduce the cause of the issue. @Test
void writePathRecursively() {
writePath(Path.of("a"));
}
void writePath(Path path) {
System.out.println(path.toString());
path.forEach(this::writePath);
}a
a
a
a
a
a
a
java.lang.StackOverflowError
....
at org.gradle.internal.io.LinePerThreadBufferingOutputStream.println(LinePerThreadBufferingOutputStream.java:239)
at org.springframework.boot.json.JsonValueWriterTests.writePath(JsonValueWriterTests.java:264)
at java.base/java.lang.Iterable.forEach(Iterable.java:75)
at org.springframework.boot.json.JsonValueWriterTests.writePath(JsonValueWriterTests.java:265)
at java.base/java.lang.Iterable.forEach(Iterable.java:75)
at org.springframework.boot.json.JsonValueWriterTests.writePath(JsonValueWriterTests.java:265)
at java.base/java.lang.Iterable.forEach(Iterable.java:75) |
d85e7f2 to
a540be5
Compare
ba43b01 to
4a28258
Compare
Prior to this commit, serializing `java.nio.file.Path` caused a StackOverflowError because `Path.iterator()` always returns itself as the first element of the iterator, which results in a StackOverflowError. This commit serializes `java.nio.file.Path` as JSON String. Signed-off-by: Dmytro Nosan <dimanosan@gmail.com>
wilkinsona
pushed a commit
that referenced
this pull request
Apr 16, 2025
Prior to this commit, serializing `java.nio.file.Path` caused a StackOverflowError because `Path.iterator()` always returns itself as the first element of the iterator, which results in a StackOverflowError. This commit serializes `java.nio.file.Path` as JSON String. See gh-44507 Signed-off-by: Dmytro Nosan <dimanosan@gmail.com>
wilkinsona
added a commit
that referenced
this pull request
Apr 16, 2025
wilkinsona
added a commit
that referenced
this pull request
Apr 16, 2025
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.
See #44502