]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fixed NPE in ApplicationRunnerServlet (#12145)
authorJouni Koivuviita <jouni@vaadin.com>
Fri, 28 Jun 2013 13:00:59 +0000 (16:00 +0300)
committerVaadin Code Review <review@vaadin.com>
Fri, 28 Jun 2013 13:03:59 +0000 (13:03 +0000)
If the path for a test case file contained special characters (such as
space), they would get URL encoded which wouldn't work for File
constructors.

Fixed by using URI.getPath(), which does the decoding.

Change-Id: I2a7c13b785adbb2e486d3807b115540c0ba70fa6

uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java

index 8c7edcac2ec19b4bfebd3d11ba1a58102b9502b7..a2f3c59f07dde8b470214ff11cb648c579a6ce9c 100644 (file)
@@ -18,6 +18,8 @@ package com.vaadin.launcher;
 import java.io.File;
 import java.io.IOException;
 import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.Collections;
 import java.util.LinkedHashSet;
@@ -64,7 +66,13 @@ public class ApplicationRunnerServlet extends LegacyVaadinServlet {
         String str = TestBase.class.getName().replace('.', '/') + ".class";
         URL url = getService().getClassLoader().getResource(str);
         if ("file".equals(url.getProtocol())) {
-            File comVaadinTests = new File(url.getPath()).getParentFile()
+            String path = url.getPath();
+            try {
+                path = new URI(path).getPath();
+            } catch (URISyntaxException e) {
+                getLogger().log(Level.FINE, "Failed to decode url", e);
+            }
+            File comVaadinTests = new File(path).getParentFile()
                     .getParentFile();
             addDirectories(comVaadinTests, defaultPackages, "com.vaadin.tests");