EgorBaranovEnjoysTyping opened a new pull request, #13495:
URL: https://github.com/apache/ignite/pull/13495
## IGNITE-28747: Fix NPE in GridToStringBuilder#handleRecursion
### Problem
`NullPointerException` occurs when `GridToStringBuilder.handleRecursion()`
is called during `toString()`
building of recursive structures. The `tail` field in
`SBLimitedLength` remains `null` because its
initialization was only triggered inside `onWrite()`, but
`handleRecursion()` directly calls `buf.a(...)`
methods, bypassing `onWrite()`.
### Root Cause
In `SBLimitedLength`, the original code in `master` branch directly called
`tail.append(...)` in all `a(...)`
methods without checking if `tail` is initialized first. This caused
NPE when recursion occurred.
### Solution
Added centralized `initTailIfAbsent()` method that checks and creates `tail`
only when needed. Replaced direct
`tail.append(...)` calls with `initTailIfAbsent()` +
`tail.append(...)` pattern.
### Related
JIRA: https://issues.apache.org/jira/browse/IGNITE-28747
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]