https://bz.apache.org/bugzilla/show_bug.cgi?id=66388

            Bug ID: 66388
           Summary: Classpath resource having a name containing a space
                    can't be read anymore by
                    ClassLoader.getResources(String name)
           Product: Tomcat 9
           Version: 9.0.70
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: regression
          Priority: P2
         Component: Catalina
          Assignee: dev@tomcat.apache.org
          Reporter: reda-ala...@hey.com
  Target Milestone: -----

We are trying to upgrade from Tomcat 9.0.69 to 9.0.70.

Booting our application on 9.0.70 fails because we are trying to read a the
content of a classpath resource (sql file) having name containing a space.
The file name is:
'com/aqme/product/database/migration/sql/_443/V443_17_36495__some name.sql'

I think this is caused by
https://github.com/apache/tomcat/commit/2a03ff1b778e6f4d05a60c3a9597b42ed4176aed#diff-019a2ddbffcf645220f667a8344672adca68f474f437195916ff157adb955fadR129
aka "Refactor code base to replace use of URL constructors. While they are
deprecated in Java 20 onwards, the reasons for deprecation are valid for all
versions so move away from them now." .

According to my test, the URI constructor considers a space character as
illegal:


>import java.net.URISyntaxException;

>class Scratch {
>       public static void main(String[] args) throws URISyntaxException {
>               new 
> >java.net.URI("com/aqme/product/database/migration/sql/_443/V443_17_36495__some
>  name.sql");
>       }
>}

>Exception in thread "main" java.net.URISyntaxException: Illegal character in 
>>path at index 65: 
>>com/aqme/product/database/migration/sql/_443/V443_17_36495__some name.sql
>       at java.base/java.net.URI$Parser.fail(URI.java:2974)
>       at java.base/java.net.URI$Parser.checkChars(URI.java:3145)
>       at java.base/java.net.URI$Parser.parseHierarchical(URI.java:3227)
>       at java.base/java.net.URI$Parser.parse(URI.java:3186)
>       at java.base/java.net.URI.<init>(URI.java:623)
>       at Scratch.main(scratch_11.java:5)

So my guess is that since
https://github.com/apache/tomcat/commit/2a03ff1b778e6f4d05a60c3a9597b42ed4176aed#diff-019a2ddbffcf645220f667a8344672adca68f474f437195916ff157adb955fadR129
any resource name containing a space will be unreachable.

Is it forbidden (from the Java Spec) to ask a ClassLoader for a resource name
containing a space? If yes, could you please push back this breaking change to
a new Tomcat major version?

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to