Bug 397902 - NPE when looking up a path from the servlet in Snaps
Summary: NPE when looking up a path from the servlet in Snaps
Status: NEW
Alias: None
Product: Virgo
Classification: RT
Component: snaps (show other bugs)
Version: 3.6.0.RELEASE   Edit
Hardware: PC Mac OS X
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2013-01-10 12:59 EST by Chris Frost CLA
Modified: 2017-03-07 05:35 EST (History)
4 users (show)

See Also:


Attachments
Patch for the described changes (1.25 KB, patch)
2017-03-07 05:35 EST, Stefan Zugal CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Frost CLA 2013-01-10 12:59:05 EST
User reported, see forum post http://www.eclipse.org/forums/index.php/m/998785/#msg_998785

At the very least we should handle this possibility but need to recreate the issue to fix properly.

java.lang.NullPointerException
	org.eclipse.virgo.snaps.core.internal.webapp.SnapServletContext.getResource(SnapServletContext.java:198)
	org.eclipse.virgo.snaps.core.internal.webapp.StaticResourceServlet.doGet(StaticResourceServlet.java:58)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:735)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
	org.eclipse.virgo.snaps.core.internal.webapp.container.ImmutableFilterChain.doFilter(ImmutableFilterChain.java:47)
	org.eclipse.virgo.snaps.core.internal.webapp.container.StandardVirtualContainerRequestDispatcher$1.doWithClassLoader(StandardVirtualContainerRequestDispatcher.java:104)
	org.eclipse.virgo.snaps.core.internal.webapp.container.StandardVirtualContainerRequestDispatcher$1.doWithClassLoader(StandardVirtualContainerRequestDispatcher.java:1)
	org.eclipse.virgo.snaps.core.internal.webapp.container.StandardVirtualContainerRequestDispatcher.doWithThreadContextClassLoader(StandardVirtualContainerRequestDispatcher.java:121)
	org.eclipse.virgo.snaps.core.internal.webapp.container.StandardVirtualContainerRequestDispatcher.service(StandardVirtualContainerRequestDispatcher.java:101)
	org.eclipse.virgo.snaps.core.internal.webapp.WebAppSnap.handleRequest(WebAppSnap.java:152)
	org.eclipse.virgo.snaps.core.RequestRouter.service(RequestRouter.java:51)
	org.eclipse.virgo.snaps.core.SnapHostFilter.doFilter(SnapHostFilter.java:62)
Comment 1 Stefan Zugal CLA 2017-03-07 05:35:06 EST
Created attachment 267134 [details]
Patch for the described changes

I tried to have a look at the problem, but I could not reproduce it, since the setup from http://www.eclipse.org/forums/index.php/m/998785/#msg_998785 is not available anymore (seems that the attachment was moved/deleted).

Regarding the reported NPE: In SnapServletContext:getResource, there is already a check whether the path is null, but this check is done after the path parameter was used, making the null-check useless (and causing the NPE). By moving the null-check to the very beginning of the method, the NPE is avoided and a MalformedURLException is thrown instead.

Even though this does not fix the problem (which I could not reproduce), it helps by providing a more specific exception.

What do you think?