diff options
author | Jon Marius Venstad <jonmv@users.noreply.github.com> | 2020-05-28 22:53:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-28 22:53:40 +0200 |
commit | df731e25b35496ab4aada70d4c15bd6f704ea74b (patch) | |
tree | 17b51f2caaeaf54041373b8b14926400e996614b /config-model-api/src/main/java/com/yahoo/config/application/api/xml/DeploymentSpecXmlReader.java | |
parent | 392706b822d0517f933cf58fca0277b192272bc5 (diff) | |
parent | 57d19fab47444292cb4d9a87d5f8a3c4b4da5dee (diff) |
Merge pull request #13420 from vespa-engine/jonmv/empty-instances-are-nothing
Avoid creating empty instance specs
Diffstat (limited to 'config-model-api/src/main/java/com/yahoo/config/application/api/xml/DeploymentSpecXmlReader.java')
-rw-r--r-- | config-model-api/src/main/java/com/yahoo/config/application/api/xml/DeploymentSpecXmlReader.java | 11 |
1 files changed, 11 insertions, 0 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 68f27a21ce4..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,6 +137,13 @@ public class DeploymentSpecXmlReader { Element instanceTag, MutableOptional<String> globalServiceId, Element parentTag) { + 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) validateTagOrder(instanceTag); |