summaryrefslogtreecommitdiffstats
path: root/config-model
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@oath.com>2018-11-02 14:19:11 +0100
committerGitHub <noreply@github.com>2018-11-02 14:19:11 +0100
commitd62eabd50a4c05684eca03f41eac6b20b0976950 (patch)
tree01755a81681967dc16a1134cc0fd0820f2b6888f /config-model
parent5982fb109a559f57eb8609d18360f6ded9a98760 (diff)
parente20f8c69911d4dc8ed1f9d39db175c35f1ea6abf (diff)
Merge pull request #7546 from vespa-engine/bratseth/improve-error-message
Improve error message etc
Diffstat (limited to 'config-model')
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/container/component/ConfigProducerGroup.java8
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/container/component/chain/Chain.java5
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/SearchChain.java5
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/container/search/searchchain/SearchChainsTest2.java15
4 files changed, 22 insertions, 11 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/component/ConfigProducerGroup.java b/config-model/src/main/java/com/yahoo/vespa/model/container/component/ConfigProducerGroup.java
index e8142999433..66294d3fcef 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/container/component/ConfigProducerGroup.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/container/component/ConfigProducerGroup.java
@@ -20,10 +20,10 @@ public class ConfigProducerGroup<CHILD extends AbstractConfigProducer<?>> extend
}
public void addComponent(ComponentId id, CHILD producer) {
- boolean wasAdded = producerById.put(id, producer) == null;
- if (!wasAdded) {
- throw new IllegalArgumentException("Two entities have the same component id '" +
- id + "' in the same scope.");
+ CHILD existing = producerById.put(id, producer);
+ if ( existing != null) {
+ throw new IllegalArgumentException("Both " + producer + " and " + existing + " are configured" +
+ " with the id '" + id + "'. All components must have a unique id.");
}
addChild(producer);
}
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/component/chain/Chain.java b/config-model/src/main/java/com/yahoo/vespa/model/container/component/chain/Chain.java
index f795e481f62..6b4f8c8f8b5 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/container/component/chain/Chain.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/container/component/chain/Chain.java
@@ -78,4 +78,9 @@ public class Chain<T extends ChainedComponent<?>> extends AbstractConfigProducer
return TYPE;
}
+ @Override
+ public String toString() {
+ return "chain '" + componentId + "'";
+ }
+
}
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/SearchChain.java b/config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/SearchChain.java
index 2605736e23b..ff211264a34 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/SearchChain.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/SearchChain.java
@@ -28,4 +28,9 @@ public class SearchChain extends Chain<Searcher<?>> {
return Collections.emptyList();
}
+ @Override
+ public String toString() {
+ return "search chain '" + getId() + "'";
+ }
+
}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/search/searchchain/SearchChainsTest2.java b/config-model/src/test/java/com/yahoo/vespa/model/container/search/searchchain/SearchChainsTest2.java
index 9122e855461..6ba75f1ff05 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/container/search/searchchain/SearchChainsTest2.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/container/search/searchchain/SearchChainsTest2.java
@@ -9,13 +9,11 @@ import org.junit.Before;
import org.junit.Test;
import org.w3c.dom.Element;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
-import static org.hamcrest.Matchers.containsString;
/**
* @author gjoranv
- * @since 5.1.11
*/
public class SearchChainsTest2 {
@@ -38,7 +36,8 @@ public class SearchChainsTest2 {
chains.validate();
fail("Expected exception when inheriting a nonexistent search chain.");
} catch (Exception e) {
- assertThat(e.getMessage(), containsString("Missing chain 'nonexistent'"));
+ assertEquals("Missing chain 'nonexistent'.",
+ e.getMessage());
}
}
@@ -56,12 +55,13 @@ public class SearchChainsTest2 {
ContainerModelBuilderTest.createModel(root, clusterElem);
fail("Expected exception when declaring chains with duplicate id.");
} catch (Exception e) {
- assertThat(e.getMessage(), containsString("Two entities have the same component id 'same'"));
+ assertEquals("Both search chain 'same' and search chain 'same' are configured with the id 'same'. All components must have a unique id.",
+ e.getMessage());
}
}
@Test
- public void fail_upon_user_declared_chain_with_same_id_as_builtin_chain() throws Exception {
+ public void fail_upon_user_declared_chain_with_same_id_as_builtin_chain() {
final Element clusterElem = DomBuilderTest.parse(
"<jdisc id='cluster1' version='1.0'>",
ContainerModelBuilderTest.nodesXml,
@@ -73,7 +73,8 @@ public class SearchChainsTest2 {
ContainerModelBuilderTest.createModel(root, clusterElem);
fail("Expected exception when taking the id from a builtin chain.");
} catch (Exception e) {
- assertThat(e.getMessage(), containsString("Two entities have the same component id 'vespa'"));
+ assertEquals("Both search chain 'vespa' and search chain 'vespa' are configured with the id 'vespa'. All components must have a unique id.",
+ e.getMessage());
}
}
}