From c47fd199f394245ed8cf3e7c97fd84c80e8a3e99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Jervidalo?= Date: Wed, 29 May 2019 17:25:37 +0200 Subject: [PATCH] fix(artifacts): Use client error code for multiple matching artifacts (#2942) Same fix as #2524, but for the case where multiple artifacts matches. Without this, Echo will try to trigger the pipeline five times and it will appear five times in the execution list. --- .../orca/pipeline/util/ArtifactResolver.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/orca-core/src/main/java/com/netflix/spinnaker/orca/pipeline/util/ArtifactResolver.java b/orca-core/src/main/java/com/netflix/spinnaker/orca/pipeline/util/ArtifactResolver.java index 4409c2ec92..b34d15bc1c 100644 --- a/orca-core/src/main/java/com/netflix/spinnaker/orca/pipeline/util/ArtifactResolver.java +++ b/orca-core/src/main/java/com/netflix/spinnaker/orca/pipeline/util/ArtifactResolver.java @@ -32,7 +32,15 @@ import com.netflix.spinnaker.orca.pipeline.persistence.ExecutionRepository; import com.netflix.spinnaker.orca.pipeline.persistence.ExecutionRepository.ExecutionCriteria; import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; import javax.annotation.Nonnull; @@ -310,7 +318,7 @@ private Artifact matchSingleArtifact( break; default: if (requireUniqueMatches) { - throw new IllegalArgumentException( + throw new InvalidRequestException( "Expected artifact " + expectedArtifact + " matches multiple artifacts " + matches); } result = matches.get(0);