Browse Source

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
tags/7.7.3
Artur Signell 7 years ago
parent
commit
977cec7e31

+ 17
- 4
server/src/main/java/com/vaadin/server/widgetsetutils/ClassPathExplorer.java View File

@@ -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;

Loading…
Cancel
Save