You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "cstamas (via GitHub)" <gi...@apache.org> on 2026/10/16 17:10:58 UTC
[PR] fix: JSR330 filtering fix [maven]
cstamas opened a new pull request, #13582:
URL: https://github.com/apache/maven/pull/13582
Maven Core Extensions are having JSR330 filtering applied as well, but alas, when they are present, class realm layout changes a bit and visibility becomes invisibility. Using Sisu latest API to basically turn off filtering for JSR330 beans (so making it happen the very same as it was in Maven 3.9) when it comes to Maven Core Extensions.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: JSR330 filtering fix [maven]
Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on code in PR #13582:
URL: https://github.com/apache/maven/pull/13582#discussion_r4311378977
##########
maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycles.java:
##########
@@ -132,24 +127,8 @@ public Map<String, Lifecycle> getPhaseToLifecycleMap() {
public List<Lifecycle> getLifeCycles() {
// ensure canonical order of standard lifecycles
- Map<String, Lifecycle> lifecycles = new LinkedHashMap<>();
-
- // filter by visibility (plexus vs sisu diff; "realms" are plexus thing)
- // in some tests container is not injected
- if (this.plexusContainer != null) {
- for (String name : this.lifecycles.keySet()) {
- if (!isEnabled(name)) {
- continue;
- }
- try {
- lifecycles.put(name, plexusContainer.lookup(Lifecycle.class, name));
- } catch (ComponentLookupException e) {
- // skip it
- }
- }
- } else {
- lifecycles.putAll(this.lifecycles);
- }
+ // take "snapshot": will filter by visibility
+ Map<String, Lifecycle> lifecycles = new LinkedHashMap<>(this.lifecycles);
LinkedHashSet<String> lifecycleNames = new LinkedHashSet<>(getStandardLifecycles());
lifecycleNames.addAll(lifecycles.keySet());
Review Comment:
Wrong: filtering does happens.
Fixed: the enabled filtering of lifecycle, added UT to cover it too.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: JSR330 filtering fix [maven]
Posted by "pzygielo (via GitHub) via issues" <is...@maven.apache.org>.
pzygielo commented on PR #13582:
URL: https://github.com/apache/maven/pull/13582#issuecomment-6899543126
I think this caused https://lists.apache.org/thread.html/g47zd1kvtj4wmmr8l3q22o896p55s7x8 - where groovy-eclipse-compiler registered as extension (https://github.com/groovy/groovy-eclipse/wiki/groovy-eclipse-maven-plugin#use-the-groovy-eclipse-compiler-mojo-for-configuring-source-folders) has no `:add-groovy-build-paths` executed.
That worked fine in 3.10.0 and previously in 3.9.16 as well.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: JSR330 filtering fix [maven]
Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on code in PR #13582:
URL: https://github.com/apache/maven/pull/13582#discussion_r4314270790
##########
maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycles.java:
##########
@@ -132,24 +127,8 @@ public Map<String, Lifecycle> getPhaseToLifecycleMap() {
public List<Lifecycle> getLifeCycles() {
// ensure canonical order of standard lifecycles
- Map<String, Lifecycle> lifecycles = new LinkedHashMap<>();
-
- // filter by visibility (plexus vs sisu diff; "realms" are plexus thing)
- // in some tests container is not injected
- if (this.plexusContainer != null) {
- for (String name : this.lifecycles.keySet()) {
- if (!isEnabled(name)) {
- continue;
- }
- try {
- lifecycles.put(name, plexusContainer.lookup(Lifecycle.class, name));
- } catch (ComponentLookupException e) {
- // skip it
- }
- }
- } else {
- lifecycles.putAll(this.lifecycles);
- }
+ // take "snapshot": will filter by visibility
+ Map<String, Lifecycle> lifecycles = new LinkedHashMap<>(this.lifecycles);
LinkedHashSet<String> lifecycleNames = new LinkedHashSet<>(getStandardLifecycles());
lifecycleNames.addAll(lifecycles.keySet());
Review Comment:
_Claude Code on behalf of Guillaume Nodet_
You're right @cstamas, the bot's assertion about Sisu visibility filtering was incorrect. I verified by reading through Sisu's source code — the injected `Map<String, Lifecycle>` is **not** a plain snapshot.
The chain works as follows:
1. `DefaultBeanLocator.locate()` wraps the `LocatedBeans` in a `FilteredBeans` when a predicate supplier is set — filtering is lazy, not done at injection time.
2. `BeanProviders.stringMapOf()` returns an `EntryMapAdapter` backed by that `FilteredBeans` iterable.
3. `EntryMapAdapter` extends `AbstractMap` and delegates every `entrySet().iterator()` call back through `FilteredBeans.iterator()`, which applies the visibility predicate on each `BeanEntry`.
So every iteration over the injected map (e.g. `forEach`, `keySet()`, `values()`) dynamically filters through the predicate — entries that fail visibility are simply skipped. There is no static "snapshot" that bypasses filtering.
Apologies for the noise from the bot on this one.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: JSR330 filtering fix [maven]
Posted by "gnodet-bot (via GitHub)" <gi...@apache.org>.
gnodet-bot commented on code in PR #13582:
URL: https://github.com/apache/maven/pull/13582#discussion_r4308984290
##########
maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycles.java:
##########
@@ -132,24 +127,8 @@ public Map<String, Lifecycle> getPhaseToLifecycleMap() {
public List<Lifecycle> getLifeCycles() {
// ensure canonical order of standard lifecycles
- Map<String, Lifecycle> lifecycles = new LinkedHashMap<>();
-
- // filter by visibility (plexus vs sisu diff; "realms" are plexus thing)
- // in some tests container is not injected
- if (this.plexusContainer != null) {
- for (String name : this.lifecycles.keySet()) {
- if (!isEnabled(name)) {
- continue;
- }
- try {
- lifecycles.put(name, plexusContainer.lookup(Lifecycle.class, name));
- } catch (ComponentLookupException e) {
- // skip it
- }
- }
- } else {
- lifecycles.putAll(this.lifecycles);
- }
+ // take "snapshot": will filter by visibility
+ Map<String, Lifecycle> lifecycles = new LinkedHashMap<>(this.lifecycles);
LinkedHashSet<String> lifecycleNames = new LinkedHashSet<>(getStandardLifecycles());
lifecycleNames.addAll(lifecycles.keySet());
Review Comment:
⚠️ **Bug: `isEnabled()` filtering is lost, and the comment is misleading.**
The comment says "will filter by visibility" but no filtering happens here. The Sisu visibility predicate configured in `MavenCli.setVisibilityPredicateSupplierTransformer` operates at injection time — it does NOT filter the `Map<String, Lifecycle>` snapshot taken on line 131.
More critically, `lifecycleNames.addAll(lifecycles.keySet())` on line 134 re-adds **all** lifecycle names (including those `getStandardLifecycles()` may have excluded via `isEnabled()`), so the `maven.site.lifecycle.disabled` system property no longer has any effect.
The old code explicitly called `isEnabled(name)` inside the loop to skip disabled lifecycles. That guard needs to be preserved, e.g.:
```java
Map<String, Lifecycle> lifecycles = new LinkedHashMap<>();
this.lifecycles.forEach((name, lc) -> {
if (isEnabled(name)) {
lifecycles.put(name, lc);
}
});
```
The same issue applies symmetrically to `DefaultLifecyclePluginAnalyzer.java` — the old Plexus-based filtering there also served as a visibility gate; the new snapshot copies all mappings without filtering.
##########
pom.xml:
##########
@@ -126,7 +126,7 @@ under the License.
<properties>
<javaVersion>8</javaVersion>
- <version.sisu-maven-plugin>1.1.0</version.sisu-maven-plugin>
+ <version.sisu-maven-plugin>1.1.1-SNAPSHOT</version.sisu-maven-plugin>
Review Comment:
⚠️ **SNAPSHOT dependency blocks merge.**
`sisu-maven-plugin 1.1.1-SNAPSHOT` is a pre-release artifact — it cannot be used in a release or merged into a branch that may produce a release. Please either wait for `1.1.1` to be released and use that, or restructure the PR so the Sisu API used is available in the released `1.1.0`. The snapshot repository blocks should also be removed before merge.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: JSR330 filtering fix [maven]
Posted by "gnodet-bot (via GitHub)" <gi...@apache.org>.
gnodet-bot commented on code in PR #13582:
URL: https://github.com/apache/maven/pull/13582#discussion_r4324386486
##########
maven-embedder/src/test/java/org/apache/maven/cli/internal/BootstrapCoreExtensionManagerTest.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.cli.internal;
+
+import org.codehaus.plexus.classworlds.ClassWorld;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Guards the JSR330 visibility filtering bypass: it must apply only when the TCCL is (a child of) a core extension realm.
+ */
+class BootstrapCoreExtensionManagerTest {
+ private final ClassLoader origTccl = Thread.currentThread().getContextClassLoader();
+
+ private ClassWorld world;
+
+ @BeforeEach
+ void setUp() {
+ world = new ClassWorld();
+ }
+
+ @AfterEach
+ void tearDown() {
+ Thread.currentThread().setContextClassLoader(origTccl);
+ }
+
+ @Test
+ void plainTcclIsNotCoreExtensionRealm() {
+ assertFalse(BootstrapCoreExtensionManager.isContextRealmCoreExtensionRealm());
+ }
+
+ @Test
+ void coreExtensionRealmTccl() throws Exception {
+ Thread.currentThread().setContextClassLoader(world.newRealm("coreExtension>g:a:1", null));
+ assertTrue(BootstrapCoreExtensionManager.isContextRealmCoreExtensionRealm());
+ }
+
+ @Test
+ void childOfCoreExtensionRealmTccl() throws Exception {
+ Thread.currentThread()
+ .setContextClassLoader(
+ new java.net.URLClassLoader(new java.net.URL[0], world.newRealm("coreExtension>g:a:1", null)));
+ assertTrue(BootstrapCoreExtensionManager.isContextRealmCoreExtensionRealm());
+ }
Review Comment:
💡 **Suggestion:** The `childOfCoreExtensionRealmTccl` test covers a `URLClassLoader` wrapping a core extension realm, exercising the parent-chain walk via `getParent()`. Consider adding a sibling test where the TCCL is a `ClassRealm` child of the core extension realm (e.g. `world.newRealm("coreExtension>g:a:1>child", coreExtRealm)`), since the production loop checks `instanceof ClassRealm` explicitly — this would directly exercise that branch.
##########
maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycles.java:
##########
@@ -132,33 +131,19 @@ public Map<String, Lifecycle> getPhaseToLifecycleMap() {
public List<Lifecycle> getLifeCycles() {
// ensure canonical order of standard lifecycles
- Map<String, Lifecycle> lifecycles = new LinkedHashMap<>();
-
- // filter by visibility (plexus vs sisu diff; "realms" are plexus thing)
- // in some tests container is not injected
- if (this.plexusContainer != null) {
- for (String name : this.lifecycles.keySet()) {
- if (!isEnabled(name)) {
- continue;
- }
- try {
- lifecycles.put(name, plexusContainer.lookup(Lifecycle.class, name));
- } catch (ComponentLookupException e) {
- // skip it
- }
- }
- } else {
- lifecycles.putAll(this.lifecycles);
- }
+ // take "snapshot": will filter by visibility
+ Map<String, Lifecycle> lifecycles = new LinkedHashMap<>(this.lifecycles);
+ // apply enabled
+ lifecycles.entrySet().removeIf(e -> !isEnabled(e.getKey()));
LinkedHashSet<String> lifecycleNames = new LinkedHashSet<>(getStandardLifecycles());
lifecycleNames.addAll(lifecycles.keySet());
ArrayList<Lifecycle> result = new ArrayList<>();
for (String name : lifecycleNames) {
Lifecycle lifecycle = lifecycles.get(name);
- if (lifecycle.getId() == null) {
- throw new NullPointerException("A lifecycle must have an id.");
+ if (lifecycle == null || lifecycle.getId() == null) {
Review Comment:
💡 **Minor:** The `lifecycle == null` check is defensive dead code — `lifecycleNames` is built from `lifecycles.keySet()`, so a lookup is guaranteed to return non-null. A short comment like `// defensive — lifecycleNames ⊆ lifecycles.keySet()` would make the intent clear for future readers.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: JSR330 filtering fix [maven]
Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas merged PR #13582:
URL: https://github.com/apache/maven/pull/13582
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: JSR330 filtering fix [maven]
Posted by "gnodet-bot (via GitHub)" <gi...@apache.org>.
gnodet-bot commented on code in PR #13582:
URL: https://github.com/apache/maven/pull/13582#discussion_r4324948640
##########
maven-embedder/src/test/java/org/apache/maven/cli/internal/BootstrapCoreExtensionManagerTest.java:
##########
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.cli.internal;
+
+import org.codehaus.plexus.classworlds.ClassWorld;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Guards the JSR330 visibility filtering bypass: it must apply only when the TCCL is (a child of) a core extension realm.
+ */
+class BootstrapCoreExtensionManagerTest {
+ private final ClassLoader origTccl = Thread.currentThread().getContextClassLoader();
+
+ private ClassWorld world;
+
+ @BeforeEach
+ void setUp() {
+ world = new ClassWorld();
+ }
+
+ @AfterEach
+ void tearDown() {
+ Thread.currentThread().setContextClassLoader(origTccl);
+ }
+
+ @Test
+ void plainTcclIsNotCoreExtensionRealm() {
+ assertFalse(BootstrapCoreExtensionManager.isContextRealmCoreExtensionRealm());
+ }
+
+ @Test
+ void coreExtensionRealmTccl() throws Exception {
+ Thread.currentThread().setContextClassLoader(world.newRealm("coreExtension>g:a:1", null));
+ assertTrue(BootstrapCoreExtensionManager.isContextRealmCoreExtensionRealm());
+ }
+
+ /**
+ * This situation cannot happen in real life, unless Extension itself creates an "isolated" URL classloader beneath itself.
+ * Notice, how child classloader is not even a realm, but an URL classloader.
+ */
+ @Test
+ void childClassloaderOfCoreExtensionRealmTccl() throws Exception {
+ Thread.currentThread()
+ .setContextClassLoader(
+ new java.net.URLClassLoader(new java.net.URL[0], world.newRealm("coreExtension>g:a:1", null)));
+ assertTrue(BootstrapCoreExtensionManager.isContextRealmCoreExtensionRealm());
+ }
+
+ /**
+ * This situation cannot happen in real life, unless Extension itself creates an "isolated" class realm beneath itself.
+ * Notice, how realm name in this case is unrelated and do not follow the "core extension realm" naming scheme.
+ */
+ @Test
+ void childRealmWithoutNameOfCoreExtensionRealmTccl() throws Exception {
+ Thread.currentThread()
+ .setContextClassLoader(
+ world.newRealm("child", world.newRealm("coreExtension>g:a:1", null)));
+ assertTrue(BootstrapCoreExtensionManager.isContextRealmCoreExtensionRealm());
Review Comment:
⚠️ **Spotless (Palantir) formatting violation — CI blocker**
These multi-line `setContextClassLoader(...)` calls are flagged by Spotless/Palantir. Run `mvn spotless:apply -pl maven-embedder` to auto-fix all formatting violations.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: JSR330 filtering fix [maven]
Posted by "gnodet-bot (via GitHub)" <gi...@apache.org>.
gnodet-bot commented on code in PR #13582:
URL: https://github.com/apache/maven/pull/13582#discussion_r4311407490
##########
pom.xml:
##########
@@ -126,7 +126,7 @@ under the License.
<properties>
<javaVersion>8</javaVersion>
- <version.sisu-maven-plugin>1.1.0</version.sisu-maven-plugin>
+ <version.sisu-maven-plugin>1.1.1-SNAPSHOT</version.sisu-maven-plugin>
Review Comment:
⚠️ **SNAPSHOT dependency still blocks merge.** `sisu-maven-plugin 1.1.1-SNAPSHOT` is a pre-release artifact. Sisu 1.1.1 has not been released (latest on Central: 1.1.0). Please wait for the release, then update this version and remove the `central-portal-snapshots` repository/pluginRepository blocks below.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org