Repository navigation
Conversation
992accf to
1edef52
Compare
gnodet
left a comment
There was a problem hiding this comment.
Well-structured port of the model-problem retention feature from Maven 3 to Maven 4 with thorough test coverage, proper backward compatibility, and correct thread-safe design. Two minor observations:
-
@sinceversion tag: The@since 3.10.0tag onhasModelProblems()andsetModelProblems()inMavenSession.javais inconsistent with the existing@since 4.0.0convention used elsewhere in the file. The3.10.0was carried over from PR #298 (which targetsmaven-3.10.x), but since this is the Maven 4 codebase, using@since 4.0.0(or whatever the target Maven 4 release version is) would be more consistent. -
Duplicate simple class name: Two new classes named
SessionModelProblemsare introduced — one package-private inorg.apache.maven.api(API module) and one public inorg.apache.maven.internal.impl(core module). This would be the first instance in the codebase of the same simple name appearing in bothapiandinternal.implpackages. A distinct name for the impl class (e.g.,LegacySessionModelProblemsorSessionModelProblemsBridge) would reduce potential confusion for future maintainers.
Neither finding is blocking — the overall design is sound: thread safety via ProblemCollector's concurrent data structures, correct enum mapping, binary compatibility via default methods, proper problem propagation through multi-module collection, and thorough test coverage across unit and integration tests.
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of gnodet
|
The |
gnodet
left a comment
There was a problem hiding this comment.
Thanks for the quick follow-up! The rename commit cleanly resolved the duplicate class name concern — the impl class is now SessionModelProblemsBridge, and all references in MavenSession.java, DefaultSession.java, and the class file itself are updated with no stale references.
Regarding @since 3.10.0: your reasoning is sound — the tags are only on MavenSession (the 3.x legacy class), not on the Maven 4 API Session.java, so tagging with the 3.x version they first appear in is defensible.
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of gnodet
gnodet
left a comment
There was a problem hiding this comment.
Well-structured port of model-problem retention from Maven 3 to Maven 4. The design is solid:
- Thread-safe:
AtomicBooleanfor the legacy bridge flag, proper session-data scoping - Backward compatible: Default methods on
Sessioninterface, bidirectionalMavenSession↔Sessionpropagation - Smart buffering:
MultiModuleCollectionStrategycorrectly buffers speculative problems before forwarding, preventing unrelated problems from leaking into the session - Well-tested: Thorough coverage across unit and integration tests; 1,049 Core ITs with zero failures
The deriveWithProblemCollector approach in DefaultModelBuilder is a clean solution for sharing the collector with parent/BOM sub-builds.
Two minor observations (non-blocking):
- The
valueOf(problem.getSeverity().name())pattern inDefaultGraphBuilder.toApiModelProblem()assumes enum constants stay in sync between legacy and API enums — safe today but worth a comment noting the coupling. Session.hasModelProblems()default method only checks the collector, whileDefaultSessionalso checks the legacy bridge flag. StandaloneSessionimplementations would miss problems set via the legacyMavenSession.setModelProblems(true)path — acceptable since standalone impls wouldn't have aMavenSessioncounterpart.
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of Guillaume Nodet
gnodet
left a comment
There was a problem hiding this comment.
LGTM — Well-structured port of model-problem retention from Maven 3 (PR #298) to Maven 4. The design is sound: default methods on Session for binary compatibility, SessionData-backed storage for derived-session sharing, correct problem buffering in MultiModuleCollectionStrategy, and thorough test coverage.
Minor observations (non-blocking):
-
Enum coupling (
DefaultGraphBuilder.java): ThevalueOf(problem.getSeverity().name())conversion creates a coupling between legacy and API enums. This follows the existing pattern inDefaultProjectBuilder.java:182, so it's consistent, but a comment noting the coupling would help future maintainers. -
Interface extensibility (
ProjectCollectionStrategy): The newcollectProjects(request, problemConsumer)overloads were added to concrete classes but not the interface. This is harmless sinceDefaultGraphBuilderuses concrete types directly, but contrasts withProjectsSelectorwhich did get the new default method.
📋 PR Metadata
| Aspect | Current | Suggested |
|---|---|---|
| Labels | (none) | enhancement |
| Milestone | (none) | 4.1.0 |
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of Guillaume Nodet
567a1a6 to
ac53c40
Compare
|
Rebased onto master and force-pushed to this branch, since it had fallen 59 commits behind and was blocking on conflicts. Only
Nothing in the 827-line change was reinterpreted. Verified: @wilx your local branch now differs from the remote. This comment was created with AI assistance. |
gnodet
left a comment
There was a problem hiding this comment.
Re-review after rebase. Clean rebase onto master after 59-commit drift — no substantive code changes from the previously approved content. Only DefaultModelBuilderTest.java conflicted, and the resolution was purely additive (both sides' new tests kept). Verified correct.
📋 PR Metadata
| Aspect | Current | Suggested |
|---|---|---|
| Milestone | (none) | 4.1.0 |
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of Guillaume Nodet
👍 |
ac53c40 to
2361313
Compare
2361313 to
31dae90
Compare
gnodet-bot
left a comment
There was a problem hiding this comment.
Re-review after rebase (31dae90). The core design is sound — SessionData-backed storage, shared across derived sessions, correct deriveWithProblemCollector call sites in DefaultModelBuilder, and good test coverage including the IT. Two findings.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
| default List<MavenProject> selectProjects( | ||
| List<File> files, MavenExecutionRequest request, Consumer<ModelProblem> problemConsumer) | ||
| throws ProjectBuildingException { | ||
| return selectProjects(files, request); |
There was a problem hiding this comment.
ProjectsSelector implementations.
The default body calls selectProjects(files, request) — the old 2-arg overload — which discards problemConsumer entirely. Any ProjectsSelector implementation that extends the interface but does not override the new 3-arg method will silently swallow all model problems rather than routing them to the session collector.
The Javadoc on this method says "report model problems encountered while building them", which the default implementation does not do. That's a misleading contract.
In practice, Maven's own impls (DefaultProjectsSelector) all override the method, so the issue is latent today. But the interface is an SPI: embedders and plugins that provide custom ProjectsSelector implementations won't get problems retained without overriding the new method — and they'll get no warning that they're silently discarding them.
Consider adding a @apiNote Javadoc warning:
| return selectProjects(files, request); | |
| // NOTE: Implementations that override only the 2-arg selectProjects() will silently | |
| // discard problemConsumer. Override this method to route problems to the caller. | |
| return selectProjects(files, request); |
Or, if the concern is real enough, mark the old 2-arg method @Deprecated to force implementors to the new overload.
|
📝 Stale PR description — the last commit (
That code is gone. The description should be updated to reflect the current design (native This comment was generated by an AI agent, Hermès on behalf of @gnodet. |
gnodet-bot
left a comment
There was a problem hiding this comment.
Re-review after rebase (561733d). Single new commit — "Document ProjectsSelector model problem reporting fallback" — directly addresses the previously raised finding.
The Javadoc on ProjectsSelector.selectProjects(List, MavenExecutionRequest, Consumer) now explicitly states:
"The default implementation delegates to
selectProjects(List, MavenExecutionRequest)for compatibility with existing implementations and does not invokeproblemConsumer. Implementations must override this method to report model problems to the consumer."
That resolves the misleading contract concern: the silent-drop behavior is now documented, and implementors overriding only the 2-arg method will see from the Javadoc that they need to override the 3-arg overload to opt into problem reporting.
Everything else was approved on SHA 31dae90. LGTM.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
gnodet
left a comment
There was a problem hiding this comment.
The default implementation on Session.getModelProblemCollector() forces SessionModelProblems into the org.apache.maven.api package, which is wrong — it's an implementation detail (a SessionData key holder) with no business being in the API module.
Suggested change: make the method abstract, remove the default, and delete SessionModelProblems.java from maven-api-core.
// Session.java
@Nonnull
ProblemCollector<ModelProblem> getModelProblemCollector();The implementation belongs in DefaultSession in impl/maven-core, where it can freely use SessionData to lazily allocate the collector. Existing Session implementations that don't override it will get a compile error, but since this is a new method in 4.1.0, that's expected — and they can trivially return ProblemCollector.empty() as a stub.
The default+helper-in-API-package pattern is only justified when the default behavior needs to be non-trivial and cannot live in impl. Here it doesn't apply: the default is just lazy SessionData allocation, which is precisely what DefaultSession should do explicitly.
|
@gnodet I have pushed a change to implement your design suggestion. |
gnodet-bot
left a comment
There was a problem hiding this comment.
Re-review after "Move model problem collector storage out of the API" (6fbc2a4).
The final commit directly addresses @gnodet's CHANGES_REQUESTED: getModelProblemCollector() is now abstract in Session.java, and the ModelProblems record + MODEL_PROBLEMS key moved out of maven-api-core into DefaultSession and ApiRunner.DefaultSession. The API module no longer holds implementation details. That design concern is fully resolved.
Two findings remain.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
gnodet-bot
left a comment
There was a problem hiding this comment.
Re-review after "Retain a writable model problem collector in SessionStub" (212e353).
The new commit directly addresses the third finding from the prior review: SessionStub.getModelProblemCollector() now returns ProblemCollector.create(100) — a real per-instance collector — instead of ProblemCollector.empty() which threw IllegalStateException on any reportProblem() call. The fix is correct:
- Each
SessionStubinstance gets its own isolated collector, matchingDefaultSessionandApiRunner.DefaultSessionsemantics. - The hardcoded limit of 100 matches the production default when
MAVEN_BUILDER_MAX_PROBLEMSis unset — acceptable for a test stub wheregetData()returns null and the session-property lookup path is unavailable. SessionStubTestcovers retention across accesses (assertSameon the collector reference) and isolation between instances (assertNotSame), which are exactly the two properties that matter.
Regarding the prior finding about a missing super(versionRange) constructor in MavenITRememberModelProblemsTest: that was a false positive. On this branch, AbstractMavenIntegrationTestCase has a no-arg constructor at line 44 — the bot was inspecting the master version of that file, which only has parameterized constructors. The test class is valid.
All three findings from the previous review are now resolved. The overall design is sound: abstract getModelProblemCollector() on Session, SessionData-backed lazy allocation in DefaultSession and ApiRunner.DefaultSession, correct buffering of speculative problems in MultiModuleCollectionStrategy, and comprehensive coverage across unit and integration tests.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
|
@gnodet I think I did all of the requested changes. Or am I missing some? |
gnodet-bot
left a comment
There was a problem hiding this comment.
Re-review (explicit request). The design is solid and all previous concerns have been addressed.
Interaction with #12702: After this merges, DefaultProjectsSelector in #12702 will conflict and should be simplified — instead of injecting DefaultDiagnosticCollector into the constructor and looping manually, it should use the Consumer<ModelProblem> overload introduced here, passing p -> diagnosticCollector.report(toBuilderProblem(p)). The DefaultGraphBuilderTest will also need a manual conflict resolution.
Backport to 4.0.x: Not recommended. While Session is @Experimental on 4.0.x (no API compat concern), the DefaultModelBuilder.deriveWithProblemCollector() method added here depends on internal structure that diverged significantly from 4.0.x after the [MNG-6563] iterative parent traversal refactor (which is not in 4.0.x). A straight cherry-pick would not apply cleanly and adapting it carries regression risk in parent/BOM problem collector sharing. The gap in 4.0.x is acceptable given it is approaching end-of-life.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
Retain reactor-discovery model problems in the Maven 4 session and expose the state through both the native and legacy session APIs. Preserve collection-strategy compatibility and ignore problems from discarded discovery attempts. Fixes apache#8485.
Explain that the default overload preserves existing implementations without invoking the problem consumer, and that implementations must override it to report model problems.
Make Session.getModelProblemCollector abstract and keep lazy SessionData-backed storage in the Core and standalone session implementations. Remove the API key holder and provide an empty collector in SessionStub. Cover standalone sharing and overflow, and isolation between independent sessions. Validated with clean reactor verify and the selected model-problem and parent-version-range Core ITs.
Allocate one collector per stub instance so reporting succeeds and repeated access preserves problem details and counters. Keep independent stub instances isolated. Add regression tests for reporting, repeated access, and instance isolation. All 27 maven-testing tests and the targeted reactor verify passed.
212e353 to
0f52332
Compare
This ports the model-problem retention feature from Maven 3 PR #298 to Maven 4.
Maven 4 retains the model problems reported while discovering the reactor. The
native
Session.getModelProblemCollector()exposes aProblemCollectorwith problemdetails, severity counts, and overflow information.
Its default implementationuses
SessionData, so sessions sharing that data, including derived sessions,share a writable collector without depending on Maven Core's
DefaultSession.Session.getModelProblemCollector()is now abstract. Core'sDefaultSessionand the standalone
ApiRunner.DefaultSessioneach explicitly allocate awritable collector lazily through
SessionData. Sessions sharing that datawithin either implementation, including derived sessions, share the collector
and preserve its configured limits, counts, and overflow information. The
SessionModelProblemshelper has been removed from the API module.No model-problem accessors or bridge are added to the legacy
MavenSessionAPI.Problems encountered while constructing an external parent or imported BOM are
part of the owning project's model result. Derived model-builder requests
share that result's collector, preserving its limits, counts, and causes
rather than copying problems afterward.
Project-collection problems are retained from the selected discovery result
before
-pland related project trimming, matching Maven 3 behavior. Problemsfrom a speculative multi-module collection attempt are buffered until that
attempt is selected; if Maven falls back to the explicitly requested POM,
those unrelated problems are discarded. Later, unrelated model-building
operations remain outside the session collector's scope.
Binary compatibility is preserved by adding default methods to the native
SessionandProjectsSelectorinterfaces and retaining existing projectcollection entry points.
The new Maven 4.1.0
Session.getModelProblemCollector()method is abstract,so existing
Sessionimplementations must implement it; adding this methoddoes not preserve binary compatibility for callers invoking it on older
implementations.
Basic stubs can return
ProblemCollector.empty(), asSessionStubnow does.SessionStubnow retains a writableProblemCollector.create(100)per instance.Repeated calls return the same collector, preserving counts and retained problems;
separate stub instances remain isolated.
The
ProjectsSelectordefault overload and existing project-collection entrypoints are retained for compatibility.
The new
ProjectsSelectoroverload delegates to theoriginal two-argument method by default and does not invoke the problem
consumer. Custom implementations must override the new overload to report
model problems; Maven's
DefaultProjectsSelectordoes so.Fixes #8485.
Verification
SessionStubfix in212e353abe, using JDK 21 and Maven 3.9.16:maven-testingreactorverifypassed: 27 tests, with 0 failures,0 errors, and 0 skipped.
stub instances.
LatestEarlier validation of the changes committed as6fbc2a4fc9, using JDK 21 and Maven 3.9.16:clean verifywith-Prun-itsand-Dits.test=MavenITRememberModelProblemsTest,MavenITmng2199ParentVersionRangeTest.16 skipped, including collector sharing, isolation, and overflow coverage.
no
SessionModelProblemshelper.LatestEarlier post-rebase validation on31dae90c23, using JDK 21:traversal, project building, graph collection, and session storage.
MavenITRememberModelProblemsTestandMavenITmng2199ParentVersionRangeTest.verifybuild passed with those test selections.mvn -e -B -V -Prun-its clean installpassed all 90 reactor modules.Following this checklist to help us incorporate your
contribution quickly and easily:
Note that commits might be squashed by a maintainer on merge.
This may not always be possible but is a best-practice.
mvn verifyto make sure basic checks pass.A more thorough check will be performed on your pull request automatically.
If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.