Bug 54284 - Util.objectNameValueNeedsQuote throws NPE for anonymous Filters
Summary: Util.objectNameValueNeedsQuote throws NPE for anonymous Filters
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 7
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 7.0.34
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-12 15:51 UTC by benjamin.gehrels_external
Modified: 2013-01-07 19:11 UTC (History)
1 user (show)



Attachments
Patch proposal (5.15 KB, patch)
2013-01-05 12:48 UTC, Violeta Georgieva
Details | Diff
Test case (5.80 KB, patch)
2013-01-05 12:51 UTC, Violeta Georgieva
Details | Diff
patch proposal (5.16 KB, patch)
2013-01-07 11:57 UTC, Violeta Georgieva
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description benjamin.gehrels_external 2012-12-12 15:51:40 UTC
How to reproduce?

From inside the contextInitialized-Method of an ServletContextListener instance, call

context.addFilter(null,
      new ArbitraryFilter(pathPrefix)).addMappingForUrlPatterns(null, false, pathPrefix);

What happens?

Dec 12, 2012 3:59:03 PM org.apache.catalina.core.StandardContext filterStart
SEVERE: Exception starting filter null
java.lang.NullPointerException
        at org.apache.tomcat.util.modeler.Util.objectNameValueNeedsQuote(Util.java:26)
        at org.apache.catalina.core.ApplicationFilterConfig.registerJMX(ApplicationFilterConfig.java:421)
        at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:282)
        at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:108)
        at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4650)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5306)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
        at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:657)
        at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1637)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
        at java.util.concurrent.FutureTask.run(FutureTask.java:166)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
        at java.lang.Thread.run(Thread.java:722)

Dec 12, 2012 3:59:03 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error filterStart
Dec 12, 2012 3:59:03 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [] startup failed due to previous errors


What should happen?
Either - if null is not an allowed filter name, throw a IllegalArgumentException on context.addFilter(...)
Or, if it is an allowed filter name, handle null-values gracefully
Comment 1 benjamin.gehrels_external 2012-12-13 11:45:24 UTC
I just recognized that i created the bug with a wrong affected version number.
The bug happens in Rel. 7.0.34, probably as a result of fixing #54170
Comment 2 Violeta Georgieva 2013-01-02 21:56:02 UTC
Hi,

I'm going to work on this.

Regards
Violeta
Comment 3 Violeta Georgieva 2013-01-03 16:30:07 UTC
Hi,

Servlet 3.0 javadoc does not specify what should be the behavior when filterName is NULL.
I requested a clarification [1] from the Servlet Specification expert group.
I'm changing the status to NEEDINFO.

Regards
Violeta

[1] http://java.net/jira/browse/SERVLET_SPEC-51
Comment 4 Violeta Georgieva 2013-01-05 12:48:28 UTC
Created attachment 29817 [details]
Patch proposal
Comment 5 Violeta Georgieva 2013-01-05 12:51:17 UTC
Created attachment 29818 [details]
Test case
Comment 6 Violeta Georgieva 2013-01-05 12:55:33 UTC
Hi,

As per clarification provided by Servlet Specification expert group - IllegalArgumentException should be thrown when filter name is NULL or empty string.

Patch proposal and test case are attached.

Any comments will be appreciated.

Regards
Violeta
Comment 7 Violeta Georgieva 2013-01-07 11:57:14 UTC
Created attachment 29822 [details]
patch proposal
Comment 8 Mark Thomas 2013-01-07 19:11:04 UTC
Thanks for the patch and for working with the EG to obtain the clarification.

The patch has been applied to trunk and 7.0.x and will be included in 7.0.35 onwards.