You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by gn...@apache.org on 2026/03/23 12:07:24 UTC
(maven) branch fix/realm-cache-dispose-ordering created (now 2f63a4ed4c)
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a change to branch fix/realm-cache-dispose-ordering
in repository https://gitbox.apache.org/repos/asf/maven.git
at 2f63a4ed4c [MNG-8572] Fix @PreDestroy ClassNotFoundException caused by premature ClassRealm disposal
This branch includes the following new commits:
new 2f63a4ed4c [MNG-8572] Fix @PreDestroy ClassNotFoundException caused by premature ClassRealm disposal
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(maven) 01/01: [MNG-8572] Fix @PreDestroy ClassNotFoundException caused by premature ClassRealm disposal
Posted by gn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch fix/realm-cache-dispose-ordering
in repository https://gitbox.apache.org/repos/asf/maven.git
commit 2f63a4ed4c48478871baa23e607c662a571fd28e
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Mon Mar 23 13:07:12 2026 +0100
[MNG-8572] Fix @PreDestroy ClassNotFoundException caused by premature ClassRealm disposal
The Plexus Disposable.dispose() lifecycle runs before Sisu's @PreDestroy
callbacks. When dispose() called flush(), it disposed ClassRealms before
@PreDestroy methods on beans loaded from those realms could execute,
causing ClassNotFoundException.
Change dispose() to only clear the cache map without disposing realms.
The flush() method (used for explicit cache clearing between builds)
remains unchanged. ClassRealms are disposed when the PlexusContainer
shuts down after all lifecycle callbacks complete.
Co-Authored-By: Claude Opus 4.6 <no...@anthropic.com>
---
.../main/java/org/apache/maven/plugin/DefaultExtensionRealmCache.java | 2 +-
.../src/main/java/org/apache/maven/plugin/DefaultPluginRealmCache.java | 2 +-
.../main/java/org/apache/maven/project/DefaultProjectRealmCache.java | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/impl/maven-core/src/main/java/org/apache/maven/plugin/DefaultExtensionRealmCache.java b/impl/maven-core/src/main/java/org/apache/maven/plugin/DefaultExtensionRealmCache.java
index b202115258..ce3cb5135f 100644
--- a/impl/maven-core/src/main/java/org/apache/maven/plugin/DefaultExtensionRealmCache.java
+++ b/impl/maven-core/src/main/java/org/apache/maven/plugin/DefaultExtensionRealmCache.java
@@ -149,6 +149,6 @@ public void register(MavenProject project, Key key, CacheRecord record) {
@Override
public void dispose() {
- flush();
+ cache.clear();
}
}
diff --git a/impl/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginRealmCache.java b/impl/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginRealmCache.java
index 681955f21d..1e822a2ccb 100644
--- a/impl/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginRealmCache.java
+++ b/impl/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginRealmCache.java
@@ -215,6 +215,6 @@ public void register(MavenProject project, Key key, CacheRecord record) {
@Override
public void dispose() {
- flush();
+ cache.clear();
}
}
diff --git a/impl/maven-core/src/main/java/org/apache/maven/project/DefaultProjectRealmCache.java b/impl/maven-core/src/main/java/org/apache/maven/project/DefaultProjectRealmCache.java
index 82a1a814c1..9111177c34 100644
--- a/impl/maven-core/src/main/java/org/apache/maven/project/DefaultProjectRealmCache.java
+++ b/impl/maven-core/src/main/java/org/apache/maven/project/DefaultProjectRealmCache.java
@@ -125,6 +125,6 @@ public void register(MavenProject project, Key key, CacheRecord record) {
@Override
public void dispose() {
- flush();
+ cache.clear();
}
}