diff options
-rwxr-xr-x | config/src/main/java/com/yahoo/vespa/config/ConfigKey.java | 9 | ||||
-rw-r--r-- | config/src/test/java/com/yahoo/vespa/config/ConfigKeyTest.java | 10 |
2 files changed, 7 insertions, 12 deletions
diff --git a/config/src/main/java/com/yahoo/vespa/config/ConfigKey.java b/config/src/main/java/com/yahoo/vespa/config/ConfigKey.java index 930b74ea804..a1d069da284 100755 --- a/config/src/main/java/com/yahoo/vespa/config/ConfigKey.java +++ b/config/src/main/java/com/yahoo/vespa/config/ConfigKey.java @@ -3,7 +3,6 @@ package com.yahoo.vespa.config; import com.yahoo.config.ConfigInstance; import com.yahoo.config.ConfigurationRuntimeException; -import com.yahoo.config.codegen.CNode; import edu.umd.cs.findbugs.annotations.NonNull; import edu.umd.cs.findbugs.annotations.Nullable; @@ -48,11 +47,13 @@ public class ConfigKey<CONFIGCLASS extends ConfigInstance> implements Comparable } public ConfigKey(String name, String configIdString, String namespace, String defMd5, Class<CONFIGCLASS> clazz) { - if (name == null) - throw new ConfigurationRuntimeException("Config name must be non-null!"); + if (name == null || name.isEmpty()) + throw new ConfigurationRuntimeException("Config name cannot be null or empty!"); + if (namespace == null || namespace.isEmpty()) + throw new ConfigurationRuntimeException("Config namespace cannot be null or empty!"); this.name = name; this.configId = (configIdString == null) ? "" : configIdString; - this.namespace = (namespace == null) ? CNode.DEFAULT_NAMESPACE : namespace; + this.namespace = namespace; this.md5 = (defMd5 == null) ? "" : defMd5; this.configClass = clazz; } diff --git a/config/src/test/java/com/yahoo/vespa/config/ConfigKeyTest.java b/config/src/test/java/com/yahoo/vespa/config/ConfigKeyTest.java index 427014316cf..452d0d78897 100644 --- a/config/src/test/java/com/yahoo/vespa/config/ConfigKeyTest.java +++ b/config/src/test/java/com/yahoo/vespa/config/ConfigKeyTest.java @@ -7,10 +7,10 @@ import java.util.List; import com.yahoo.foo.AppConfig; import com.yahoo.config.ConfigurationRuntimeException; -import com.yahoo.config.codegen.CNode; import org.junit.Test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; /** * @@ -27,7 +27,6 @@ public class ConfigKeyTest { assertEquals(key1, key2); ConfigKey<?> key3 = new ConfigKey<>("foo", "a/b/c/d", namespace); - assertFalse(key1.equals(key3)); assertNotEquals(key1, key3); assertEquals("a/b/c", new ConfigKey<>("foo", "a/b/c", namespace).getConfigId()); @@ -67,15 +66,10 @@ public class ConfigKeyTest { // Tests namespace and equals with combinations of namespace. @Test public void testNamespace() { - ConfigKey<?> noNamespace = new ConfigKey<>("name", "id", null); ConfigKey<?> namespaceFoo = new ConfigKey<>("name", "id", "foo"); ConfigKey<?> namespaceBar = new ConfigKey<>("name", "id", "bar"); - assertEquals(noNamespace, noNamespace); assertEquals(namespaceFoo, namespaceFoo); - assertNotEquals(noNamespace, namespaceFoo); - assertNotEquals(namespaceFoo, noNamespace); assertNotEquals(namespaceFoo, namespaceBar); - assertEquals(noNamespace.getNamespace(), CNode.DEFAULT_NAMESPACE); assertEquals(namespaceBar.getNamespace(), "bar"); } |