Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(clouddriver): NPE applying empty artifact manifest #5645

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.CollectionUtils;

public class KubernetesDeployManifestOperation implements AtomicOperation<OperationResult> {
private static final Logger log =
Expand Down Expand Up @@ -167,18 +168,21 @@ public OperationResult operate(List<OperationResult> _unused) {
@NotNull
private List<KubernetesManifest> getManifestsFromDescription() {
List<KubernetesManifest> inputManifests = description.getManifests();
if (inputManifests == null || inputManifests.isEmpty()) {
// The stage currently only supports using the `manifests` field but we need to continue to
// check `manifest` for backwards compatibility until all existing stages have been updated.
@SuppressWarnings("deprecation")
KubernetesManifest manifest = description.getManifest();

// The stage currently only supports using the `manifests` field but we need to continue to
// check `manifest` for backwards compatibility until all existing stages have been updated.
@SuppressWarnings("deprecation")
KubernetesManifest manifest = description.getManifest();

if (CollectionUtils.isEmpty(inputManifests) && manifest != null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If both description.getManifests() and description.getManifest() return null, there will be a new NullPointerException in line 186, so we need to make sure that inputManifests is never null.

log.warn(
"Relying on deprecated single manifest input (account: {}, kind: {}, name: {})",
accountName,
manifest.getKind(),
manifest.getName());
inputManifests = ImmutableList.of(manifest);
}

inputManifests = inputManifests.stream().filter(Objects::nonNull).collect(Collectors.toList());
return inputManifests;
}
Expand Down