Skip to content

Ignite 28747 quick fix - #13495

Open
EgorBaranovEnjoysTyping wants to merge 13 commits into
apache:masterfrom
EgorBaranovEnjoysTyping:ignite-28747-quick-fix
Open

Ignite 28747 quick fix#13495
EgorBaranovEnjoysTyping wants to merge 13 commits into
apache:masterfrom
EgorBaranovEnjoysTyping:ignite-28747-quick-fix

Conversation

@EgorBaranovEnjoysTyping

Copy link
Copy Markdown
Contributor

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

* @param headLength Head length.
*/
private SBLimitedLength getStrBuilder(int headLength) {
SBLimitedLength sbLimitedLength = new SBLimitedLength(0);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
SBLimitedLength sbLimitedLength = new SBLimitedLength(0);
SBLimitedLength sb = new SBLimitedLength(0);

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.

2 participants