Skip to content

Commit

Permalink
Fixup apache#49 Could not notify CliPluginRealmCache.
Browse files Browse the repository at this point in the history
Let's better not compare on realPaths. That would give unexpected
results in situations when something is symlinked into the source tree.
ppalaga committed Aug 12, 2020
1 parent 78f1b23 commit 44e2959
Showing 1 changed file with 1 addition and 12 deletions.
Original file line number Diff line number Diff line change
@@ -442,8 +442,7 @@ public void onEvent(Object event) throws Exception {
try {
if (event instanceof MavenExecutionRequest) {
/* Store the multiModuleProjectDirectory path */
multiModuleProjectDirectory = ((MavenExecutionRequest) event).getMultiModuleProjectDirectory().toPath()
.toRealPath();
multiModuleProjectDirectory = ((MavenExecutionRequest) event).getMultiModuleProjectDirectory().toPath();
} else if (event instanceof MavenExecutionResult) {
/* Evict the entries refering to jars under multiModuleProjectDirectory */
final Iterator<Entry<Key, ValidableCacheRecord>> i = cache.entrySet().iterator();
@@ -453,17 +452,7 @@ public void onEvent(Object event) throws Exception {
for (URL url : record.getRealm().getURLs()) {
if (url.getProtocol().equals("file")) {
final Path path = Paths.get(url.toURI());
boolean remove = false;
if (path.startsWith(multiModuleProjectDirectory)) {
remove = true;
} else if (Files.exists(path)) {
/* Try to convert to real path only if the file exists */
final Path realPath = path.toRealPath();
if (realPath.startsWith(multiModuleProjectDirectory)) {
remove = true;
}
}
if (remove) {
log.debug(
"Removing PluginRealmCache entry {} because it refers to an artifact in the build tree {}",
entry.getKey(), path);

0 comments on commit 44e2959

Please sign in to comment.