| Summary: | ServletContext.getRealPath() gives inconsistent results for paths ending with "/" | ||
|---|---|---|---|
| Product: | [RT] Jetty | Reporter: | Eirik Bjørsnøs <eirbjo> |
| Component: | server | Assignee: | Greg Wilkins <gregw> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | jetty-inbox |
| Version: | unspecified | ||
| Target Milestone: | 7.2.x | ||
| Hardware: | PC | ||
| OS: | Mac OS X - Carbon (unsup.) | ||
| Whiteboard: | |||
fixed for 7.3.1 |
Build Identifier: ServletContext.getRealPath() on a WebAppContext returns null when a non-existing directory path ends with a "/", but returns the path (where the virtual path "would have beeen") when the argument does not end with a "/"? The servlet spec isn't really clear, but only mentions returning null if the context is served from a war which isn't unpacked. The following test demonstrates the issue: @Test public void inconsistentRealPaths() throws Exception { // Given Server server = new Server(0); WebAppContext context = new WebAppContext(".", "/"); server.setHandler(context); server.start(); // When ServletContext ctx = context.getServletContext(); // Then // This passes: assertNotNull(ctx.getRealPath("/doesnotexist")); // This fails: assertNotNull(ctx.getRealPath("/doesnotexist/")); } Reproducible: Always Steps to Reproduce: See included unit test method.