Skip to content

Commit

Permalink
[JENKINS-71851] Dependency-check 5.4.1 fails with NPE when installer …
Browse files Browse the repository at this point in the history
…is of type folder

Fix NPE when installer is of kind folder
  • Loading branch information
nfalco79 committed Aug 18, 2023
1 parent d47c1f3 commit 11ef873
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,13 @@ public void perform(@NonNull final Run<?, ?> build,

private boolean isSuccess(int exitCode) {
InstallSourceProperty installSourceProperty = getDependencyCheck().getProperties().get(InstallSourceProperty.class);
DependencyCheckInstaller ui = installSourceProperty.installers.get(DependencyCheckInstaller.class);
if (ui != null) {
Version v = Version.parse(ui.id);
if (v.feature() < 8) {
return exitCode == 0;
if (installSourceProperty != null) {
DependencyCheckInstaller ui = installSourceProperty.installers.get(DependencyCheckInstaller.class);
if (ui != null) {
Version v = Version.parse(ui.id);
if (v.feature() < 8) {
return exitCode == 0;
}
}
}
// fallback handle exitcode like version 8 or greater
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

import org.jenkinsci.plugins.DependencyCheck.tools.DependencyCheckInstallation;
Expand Down Expand Up @@ -126,7 +125,7 @@ public void test_exit_code_by_dependency_check_version() throws Exception {
}

private DependencyCheckInstallation prepareInstaller(String name, String version, boolean isAutoinstaller) throws Exception {
List<DependencyCheckInstaller> installers = Collections.emptyList();
List<DependencyCheckInstaller> installers = null;
if (isAutoinstaller) {
installers = Arrays.asList(new DependencyCheckInstaller(version));
}
Expand Down

0 comments on commit 11ef873

Please sign in to comment.