summaryrefslogtreecommitdiffstats
path: root/controller-api
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2020-01-31 14:26:59 +0100
committerMartin Polden <mpolden@mpolden.no>2020-01-31 15:13:29 +0100
commitc49feda53eef265802aff4b5e8fc1c8160bdc167 (patch)
treecba4cae61f6352f7ce413cd47675c75742cd76f0 /controller-api
parent793dd0047b8e7bd41444a1bdd26a702e228e9a4c (diff)
Handle empty source revision
Diffstat (limited to 'controller-api')
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/SourceRevision.java16
1 files changed, 10 insertions, 6 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/SourceRevision.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/SourceRevision.java
index a9c1155c5ef..47538b4aaca 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/SourceRevision.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/SourceRevision.java
@@ -15,12 +15,9 @@ public class SourceRevision {
private final String commit;
public SourceRevision(String repository, String branch, String commit) {
- Objects.requireNonNull(repository, "repository cannot be null");
- Objects.requireNonNull(branch, "branch cannot be null");
- Objects.requireNonNull(commit, "commit cannot be null");
- this.repository = repository;
- this.branch = branch;
- this.commit = commit;
+ this.repository = nonBlank(repository, "repository cannot be null or empty");
+ this.branch = nonBlank(branch, "branch cannot be null or empty");
+ this.commit = nonBlank(commit, "commit cannot be null");
}
public String repository() { return repository; }
@@ -45,4 +42,11 @@ public class SourceRevision {
public String toString() { return "source revision of repository '" + repository +
"', branch '" + branch + "' with commit '" + commit + "'"; }
+
+ private static String nonBlank(String s, String message) {
+ Objects.requireNonNull(message);
+ if (s.isBlank()) throw new IllegalArgumentException(message);
+ return s;
+ }
+
}