On Fri, 26 Aug 2022 10:39:20 GMT, Sean Mullan <mul...@openjdk.org> wrote:
>> IntelliJ seems to think it could. The point of requireNonNull is that you >> control when an exception is thrown, and sooner rather than later is better. >> This code appears to have been working fine for a long time, so maybe NPE >> can't happen in practice. I'm fine with reverting this requireNonNull change >> here and elsewhere if you think it is unnecessary. > > Right, but in this case I think if an NPE is ever thrown it would be > considered a bug in the JDK because an unexpected RuntimeException would be > thrown. I think requireNonNull is used more in cases where caller input is > being validated and null is not valid. I find this code less readable. There > are lots of cases in the JDK code where some object could theoretically be > null, but it would be a bug if it was. If it was a normal case for a provider > to sometimes be null here, then I would expect this code to check for null > and handle it. > > @valeriep is more familiar with this code, so I would also like her feedback > on these changes to use requireNonNull. I don't see much benefit of using Objects.requireNonNull() here also for the reasons that Sean have already stated. ------------- PR: https://git.openjdk.org/jdk/pull/9972