gnodet-bot commented on code in PR #13118:
URL: https://github.com/apache/maven/pull/13118#discussion_r4012738331
##########
impl/maven-impl/src/main/java/org/apache/maven/impl/DefaultSettingsBuilder.java:
##########
@@ -245,6 +245,30 @@ private Server serverAlias(Server server, String id) {
return Server.newBuilder(server,
true).id(id).aliases(List.of()).build();
}
+ @Nullable
+ private SettingsParser selectParser(Source source,
ProblemCollector<BuilderProblem> problems) {
+ List<Map.Entry<String, SettingsParser>> matches =
settingsParsers.entrySet().stream()
+ .filter(entry -> entry.getValue().supports(source))
Review Comment:
💡 **`supports()` RuntimeException leaks as a raw stack trace**
If a custom `SettingsParser.supports()` throws a `RuntimeException` (e.g. an
NPE from accessing `source.getLocation()` before the source is ready), it
propagates unchecked out of `selectParser`, exits `readSettings` through
neither the `SettingsParserException` nor `IOException` branches, and surfaces
to the caller as a raw exception — not a structured FATAL problem.
For a user with a buggy extension, this means a raw stack trace instead of a
Maven diagnostic message. `ModelParser` has the same gap, so this is consistent
with the existing SPI contract, but since `SettingsParser.supports()` is being
introduced fresh, it's worth documenting or guarding:
```suggestion
.filter(entry -> {
try {
return entry.getValue().supports(source);
} catch (RuntimeException e) {
problems.reportProblem(new DefaultBuilderProblem(
source.getLocation(), -1, -1, e,
"Settings parser '" + entry.getKey() + "'
failed during supports() check: " + e.getMessage(),
BuilderProblem.Severity.FATAL));
return false;
}
})
```
Alternatively, document explicitly in `SettingsParser.supports()` Javadoc
that the method must not throw — as-is, the contract is silent on this.
--
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]