Bug 56085

Summary: IllegalArgumentException is thrown when calling getServletContext().getRealPath("\\")
Product: Tomcat 8 Reporter: lobanova.e.o
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Severity: normal    
Priority: P2    
Version: 8.0.0-RC10   
Target Milestone: ----   
Hardware: PC   
OS: All   

Description lobanova.e.o 2014-01-29 07:43:57 UTC
When getServletContext().getRealPath(System.getProperty("file.separator")) is called in Windows OS, where the file separator is a back slash, the getServletContext().getRealPath("\\") method throws an IllegalArgumentException.

It seems to work fine in Tomcat 7.0, but fails in 8.0-RC10.
As a temporary workaround solution, I changed the separator to the right slash ("/").
Comment 1 Mark Thomas 2014-01-30 08:21:09 UTC
The argument for getRealPath() is a virtual path and should therefore always use "/" as a file separator irrespective of the operating system Tomcat is running on.

However, throwing an IllegalArgumentException in this case does not appear to be justified by the Javadoc. getRealPath("\\") should return null.
Comment 2 Mark Thomas 2014-01-30 08:30:05 UTC
This has been fixed in 8.0.x and will be included in 8.0.2 onwards.
Comment 3 Konstantin Kolinko 2015-02-10 13:49:34 UTC
Restore "Version" field back to 8.0.0-RC10

This issue was reported in 8.0-RC10 and fixed since 8.0.2.