@@ -95,24 +95,37 @@ private List<String> strip(String base, URL[] urls) {
9595 @ Test
9696 @ DisabledOnOs (MAC ) // test fails on systems with case-insensitive volumes
9797 public void customerClassLoaderFunction () throws IOException {
98- Path rootDir = fakeFileSystem (EXAMPLE_FUNCTION );
99-
100- URLClassLoader customerClassLoader = new CustomerClassLoader (
101- rootDir .resolve ("user/path" ).toString (),
102- rootDir .resolve ("opt/java" ).toString (),
103- ClassLoader .getSystemClassLoader ());
104-
105- List <String > res = strip ("file:" + rootDir .toString (), customerClassLoader .getURLs ());
106-
107- Assertions .assertEquals (Arrays .asList (
108- "/user/path/" ,
109- "/user/path/lib/4.jar" ,
110- "/user/path/lib/A.jar" ,
111- "/user/path/lib/a.jar" ,
112- "/user/path/lib/b.jar" ,
113- "/user/path/lib/z.jar" ,
114- "/user/path/lib/λ.jar" ),
115- res );
98+ try {
99+ Path rootDir = fakeFileSystem (EXAMPLE_FUNCTION );
100+
101+ URLClassLoader customerClassLoader = new CustomerClassLoader (
102+ rootDir .resolve ("user/path" ).toString (),
103+ rootDir .resolve ("opt/java" ).toString (),
104+ ClassLoader .getSystemClassLoader ());
105+
106+ List <String > res = strip ("file:" + rootDir .toString (), customerClassLoader .getURLs ());
107+
108+ Assertions .assertEquals (Arrays .asList (
109+ "/user/path/" ,
110+ "/user/path/lib/4.jar" ,
111+ "/user/path/lib/A.jar" ,
112+ "/user/path/lib/a.jar" ,
113+ "/user/path/lib/b.jar" ,
114+ "/user/path/lib/z.jar" ,
115+ "/user/path/lib/λ.jar" ),
116+ res );
117+ } catch (Throwable t ) {
118+ // this system property is the name of the charset used when encoding/decoding file paths
119+ // exception is expected if it is not set to a UTF variant or not set at all
120+ String systemEncoding = System .getProperty ("sun.jnu.encoding" );
121+
122+ if (systemEncoding != null && !systemEncoding .toLowerCase ().contains ("utf" )){
123+ Assertions .assertTrue (t .getMessage ().contains ("Malformed input or input contains unmappable characters" ));
124+ }
125+ else {
126+ throw t ;
127+ }
128+ }
116129 }
117130
118131 @ Test
0 commit comments