On Fri, 27 Jun 2025 12:06:21 GMT, Artem Semenov <aseme...@openjdk.org> wrote:

> > > At most I would add an assert, but generally my understanding is that the 
> > > user of any closure has the responsibility of passing it valid input.
> > 
> > 
> > Adding asserts sounds like a good suggestion.
> 
> It seems to me that this won’t be a big problem in this form. I’ve just moved 
> the existing check higher up, where it will prevent dereferencing a null 
> pointer.
> 
> However, if you confirm that this is not acceptable, I will replace the check 
> with assert.

I think it is a matter of having the code accurately document the input 
requirements. Checking for null and returning makes it look like passing null 
is ok and might happen. That's not the case though. It should never happen and 
adding an assert properly documents this.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/26002#issuecomment-3013875492

Reply via email to