Bug 56085 - IllegalArgumentException is thrown when calling getServletContext().getRealPath("\\")
Summary: IllegalArgumentException is thrown when calling getServletContext().getRealPa...
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 8
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 8.0.0-RC10
Hardware: PC All
: P2 normal (vote)
Target Milestone: ----
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-29 07:43 UTC by lobanova.e.o
Modified: 2015-02-10 13:49 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.