You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Violeta Georgieva <mi...@gmail.com> on 2013/01/03 15:30:03 UTC

Question about bug 54284

Hi,

I have a question about bug 54284 (Util.objectNameValueNeedsQuote throws
NPE for anonymous Filters)

ServletContext.addFilter javadoc specifies:

"
FilterRegistration.Dynamic addFilter(java.lang.String filterName, Filter
filter)

Registers the given filter instance with this ServletContext under the
given filterName.
The registered filter may be further configured via the returned
FilterRegistration object.

If this ServletContext already contains a preliminary FilterRegistration
for a filter with the given filterName, it will be completed (by assigning
the class name of the given filter instance to it) and returned.

Parameters:

filterName - the name of the filter
filter - the filter instance to register

Returns:

a FilterRegistration object that may be used to further configure the given
filter, or null if this ServletContext already contains a complete
FilterRegistration for a filter with the given filterName or if the same
filter instance has already been registered with this or another
ServletContext in the same container

Throws:

java.lang.IllegalStateException - if this ServletContext has already been
initialized
java.lang.UnsupportedOperationException - if this ServletContext was passed
to the
ServletContextListener.contextInitialized(javax.servlet.ServletContextEvent)
method of a ServletContextListener that was neither declared in web.xml or
web-fragment.xml, nor annotated with WebListener

Since:
Servlet 3.0
"

I think that when the filter name is NULL the proper behaviour is to return
IllegalArgumentException.
>From other point of view the method's javadoc specifies only
IllegalStateException and UnsupportedOperationException.
If the method starts returning IllegalArgumentException it will be
backwards incompatible change and also not compliant with the specification.

What do you think?
Are there any clarifications in the Servlet 3.1 specification?

Regards
Violeta

Re: Question about bug 54284

Posted by Violeta Georgieva <mi...@gmail.com>.
Thanks

2013/1/3 Mark Thomas <ma...@apache.org>

> On 03/01/2013 14:30, Violeta Georgieva wrote:
>
> > I think that when the filter name is NULL the proper behaviour is to
> return
> > IllegalArgumentException.
> > From other point of view the method's javadoc specifies only
> > IllegalStateException and UnsupportedOperationException.
> > If the method starts returning IllegalArgumentException it will be
> > backwards incompatible change and also not compliant with the
> specification.
> >
> > What do you think?
>
> I think that there is strong implication from the Javadoc that the name
> is required. That said, when using this API a name isn't absolutely
> necessary so it could be made optional (ignoring the JMX name issues).
>
> IllegalArgumentException is a runtime exception so as long as it is not
> added to the method signature (it doesn't need to be) that will not
> break the API tests in the TCK.
>
> > Are there any clarifications in the Servlet 3.1 specification?
>
> Not that I am aware of. I'd suggest creating a Jira issue and requesting
> clarification. I usually find to helpful to suggest a solution in the
> Jira which in this case I think is that the name should be required.
>
> The issue can be left in the NEEDINFO state with a link to the Servlet
> Jira until we get clarification.
>
> Mark
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
>

Re: Question about bug 54284

Posted by Mark Thomas <ma...@apache.org>.
On 03/01/2013 14:30, Violeta Georgieva wrote:

> I think that when the filter name is NULL the proper behaviour is to return
> IllegalArgumentException.
> From other point of view the method's javadoc specifies only
> IllegalStateException and UnsupportedOperationException.
> If the method starts returning IllegalArgumentException it will be
> backwards incompatible change and also not compliant with the specification.
> 
> What do you think?

I think that there is strong implication from the Javadoc that the name
is required. That said, when using this API a name isn't absolutely
necessary so it could be made optional (ignoring the JMX name issues).

IllegalArgumentException is a runtime exception so as long as it is not
added to the method signature (it doesn't need to be) that will not
break the API tests in the TCK.

> Are there any clarifications in the Servlet 3.1 specification?

Not that I am aware of. I'd suggest creating a Jira issue and requesting
clarification. I usually find to helpful to suggest a solution in the
Jira which in this case I think is that the name should be required.

The issue can be left in the NEEDINFO state with a link to the Servlet
Jira until we get clarification.

Mark


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org