diff options
author | Jon Marius Venstad <venstad@gmail.com> | 2020-05-28 21:05:55 +0200 |
---|---|---|
committer | Jon Marius Venstad <venstad@gmail.com> | 2020-05-28 21:05:55 +0200 |
commit | 57d19fab47444292cb4d9a87d5f8a3c4b4da5dee (patch) | |
tree | 2fea8eed09a465192f9519066c35c98cf2523416 /config-model-api/src/main/java/com/yahoo | |
parent | 482ad2d6f959149531a8dd9ecef5b540f14b430d (diff) |
Fix check for whether instance is empty
Diffstat (limited to 'config-model-api/src/main/java/com/yahoo')
-rw-r--r-- | config-model-api/src/main/java/com/yahoo/config/application/api/xml/DeploymentSpecXmlReader.java | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/config-model-api/src/main/java/com/yahoo/config/application/api/xml/DeploymentSpecXmlReader.java b/config-model-api/src/main/java/com/yahoo/config/application/api/xml/DeploymentSpecXmlReader.java index 6519a6f50af..48a675fa182 100644 --- a/config-model-api/src/main/java/com/yahoo/config/application/api/xml/DeploymentSpecXmlReader.java +++ b/config-model-api/src/main/java/com/yahoo/config/application/api/xml/DeploymentSpecXmlReader.java @@ -45,6 +45,7 @@ import java.util.stream.Stream; */ public class DeploymentSpecXmlReader { + private static final String deploymentTag = "deployment"; private static final String instanceTag = "instance"; private static final String majorVersionTag = "major-version"; private static final String testTag = "test"; @@ -93,6 +94,9 @@ public class DeploymentSpecXmlReader { /** Reads a deployment spec from XML */ public DeploymentSpec read(String xmlForm) { Element root = XML.getDocument(xmlForm).getDocumentElement(); + if ( ! root.getTagName().equals(deploymentTag)) + throw new IllegalArgumentException("The root tag must be <deployment>"); + if (isEmptySpec(root)) return DeploymentSpec.empty; @@ -133,7 +137,11 @@ public class DeploymentSpecXmlReader { Element instanceTag, MutableOptional<String> globalServiceId, Element parentTag) { - if (isEmptySpec(instanceTag)) + if (instanceNameString.isBlank()) + throw new IllegalArgumentException("<instance> attribute 'id' must be specified, and not be blank"); + + // If this is an absolutely empty instance, or the implicit "default" instance but without content, ignore it + if (XML.getChildren(instanceTag).isEmpty() && (instanceTag.getAttributes().getLength() == 0 || instanceTag == parentTag)) return List.of(); if (validate) |