Skip to content

Commit

Permalink
If passed parameter is null, return the empty optional
Browse files Browse the repository at this point in the history
As per P2Resolver API it is allowed to pass a null reactor project, even
though this is some rare case we probably better avoid it should not
lead to a Nullpointer exception.
  • Loading branch information
laeubi committed Nov 20, 2022
1 parent 4ee2dcf commit 60d5cd3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,16 @@ public class TychoProjectManager {
Map<String, TychoProject> projectTypes;

public Optional<TychoProject> getTychoProject(MavenProject project) {
if (project == null) {
return Optional.empty();
}
return Optional.ofNullable(projectTypes.get(project.getPackaging()));
}

public Optional<TychoProject> getTychoProject(ReactorProject project) {
if (project == null) {
return Optional.empty();
}
return Optional.ofNullable(projectTypes.get(project.getPackaging()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ protected P2ResolutionResult resolveDependencies(Collection<IInstallableUnit> ro
strategy.setData(data);
Collection<IInstallableUnit> newState;
try {
if (pomDependencies != PomDependencies.ignore || !TychoConstants.USE_OLD_RESOLVER) {
if ((pomDependencies != PomDependencies.ignore || !TychoConstants.USE_OLD_RESOLVER) && project != null) {
data.setAdditionalUnitStore(p2ResolverFactoryImpl.getPomUnits().createPomQueryable(project));
}
newState = strategy.resolve(environment, monitor);
Expand Down

0 comments on commit 60d5cd3

Please sign in to comment.