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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]