gnodet opened a new issue, #13707: URL: https://github.com/apache/maven/issues/13707
## Summary `ModelProcessor` is a format-agnostic orchestrator: it tries registered `ModelParser` SPIs first, then falls back to XML via `ModelXmlFactory`. However, its `read()` method takes `XmlReaderRequest` and throws `IOException, XmlReaderException`, leaking XML-specific concerns into what should be a format-neutral interface. ## Current state - `ModelProcessor.read(XmlReaderRequest)` exposes XML-only fields (`transformer`, `addDefaultEntities`, `addLocationInformation`) that `DefaultModelProcessor` ignores for SPI dispatch (it only uses `getPath()` and `isStrict()`) - Callers unpack a `ModelSource` into `XmlReaderRequest` fields that are immediately available on the `Source` itself (`getPath()`, `getLocation()`, `openStream()`, `getModelId()`) - `ModelParserException` (from SPI parsers) is wrapped in `IOException` — wrong exception hierarchy (both extend `RuntimeException` via `MavenException`) - The exception aggregation when both SPI parsers and XML fallback fail uses `IOException` as a wrapper for unrelated `ModelParserException` instances ## Proposed change Add a new format-agnostic method matching `ModelParser.parse(Source, Map)`: ```java Model read(@Nonnull Source source, @Nullable Map<String, ?> options) throws ModelParserException; ``` - Deprecate the old `read(XmlReaderRequest)` with a default implementation that delegates to the new method for backward compatibility - `DefaultModelProcessor` overrides the new method: SPI dispatch stays the same, XML fallback builds `XmlReaderRequest` internally (including `InterningTransformer` creation), `XmlReaderException` is wrapped in `ModelParserException` - Callers (`DefaultModelBuilder`, `DefaultSuperPomProvider`) pass `ModelSource` + `Map.of(ModelParser.STRICT, strict)` directly - Fix exception aggregation to use `ModelParserException` throughout ### Files affected - `api/maven-api-spi/.../model/ModelProcessor.java` — new method + deprecation - `impl/maven-impl/.../model/DefaultModelProcessor.java` — new implementation - `impl/maven-impl/.../model/DefaultModelBuilder.java` — updated caller - `impl/maven-impl/.../DefaultSuperPomProvider.java` — updated caller - `compat/maven-model-builder/.../DefaultModelProcessor.java` — compat adapter ### Context This aligns `ModelProcessor` with the existing `ModelParser` API pattern and prepares for #13613 (model dialect system) which introduces symmetric multi-format model reading/writing. _Claude Code on behalf of Guillaume Nodet_ -- 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]
