aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2016-09-23 22:08:39 +0300
committerArtur Signell <artur@vaadin.com>2016-09-25 15:30:57 +0300
commit977cec7e3107c2da306d46449dbf32f6544313be (patch)
tree3844f703f15be718a9092659f8a7370de8b239a1
parent092b4f7f3192555fe3ae22ac03a89ac2ada2a2dd (diff)
downloadvaadin-framework-977cec7e3107c2da306d46449dbf32f6544313be.tar.gz
vaadin-framework-977cec7e3107c2da306d46449dbf32f6544313be.zip
Fix widget set builder to create widget set in correct location (#20320)
The fix for #20285 generates URLs so that the end in a slash, where the old version generated URLs without the trailing slash. The trailing slash was not taken into account by the code which updates a widget set. Change-Id: Iabe716ed1632da7b2a6b1f4ffdc987c745d9452d
-rw-r--r--server/src/main/java/com/vaadin/server/widgetsetutils/ClassPathExplorer.java21
1 files changed, 17 insertions, 4 deletions
diff --git a/server/src/main/java/com/vaadin/server/widgetsetutils/ClassPathExplorer.java b/server/src/main/java/com/vaadin/server/widgetsetutils/ClassPathExplorer.java
index fefdf18e70..1f69de073e 100644
--- a/server/src/main/java/com/vaadin/server/widgetsetutils/ClassPathExplorer.java
+++ b/server/src/main/java/com/vaadin/server/widgetsetutils/ClassPathExplorer.java
@@ -223,8 +223,21 @@ public class ClassPathExplorer {
if (!widgetsets.containsKey(classname)) {
String packagePath = packageName.replaceAll("\\.", "/");
- String basePath = location.getFile()
- .replaceAll("/" + packagePath + "$", "");
+
+ String basePath = location.getFile();
+ if (basePath.endsWith("/" + packagePath)) {
+ basePath = basePath.replaceAll("/" + packagePath + "$",
+ "");
+ } else if (basePath.endsWith("/" + packagePath + "/")) {
+ basePath = basePath.replaceAll("/" + packagePath + "/$",
+ "");
+ } else {
+ throw new IllegalStateException(
+ "Error trying to find base path, location ("
+ + location.getFile()
+ + ") does not end in expected '/"
+ + packagePath + "'");
+ }
try {
URL url = new URL(location.getProtocol(),
location.getHost(), location.getPort(),
@@ -453,8 +466,8 @@ public class ClassPathExplorer {
&& !dirs[i].getPath().contains(File.separator + ".")) {
String key = dirs[i].getCanonicalPath() + "/" + name
+ dirs[i].getName();
- locations.put(key,
- dirs[i].getCanonicalFile().toURI().toURL());
+ URL url = dirs[i].getCanonicalFile().toURI().toURL();
+ locations.put(key, url);
}
} catch (Exception ioe) {
return;