Skip to content

Commit

Permalink
Prevent NPE on older LSTs not yet containing ResolvedPom.subprojects (#…
Browse files Browse the repository at this point in the history
…4630)

* Prevent NPE on older LSTs not yet containing ResolvedPom.subprojects

* Pom.subprojects might also not have been serialized before
  • Loading branch information
timtebeek authored Oct 30, 2024
1 parent d030c63 commit 7d70216
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ private boolean isSubprojectOfParentInRepository(Scanned acc) {

private boolean isAggregatorNotUsedAsParent() {
List<String> subprojects = getResolutionResult().getPom().getSubprojects();
if (subprojects.isEmpty()) {
if (subprojects == null || subprojects.isEmpty()) {
return false;
}
List<MavenResolutionResult> modules = getResolutionResult().getModules();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public boolean parentPomIsProjectPom() {
}

public boolean isMultiModulePom() {
return !getPom().getSubprojects().isEmpty();
return getPom().getSubprojects() == null || !getPom().getSubprojects().isEmpty();
}

private Map<Path, Pom> getProjectPomsRecursive(Map<Path, Pom> projectPoms) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public static int getModelVersion() {
List<Plugin> pluginManagement = emptyList();

@Builder.Default
@Nullable
List<String> subprojects = emptyList();

public String getGroupId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ public ResolvedPom(Pom requested, Iterable<String> activeProfiles) {

@NonFinal
@Builder.Default
@Nullable // on older LSTs, this field is not yet present
List<String> subprojects = emptyList();


/**
* Deduplicate dependencies and dependency management dependencies
*
Expand Down

0 comments on commit 7d70216

Please sign in to comment.