[jsr369-experts] Re: [servlet-spec users] [SERVLET_SPEC-83] ServletContext getInitParameter(), getAttribute() and null values

From: Mark Thomas <markt_at_apache.org>
Date: Thu, 13 Aug 2015 08:51:07 +0100

On 12/08/2015 23:54, Edward Burns wrote:
>>>>>> On Wed, 12 Aug 2015 15:06:22 -0700, Shing Wai Chan <shing.wai.chan_at_oracle.com> said:
> SW> Using String("null") in this case may not be a good idea as it
> SW> introduces some special meaning of the String("null").
> SW> I notice that different implementations seems to behave differently for
> SW> ServletContext.getInitParameter(null).
> SW> In GlassFish, it is NPE.
> SW> In WebLogic, it is null.
> Ahh, I misunderstood you. I thought the issue was asking about what to
> return if the someone had done
> <init-param>
> <param-name>SomeValue</param-name>
> <param-value></param-value>
> </init-param>
> What do you think we should do in that case?

For the above case I would say that the parameter value was the empty

> I agree that we should throw NPE if the argument is null.

For clarity, you are saying:

ServletContext.getInitParameter(null) should throw NPE
ServletContext.getAttribute(null) should throw NPE

right? If so, I agree.

While we are at it we should add:

ServletContext.setInitParameter(null, <anything>) should throw NPE
ServletContext.setAttribute(null, <anything>) should throw NPE