diff options
15 files changed, 61 insertions, 56 deletions
diff --git a/config-lib/abi-spec.json b/config-lib/abi-spec.json index 2cc1cb2b67b..6cfce9da0ba 100644 --- a/config-lib/abi-spec.json +++ b/config-lib/abi-spec.json @@ -251,9 +251,10 @@ "public abstract java.lang.String getValue()", "protected final boolean setValue(java.lang.String)", "protected abstract boolean doSetValue(java.lang.String)", - "protected java.lang.Object clone()", + "protected com.yahoo.config.LeafNode clone()", "public boolean equals(java.lang.Object)", - "public int hashCode()" + "public int hashCode()", + "protected bridge synthetic java.lang.Object clone()" ], "fields" : [ "protected boolean initialized", diff --git a/config-lib/src/main/java/com/yahoo/config/ConfigurationRuntimeException.java b/config-lib/src/main/java/com/yahoo/config/ConfigurationRuntimeException.java index cd5576db9f0..ed757c6dea9 100644 --- a/config-lib/src/main/java/com/yahoo/config/ConfigurationRuntimeException.java +++ b/config-lib/src/main/java/com/yahoo/config/ConfigurationRuntimeException.java @@ -4,8 +4,8 @@ package com.yahoo.config; /** * This exception is thrown on internal errors in the configuration system. */ -@SuppressWarnings("serial") public class ConfigurationRuntimeException extends RuntimeException { + public ConfigurationRuntimeException(String message) { super(message); } diff --git a/config-lib/src/main/java/com/yahoo/config/LeafNode.java b/config-lib/src/main/java/com/yahoo/config/LeafNode.java index 8aa97cef4ee..0463631e4f6 100644 --- a/config-lib/src/main/java/com/yahoo/config/LeafNode.java +++ b/config-lib/src/main/java/com/yahoo/config/LeafNode.java @@ -4,7 +4,7 @@ package com.yahoo.config; /** * Superclass for all leaf nodes in a {@link ConfigInstance}. * <p> - * Subclasses represents leaf nodes with different types. These + * Subclasses represent leaf nodes with different types. These * implementations should implement method value() with return-value * corresponding to the actual type. * @@ -73,9 +73,9 @@ public abstract class LeafNode<T> extends Node implements Cloneable { * @return a new instance similar to this object. */ @Override - protected Object clone() { + protected LeafNode<?> clone() { try { - return super.clone(); + return (LeafNode<?>) super.clone(); } catch (CloneNotSupportedException e) { throw new ConfigurationRuntimeException(e); } @@ -83,10 +83,8 @@ public abstract class LeafNode<T> extends Node implements Cloneable { @Override public boolean equals(Object o) { - if (! (o instanceof LeafNode)) - return false; + if (! (o instanceof LeafNode<?> other)) return false; - LeafNode<?> other = (LeafNode)o; return value == null ? other.value == null : value().equals(other.value); } @@ -102,4 +100,5 @@ public abstract class LeafNode<T> extends Node implements Cloneable { void serialize(Serializer serializer) { serializer.serialize(getValue()); } + } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java b/config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java index 2d40f493e54..a13eebf0042 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java @@ -520,7 +520,8 @@ public final class VespaModel extends AbstractConfigProducerRoot implements Mode throw new ConfigurationRuntimeException(e); } if (!(i instanceof ConfigInstance.Builder)) { - throw new ConfigurationRuntimeException(fullClassName + " is not a ConfigInstance.Builder, can not produce config for the name '" + key.getName() + "'."); + throw new ConfigurationRuntimeException(fullClassName + " is not a ConfigInstance.Builder, " + + "can not produce config for the name '" + key.getName() + "'."); } return (ConfigInstance.Builder) i; } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/DomConfigPayloadBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/DomConfigPayloadBuilder.java index ee1771cfbfc..5d17619b526 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/DomConfigPayloadBuilder.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/DomConfigPayloadBuilder.java @@ -54,19 +54,19 @@ public class DomConfigPayloadBuilder { public static ConfigDefinitionKey parseConfigName(Element configE) { if (!configE.getNodeName().equals("config")) { - throw new ConfigurationRuntimeException("The root element must be 'config', but was '" + configE.getNodeName() + "'"); + throw new IllegalArgumentException("The root element must be 'config', but was '" + configE.getNodeName() + "'"); } if (!configE.hasAttribute("name")) { - throw new ConfigurationRuntimeException + throw new IllegalArgumentException ("The 'config' element must have a 'name' attribute that matches the name of the config definition"); } String elementString = configE.getAttribute("name"); if (!elementString.contains(".")) { - throw new ConfigurationRuntimeException("The config name '" + elementString + - "' contains illegal characters. Only names with the pattern " + - namespacePattern.pattern() + "." + namePattern.pattern() + " are legal."); + throw new IllegalArgumentException("The config name '" + elementString + + "' contains illegal characters. Only names with the pattern " + + namespacePattern.pattern() + "." + namePattern.pattern() + " are legal."); } Tuple2<String, String> t = ConfigUtils.getNameAndNamespaceFromString(elementString); @@ -74,15 +74,15 @@ public class DomConfigPayloadBuilder { String xmlNamespace = t.second; if (!validName(xmlName)) { - throw new ConfigurationRuntimeException("The config name '" + xmlName + - "' contains illegal characters. Only names with the pattern " + - namePattern.toString() + " are legal."); + throw new IllegalArgumentException("The config name '" + xmlName + + "' contains illegal characters. Only names with the pattern " + + namePattern.toString() + " are legal."); } if (!validNamespace(xmlNamespace)) { - throw new ConfigurationRuntimeException("The config namespace '" + xmlNamespace + - "' contains illegal characters. Only namespaces with the pattern " + - namespacePattern.toString() + " are legal."); + throw new IllegalArgumentException("The config namespace '" + xmlNamespace + + "' contains illegal characters. Only namespaces with the pattern " + + namespacePattern.toString() + " are legal."); } return new ConfigDefinitionKey(xmlName, xmlNamespace); } @@ -123,12 +123,12 @@ public class DomConfigPayloadBuilder { String name = extractName(element); String value = XML.getValue(element); if (value == null) { - throw new ConfigurationRuntimeException("Element '" + name + "' must have either children or a value"); + throw new IllegalArgumentException("Element '" + name + "' must have either children or a value"); } if ("item".equals(name)) { if (parentName == null) - throw new ConfigurationRuntimeException("<item> is a reserved keyword for array and map elements"); + throw new IllegalArgumentException("<item> is a reserved keyword for array and map elements"); if (element.hasAttribute("key")) { payloadBuilder.getMap(parentName).put(element.getAttribute("key"), value); } else { @@ -190,7 +190,7 @@ public class DomConfigPayloadBuilder { parseElement(child, payloadBuilder, name); } } else { - throw new ConfigurationRuntimeException("<item> is a reserved keyword for array and map elements"); + throw new IllegalArgumentException("<item> is a reserved keyword for array and map elements"); } } } @@ -209,8 +209,8 @@ public class DomConfigPayloadBuilder { parseComplex(currElem, children, payloadBuilder, parentName); } } catch (Exception exception) { - throw new ConfigurationRuntimeException("Error parsing element at " + XML.getNodePath(currElem, " > ") + - ": " + Exceptions.toMessageString(exception)); + throw new IllegalArgumentException("Error parsing element at " + XML.getNodePath(currElem, " > ") + + ": " + Exceptions.toMessageString(exception)); } } diff --git a/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/DomConfigPayloadBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/DomConfigPayloadBuilderTest.java index e788fe5fc54..e9e52ba78cd 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/DomConfigPayloadBuilderTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/DomConfigPayloadBuilderTest.java @@ -129,7 +129,7 @@ public class DomConfigPayloadBuilderTest { try { new DomConfigPayloadBuilder(null).build(configRoot); fail("Expected exception for wrong tag name."); - } catch (ConfigurationRuntimeException e) { + } catch (IllegalArgumentException e) { assertEquals("The root element must be 'config', but was 'configs'", e.getMessage()); } } @@ -141,7 +141,7 @@ public class DomConfigPayloadBuilderTest { try { new DomConfigPayloadBuilder(null).build(configRoot); fail("Expected exception for mismatch between def-name and xml name attribute."); - } catch (ConfigurationRuntimeException e) { + } catch (IllegalArgumentException e) { assertEquals("The 'config' element must have a 'name' attribute that matches the name of the config definition", e.getMessage()); } } @@ -158,7 +158,7 @@ public class DomConfigPayloadBuilderTest { @Test void testNameParsingInvalidName() { - assertThrows(ConfigurationRuntimeException.class, () -> { + assertThrows(IllegalArgumentException.class, () -> { Element configRoot = getDocument(new StringReader("<config name=\" function-test\" version=\"1\">" + "<int_val>1</int_val> +" + "</config>")); @@ -168,7 +168,7 @@ public class DomConfigPayloadBuilderTest { @Test void testNameParsingInvalidNamespace() { - assertThrows(ConfigurationRuntimeException.class, () -> { + assertThrows(IllegalArgumentException.class, () -> { Element configRoot = getDocument(new StringReader("<config name=\"_foo.function-test\" version=\"1\">" + "<int_val>1</int_val> +" + "</config>")); @@ -221,7 +221,7 @@ public class DomConfigPayloadBuilderTest { @Test void require_that_item_is_reserved_in_root() { - assertThrows(ConfigurationRuntimeException.class, () -> { + assertThrows(IllegalArgumentException.class, () -> { Element configRoot = getDocument( "<config name=\"test.arraytypes\" version=\"1\">" + " <item>13</item>" + @@ -232,7 +232,7 @@ public class DomConfigPayloadBuilderTest { @Test void require_that_exceptions_are_issued() throws FileNotFoundException { - assertThrows(ConfigurationRuntimeException.class, () -> { + assertThrows(IllegalArgumentException.class, () -> { Element configRoot = getDocument( "<config name=\"test.simpletypes\">" + "<longval>invalid</longval>" + diff --git a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/RpcConfigSourceClient.java b/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/RpcConfigSourceClient.java index 994bdef5898..08e5c22c4e1 100644 --- a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/RpcConfigSourceClient.java +++ b/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/RpcConfigSourceClient.java @@ -153,7 +153,7 @@ class RpcConfigSourceClient implements ConfigSourceClient, Runnable { subscriber.subscribe(); subscribers.put(configCacheKey, subscriber); } catch (ConfigurationRuntimeException e) { - log.log(Level.INFO, "Subscribe for '" + configCacheKey + "' failed, closing subscriber"); + log.log(Level.INFO, "Subscribe for '" + configCacheKey + "' failed, closing subscriber", e); subscriber.cancel(); } } diff --git a/config/src/main/java/com/yahoo/config/subscription/CfgConfigPayloadBuilder.java b/config/src/main/java/com/yahoo/config/subscription/CfgConfigPayloadBuilder.java index 1a110fe8e6c..bdb0b03df05 100644 --- a/config/src/main/java/com/yahoo/config/subscription/CfgConfigPayloadBuilder.java +++ b/config/src/main/java/com/yahoo/config/subscription/CfgConfigPayloadBuilder.java @@ -19,6 +19,7 @@ import static java.util.logging.Level.FINEST; * @author hmusum */ public class CfgConfigPayloadBuilder { + private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(CfgConfigPayloadBuilder.class.getName()); /** @@ -39,7 +40,7 @@ public class CfgConfigPayloadBuilder { parseLine(line, lineNum, payloadBuilder); lineNum++; } - log.log(FINEST, () -> "payload=" + payloadBuilder.toString()); + log.log(FINEST, () -> "payload=" + payloadBuilder); return payloadBuilder; } @@ -53,8 +54,8 @@ public class CfgConfigPayloadBuilder { log.log(FINE, () -> "Got field without value in line " + lineNum + ": " + line + ", skipping"); return; } - field=field.trim(); - value=value.trim(); + field = field.trim(); + value = value.trim(); validateField(field, trimmedLine, lineNum); validateValue(value, trimmedLine, lineNum); List<String> fields = parseFieldList(field); @@ -96,7 +97,7 @@ public class CfgConfigPayloadBuilder { Pair<String, String> parseFieldAndValue(String line) { String field=null; String value; - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); boolean inMapKey = false; for (char c : line.toCharArray()) { if (c=='{') inMapKey=true; @@ -104,7 +105,7 @@ public class CfgConfigPayloadBuilder { if (c==' ' && !inMapKey) { if (field==null) { field = sb.toString(); - sb = new StringBuffer(); + sb = new StringBuilder(); continue; } } @@ -117,14 +118,14 @@ public class CfgConfigPayloadBuilder { // split on dot, but not if inside { } (map key) List<String> parseFieldList(String field) { List<String> ret = new ArrayList<>(); - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); boolean inMapKey = false; for (char c : field.toCharArray()) { if (c=='{') inMapKey=true; if (c=='}') inMapKey=false; if (c=='.' && !inMapKey) { ret.add(sb.toString()); - sb = new StringBuffer(); + sb = new StringBuilder(); continue; } sb.append(c); @@ -137,7 +138,7 @@ public class CfgConfigPayloadBuilder { private void validateField(String field, String line, int lineNum) { if (field.length() == 0) { throw new ConfigurationRuntimeException("Error on line " + lineNum + ": " + line + "\n" + - "'" + field + "' is not a valid field name"); + "'" + field + "' is not a valid field name"); } } @@ -145,7 +146,7 @@ public class CfgConfigPayloadBuilder { private void validateValue(String value, String line, int lineNum) { if (value.length() == 0) { throw new ConfigurationRuntimeException("Error on line " + lineNum + ": " + line + "\n" + - "'" + value + "' is not a valid value"); + "'" + value + "' is not a valid value"); } } @@ -192,4 +193,5 @@ public class CfgConfigPayloadBuilder { return 0; } } + } diff --git a/config/src/main/java/com/yahoo/config/subscription/impl/JRTConfigRequester.java b/config/src/main/java/com/yahoo/config/subscription/impl/JRTConfigRequester.java index 858dc46f77a..0ef99930dde 100644 --- a/config/src/main/java/com/yahoo/config/subscription/impl/JRTConfigRequester.java +++ b/config/src/main/java/com/yahoo/config/subscription/impl/JRTConfigRequester.java @@ -98,7 +98,8 @@ public class JRTConfigRequester implements RequestWaiter { Connection connection = connectionPool.getCurrent(); Request request = req.getRequest(); request.setContext(new RequestContext(sub, req, connection)); - if (!req.validateParameters()) throw new ConfigurationRuntimeException("Error in parameters for config request: " + req); + if (!req.validateParameters()) + throw new ConfigurationRuntimeException("Error in parameters for config request: " + req); Duration jrtClientTimeout = getClientTimeout(req); log.log(FINE, () -> "Requesting config for " + sub + " on connection " + connection diff --git a/config/src/main/java/com/yahoo/vespa/config/protocol/DefContent.java b/config/src/main/java/com/yahoo/vespa/config/protocol/DefContent.java index 00e5bfa24d3..a84604fceb6 100644 --- a/config/src/main/java/com/yahoo/vespa/config/protocol/DefContent.java +++ b/config/src/main/java/com/yahoo/vespa/config/protocol/DefContent.java @@ -51,7 +51,8 @@ public class DefContent { } /** - * The def file payload of the actual class of the given config + * The def file payload of the actual class of the given config. + * * @param configClass the class of a generated config instance * @return a String array with the config definition (one line per element) */ diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/application/Application.java b/configserver/src/main/java/com/yahoo/vespa/config/server/application/Application.java index 0b409d38196..5ceeb83d2d3 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/application/Application.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/application/Application.java @@ -157,8 +157,8 @@ public class Application implements ModelResult { // This can happen in cases where services ask for config that no longer exist before they have been able // to reconfigure themselves log.log(Level.INFO, TenantRepository.logPre(getId()) + - ": Error resolving instance for builder '" + cacheBuilderClassNameForErrorReport + - "', returning empty config: " + Exceptions.toMessageString(e)); + ": Error resolving instance for builder '" + cacheBuilderClassNameForErrorReport + + "', returning empty config: " + Exceptions.toMessageString(e)); payload = ConfigPayload.fromBuilder(new ConfigPayloadBuilder()); } if (def.getCNode() != null) diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/application/ConfigInstanceBuilder.java b/configserver/src/main/java/com/yahoo/vespa/config/server/application/ConfigInstanceBuilder.java index 1167f32caf5..d99d9a7e017 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/application/ConfigInstanceBuilder.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/application/ConfigInstanceBuilder.java @@ -109,7 +109,8 @@ class ConfigInstanceBuilder { private static Class<? extends ConfigInstance> getConfigClass(Class<? extends ConfigInstance.Builder> builderClass) { Class<?> configClass = builderClass.getEnclosingClass(); if (configClass == null || ! ConfigInstance.class.isAssignableFrom(configClass)) { - throw new ConfigurationRuntimeException("Builder class " + builderClass + " has enclosing class " + configClass + ", which is not a ConfigInstance"); + throw new ConfigurationRuntimeException("Builder class " + builderClass + " has enclosing class " + + configClass + ", which is not a ConfigInstance"); } return (Class<? extends ConfigInstance>) configClass; } diff --git a/container-core/src/main/java/com/yahoo/container/di/Container.java b/container-core/src/main/java/com/yahoo/container/di/Container.java index 5913c5e79d1..8e9874f272e 100644 --- a/container-core/src/main/java/com/yahoo/container/di/Container.java +++ b/container-core/src/main/java/com/yahoo/container/di/Container.java @@ -213,7 +213,7 @@ public class Container { ComponentsConfig componentsConfig = getConfig(componentsConfigKey, configsIncludingBootstrapConfigs); if (componentsConfig == null) { throw new ConfigurationRuntimeException("The set of all configs does not include a valid 'components' config. Config set: " - + configsIncludingBootstrapConfigs.keySet()); + + configsIncludingBootstrapConfigs.keySet()); } addNodes(componentsConfig, graph); injectNodes(componentsConfig, graph); diff --git a/container-search/src/main/java/com/yahoo/search/statistics/ElapsedTime.java b/container-search/src/main/java/com/yahoo/search/statistics/ElapsedTime.java index a2249f8a740..5ba8963c78c 100644 --- a/container-search/src/main/java/com/yahoo/search/statistics/ElapsedTime.java +++ b/container-search/src/main/java/com/yahoo/search/statistics/ElapsedTime.java @@ -25,19 +25,18 @@ public class ElapsedTime { // safe than sorry. It also covers in SearchHandler where the same Execution instance // is used for search and fill. /** A map used as a set to store the time track of all the Execution instances for a Result */ - private Set<TimeTracker> tracks = new TinyIdentitySet<>(8); + private final Set<TimeTracker> tracks = new TinyIdentitySet<>(8); public void add(TimeTracker track) { tracks.add(track); } private long fetcher(Activity toFetch, TimeTracker fetchFrom) { - switch (toFetch) { - case SEARCH: return fetchFrom.searchTime(); - case FILL: return fetchFrom.fillTime(); - case PING: return fetchFrom.pingTime(); - default: return 0L; - } + return switch (toFetch) { + case SEARCH -> fetchFrom.searchTime(); + case FILL -> fetchFrom.fillTime(); + case PING -> fetchFrom.pingTime(); + }; } /** diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/MetricsResponse.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/MetricsResponse.java index d100e3bdd95..9e28a9d85bb 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/MetricsResponse.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/MetricsResponse.java @@ -60,7 +60,7 @@ public class MetricsResponse { private void consumeNode(Inspector nodeObject, NodeList applicationNodes, NodeRepository nodeRepository) { String hostname = nodeObject.field("hostname").asString(); Optional<Node> node = applicationNodes.node(hostname); - if (node.isEmpty()) return; // Node is not part of this cluster any more + if (node.isEmpty()) return; // Node is not part of this cluster any longer ListMap<String, Double> nodeValues = new ListMap<>(); Instant at = consumeNodeMetrics(nodeObject.field("node"), nodeValues); |