Skip to content

Commit 0623275

Browse files
committed
Add nullability to JsonWriter
See gh-46926
1 parent 239f384 commit 0623275

File tree

7 files changed

+112
-79
lines changed

7 files changed

+112
-79
lines changed

core/spring-boot/src/main/java/org/springframework/boot/json/JsonValueWriter.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ private <N, V> void writePair(N name, @Nullable V value) {
257257
append(":");
258258
write(value);
259259
}
260-
this.path = this.path.parent();
260+
this.path = (this.path.parent() != null) ? this.path.parent() : MemberPath.ROOT;
261261
}
262262

263263
private void writeString(Object value) {
@@ -400,11 +400,17 @@ boolean addName(String processedName) {
400400
}
401401

402402
MemberPath updatePath(MemberPath path) {
403-
return (this.series != Series.ARRAY) ? path : path.child(this.index);
403+
if (this.series != Series.ARRAY) {
404+
return path;
405+
}
406+
return path.child(this.index);
404407
}
405408

406409
MemberPath restorePath(MemberPath path) {
407-
return (this.series != Series.ARRAY) ? path : path.parent();
410+
if (this.series != Series.ARRAY) {
411+
return path;
412+
}
413+
return (path.parent() != null) ? path.parent() : MemberPath.ROOT;
408414
}
409415

410416
void incrementIndexAndAddCommaIfRequired() {

0 commit comments

Comments
 (0)