From a4f127722af09a0e67f8df7c9aa3916b52d4595a Mon Sep 17 00:00:00 2001 From: Jouni Koivuviita Date: Fri, 28 Jun 2013 16:00:59 +0300 Subject: [PATCH] Fixed NPE in ApplicationRunnerServlet (#12145) 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 --- .../com/vaadin/launcher/ApplicationRunnerServlet.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java b/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java index 8c7edcac2e..a2f3c59f07 100644 --- a/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java +++ b/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java @@ -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"); -- 2.39.5