Skip to content

Fix inconsistent null handling between array and single object version RAM estimation#16296

Open
timgrein wants to merge 4 commits into
apache:mainfrom
timgrein:make-accountable-null-check-consistent
Open

Fix inconsistent null handling between array and single object version RAM estimation#16296
timgrein wants to merge 4 commits into
apache:mainfrom
timgrein:make-accountable-null-check-consistent

Conversation

@timgrein

Copy link
Copy Markdown
Contributor

When checking an array of Accountable there's an explicit null check avoiding NPEs, which would happen, when calling accountable.ramBytesUsed().

For the single object version sizeOf(Accountable accountable) this is not the case, therefore aligning the implementations.

@github-actions github-actions Bot added this to the 11.0.0 milestone Jun 25, 2026
@timgrein

Copy link
Copy Markdown
Contributor Author

I cannot add people as reviewers unfortunately. @ChrisHegarty can you maybe take a look?

@ChrisHegarty

Copy link
Copy Markdown
Contributor

Did you encounter this in a real situation, or why the need to allow null? ( I'm just raising the question as I believe this api has been like this for a long time, and want to know if it's a real issue or just for consistency's sake )

@timgrein

Copy link
Copy Markdown
Contributor Author

Did you encounter this in a real situation, or why the need to allow null? ( I'm just raising the question as I believe this api has been like this for a long time, and want to know if it's a real issue or just for consistency's sake )

@ChrisHegarty Yes I encountered it while working on a new CircuitBreaker for the inference API in Elasticsearch, where I've used it for RAM estimation. It felt inconvenient that I had to include a null-check, when I'm working with a single Accountable object vs. without a null-check when using an array.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants