Avoid direct URL construction and URL equality checks

Closes gh-29486
This commit is contained in:
Juergen Hoeller
2022-11-14 23:23:12 +01:00
parent 0b21c16fa8
commit aaeb5eb0d2
8 changed files with 87 additions and 59 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -312,7 +312,7 @@ final class PersistenceUnitReader {
// relative to the persistence unit root, according to the JPA spec
URL rootUrl = unitInfo.getPersistenceUnitRootUrl();
if (rootUrl != null) {
unitInfo.addJarFileUrl(new URL(rootUrl, value));
unitInfo.addJarFileUrl(ResourceUtils.toRelativeURL(rootUrl, value));
}
else {
logger.warn("Cannot resolve jar-file entry [" + value + "] in persistence unit '" +
@@ -363,7 +363,7 @@ final class PersistenceUnitReader {
if (persistenceUnitRoot.endsWith("/")) {
persistenceUnitRoot = persistenceUnitRoot.substring(0, persistenceUnitRoot.length() - 1);
}
return new URL(persistenceUnitRoot);
return ResourceUtils.toURL(persistenceUnitRoot);
}
}