Code Review Request: 7165118: (prefs) AbstractPreferences.remove(null) does not throw NPE

Alan Bateman Alan.Bateman at oracle.com
Wed May 2 09:55:53 UTC 2012


On 02/05/2012 04:54, David Holmes wrote:
> Hi Kurchi,
>
> You should also add:
>
> @throws NullPointerException {@inheritDoc}
>
> to the method spec so that the docs re-instate the fact that it is 
> supposed to throw NPE. As it stands I could argue that 
> AbstractPreferences.remove has chosen not to throw NPE for a null key 
> - leaving it up to removeSpi to do that if needed.
I think it would be an error to delegate null to the SPI method as it 
specified to guarantee that the key is non-null. So as 
AbstractPreferences is providing a default implementation of 
remove(String) then I think it should do the null check as proposed and 
it's javadoc should make it clear that NPE can be thrown (so I agree we 
should add @throws NullPointerException).

-Alan.





More information about the core-libs-dev mailing list