elharo opened a new issue, #166:
URL: https://github.com/apache/maven-resolver-ant-tasks/issues/166
## Summary
`AntRepoSys.getRemoteRepositories()` throws a `NullPointerException` when
`settings.xml` declares an `activeProfile` that is not defined by a `<profile>`
in the settings file.
## Affected code
`src/main/java/org/apache/maven/resolver/internal/ant/AntRepoSys.java` lines
487-491 (master @ `df2908e`)
```java
List<String> activeProfiles = settings.getActiveProfiles();
for (String profileId : activeProfiles) {
Profile profile = settings.getProfilesAsMap().get(profileId);
for (Repository repository : profile.getRepositories()) {
```
## Problem
Maven's `DefaultSettingsBuilder` retains entries in
`effectiveSettings.getActiveProfiles()` even when no matching `<profile>`
exists in `settings.xml` (it does not validate or remove them).
`settings.getProfilesAsMap().get(profileId)` therefore returns `null` for such
ids, and the subsequent `profile.getRepositories()` call throws an NPE.
Pointing an `<activeProfile>` at a profile defined in a POM (rather than in
settings.xml) is legitimate Maven usage and triggers this crash.
## Expected behavior
Missing profiles in `activeProfiles` should be skipped (or a meaningful
error message logged), never crash. Example settings.xml that reproduces it:
```xml
<settings>
<profiles>
<profile>
<id>defined</id>
<repositories>...</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>defined</activeProfile>
<activeProfile>not-defined-anywhere</activeProfile>
</activeProfiles>
</settings>
```
## Impact
Any build whose settings.xml lists a POM-only (or otherwise unknown) active
profile fails with a confusing NPE.
--
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]