summaryrefslogtreecommitdiffstats
path: root/config-model
diff options
context:
space:
mode:
authorgjoranv <gv@verizonmedia.com>2020-01-07 11:38:22 +0100
committerGitHub <noreply@github.com>2020-01-07 11:38:22 +0100
commitfbea1c3b5a6020d6d5fbd5b76d1eb3e693152500 (patch)
tree24efa382235105fa1255e19cc29a75751de38c18 /config-model
parent03ad85915b39cadb1bc0e74b4fa6daec294a88de (diff)
parentef00c557ff5e5b33f6f9fdef83f5357201562ec1 (diff)
Merge pull request #11662 from vespa-engine/bjorncs/apache-commons-libraries-cleanup
Bjorncs/apache commons libraries cleanup
Diffstat (limited to 'config-model')
-rw-r--r--config-model/pom.xml12
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/parser/Utils.java15
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/application/validation/ComplexAttributeFieldsValidator.java3
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/ConfigValueChangeValidator.java5
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/utils/internal/ReflectionUtil.java10
-rw-r--r--config-model/src/main/javacc/SDParser.jj4
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/container/xml/BundleInstantiationSpecificationBuilderTest.java5
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/content/cluster/DomContentSearchBuilderTest.java4
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/content/cluster/DomSearchCoverageBuilderTest.java4
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/content/cluster/DomTuningDispatchBuilderTest.java4
10 files changed, 39 insertions, 27 deletions
diff --git a/config-model/pom.xml b/config-model/pom.xml
index 180a2e40921..25b733985f5 100644
--- a/config-model/pom.xml
+++ b/config-model/pom.xml
@@ -46,10 +46,6 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- </dependency>
- <dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<scope>provided</scope>
@@ -297,14 +293,6 @@
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- </dependency>
- <dependency>
<groupId>com.yahoo.vespa</groupId>
<artifactId>jdisc_http_service</artifactId>
<version>${project.version}</version>
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/parser/Utils.java b/config-model/src/main/java/com/yahoo/searchdefinition/parser/Utils.java
new file mode 100644
index 00000000000..d8f02b2a9c3
--- /dev/null
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/parser/Utils.java
@@ -0,0 +1,15 @@
+// Copyright 2020 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.searchdefinition.parser;
+
+/**
+ * @author bjorncs
+ */
+class Utils {
+
+ private Utils() {}
+
+ // Separate class since javacc does not accept Java code using lambdas
+ static int count(String str, char ch) {
+ return (int) str.chars().filter(c -> c == ch).count();
+ }
+}
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/ComplexAttributeFieldsValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/ComplexAttributeFieldsValidator.java
index 30f08d13772..f9762ce58fa 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/ComplexAttributeFieldsValidator.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/ComplexAttributeFieldsValidator.java
@@ -10,7 +10,6 @@ import com.yahoo.searchdefinition.document.ImmutableSDField;
import com.yahoo.vespa.model.VespaModel;
import com.yahoo.vespa.model.search.AbstractSearchCluster;
import com.yahoo.vespa.model.search.SearchCluster;
-import org.apache.commons.lang.StringUtils;
import java.util.ArrayList;
import java.util.Collection;
@@ -67,7 +66,7 @@ public class ComplexAttributeFieldsValidator extends Validator {
}
private static String toString(ImmutableSDField field) {
- return field.getName() + " (" + StringUtils.join(getStructFieldAttributes(field.getStructFields()), ", ") + ")";
+ return field.getName() + " (" + String.join(", ", getStructFieldAttributes(field.getStructFields())) + ")";
}
private static boolean hasStructFieldAttributes(Collection<? extends ImmutableSDField> structFields) {
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/ConfigValueChangeValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/ConfigValueChangeValidator.java
index 3a97bf4b876..d94cd57357d 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/ConfigValueChangeValidator.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/ConfigValueChangeValidator.java
@@ -4,14 +4,13 @@ package com.yahoo.vespa.model.application.validation.change;
import com.yahoo.config.ChangesRequiringRestart;
import com.yahoo.config.ConfigInstance;
import com.yahoo.config.application.api.DeployLogger;
+import com.yahoo.config.application.api.ValidationOverrides;
import com.yahoo.config.model.api.ConfigChangeAction;
import com.yahoo.config.model.producer.AbstractConfigProducerRoot;
import com.yahoo.vespa.model.Service;
import com.yahoo.vespa.model.VespaModel;
import com.yahoo.vespa.model.application.validation.RestartConfigs;
-import com.yahoo.config.application.api.ValidationOverrides;
import com.yahoo.vespa.model.utils.internal.ReflectionUtil;
-import org.apache.commons.lang3.ClassUtils;
import java.time.Instant;
import java.util.Arrays;
@@ -95,7 +94,7 @@ public class ConfigValueChangeValidator implements ChangeValidator {
* NOTE: Only the super classes that are subclass of Service are inspected.
*/
private static Stream<Class<? extends ConfigInstance>> getConfigInstancesFromServiceAnnotations(Class<? extends Service> serviceClass) {
- List<Class<?>> classHierarchy = ClassUtils.getAllSuperclasses(serviceClass);
+ List<Class<?>> classHierarchy = ReflectionUtil.getAllSuperclasses(serviceClass);
classHierarchy.add(serviceClass);
return classHierarchy.stream()
.filter(Service.class::isAssignableFrom)
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/utils/internal/ReflectionUtil.java b/config-model/src/main/java/com/yahoo/vespa/model/utils/internal/ReflectionUtil.java
index ef021872efb..ab46bb287b1 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/utils/internal/ReflectionUtil.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/utils/internal/ReflectionUtil.java
@@ -9,6 +9,8 @@ import com.yahoo.vespa.model.ConfigProducer;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@@ -80,6 +82,14 @@ public final class ReflectionUtil {
}
}
+ public static List<Class<?>> getAllSuperclasses(Class<?> cls) {
+ var result = new ArrayList<Class<?>>();
+ for(Class<?> superClass = cls.getSuperclass(); superClass != null; superClass = superClass.getSuperclass()) {
+ result.add(superClass);
+ }
+ return result;
+ }
+
private static ConfigKey<?> createConfigKeyFromInstance(Class<?> configInstClass, String configId) {
try {
String defName = ConfigInstance.getDefName(configInstClass);
diff --git a/config-model/src/main/javacc/SDParser.jj b/config-model/src/main/javacc/SDParser.jj
index e560d78a116..61621b4025c 100644
--- a/config-model/src/main/javacc/SDParser.jj
+++ b/config-model/src/main/javacc/SDParser.jj
@@ -63,7 +63,6 @@ import java.util.List;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.logging.Level;
-import org.apache.commons.lang.StringUtils;
/**
* A search definition parser
@@ -2429,7 +2428,8 @@ void importField(Search search) :
<IMPORT> <FIELD> fieldRefSpec = identifier() <AS> aliasFieldName = identifier() lbrace()
<RBRACE>
{
- if (StringUtils.countMatches(fieldRefSpec, ".") != 1) {
+ long nDots = Utils.count(fieldRefSpec, '.');
+ if (nDots != 1) {
throw new IllegalArgumentException("Illegal field reference spec '" + fieldRefSpec + "': Does not include a single '.'");
}
int indexOfDot = fieldRefSpec.indexOf('.');
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/BundleInstantiationSpecificationBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/BundleInstantiationSpecificationBuilderTest.java
index a651bbb7772..d2a840d1fbc 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/BundleInstantiationSpecificationBuilderTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/BundleInstantiationSpecificationBuilderTest.java
@@ -5,13 +5,14 @@ import com.yahoo.component.ComponentSpecification;
import com.yahoo.config.model.builder.xml.XmlHelper;
import com.yahoo.container.bundle.BundleInstantiationSpecification;
import com.yahoo.search.grouping.GroupingValidator;
-import org.apache.commons.io.IOUtils;
import org.junit.Test;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
+import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
@@ -50,7 +51,7 @@ public class BundleInstantiationSpecificationBuilderTest {
xml += " bundle=\"" + explicitBundle + "\"";
}
xml += " />";
- InputStream xmlStream = IOUtils.toInputStream(xml);
+ InputStream xmlStream = new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8));
Element component = XmlHelper.getDocumentBuilder().parse(xmlStream).getDocumentElement();
BundleInstantiationSpecification spec = BundleInstantiationSpecificationBuilder.build(component);
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/cluster/DomContentSearchBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/content/cluster/DomContentSearchBuilderTest.java
index e5d6e149c70..fa38b415cd6 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/content/cluster/DomContentSearchBuilderTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/content/cluster/DomContentSearchBuilderTest.java
@@ -3,10 +3,10 @@ package com.yahoo.vespa.model.content.cluster;
import com.yahoo.vespa.model.content.ContentSearch;
import com.yahoo.vespa.model.builder.xml.dom.ModelElement;
-import org.apache.commons.io.input.CharSequenceInputStream;
import org.junit.Test;
import javax.xml.parsers.DocumentBuilderFactory;
+import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
import static org.junit.Assert.assertEquals;
@@ -52,7 +52,7 @@ public class DomContentSearchBuilderTest {
return DomContentSearchBuilder.build(
new ModelElement(DocumentBuilderFactory.newInstance()
.newDocumentBuilder()
- .parse(new CharSequenceInputStream(xml, StandardCharsets.UTF_8))
+ .parse(new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8)))
.getDocumentElement()));
}
}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/cluster/DomSearchCoverageBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/content/cluster/DomSearchCoverageBuilderTest.java
index d9db6234f1c..107e8968c1a 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/content/cluster/DomSearchCoverageBuilderTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/content/cluster/DomSearchCoverageBuilderTest.java
@@ -3,10 +3,10 @@ package com.yahoo.vespa.model.content.cluster;
import com.yahoo.vespa.model.builder.xml.dom.ModelElement;
import com.yahoo.vespa.model.content.SearchCoverage;
-import org.apache.commons.io.input.CharSequenceInputStream;
import org.junit.Test;
import javax.xml.parsers.DocumentBuilderFactory;
+import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
import static org.junit.Assert.assertEquals;
@@ -71,7 +71,7 @@ public class DomSearchCoverageBuilderTest {
return DomSearchCoverageBuilder.build(
new ModelElement(DocumentBuilderFactory.newInstance()
.newDocumentBuilder()
- .parse(new CharSequenceInputStream(xml, StandardCharsets.UTF_8))
+ .parse(new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8)))
.getDocumentElement()));
}
}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/cluster/DomTuningDispatchBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/content/cluster/DomTuningDispatchBuilderTest.java
index 46b5b630f9e..0f909b7a8eb 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/content/cluster/DomTuningDispatchBuilderTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/content/cluster/DomTuningDispatchBuilderTest.java
@@ -3,10 +3,10 @@ package com.yahoo.vespa.model.content.cluster;
import com.yahoo.vespa.model.builder.xml.dom.ModelElement;
import com.yahoo.vespa.model.content.TuningDispatch;
-import org.apache.commons.io.input.CharSequenceInputStream;
import org.junit.Test;
import javax.xml.parsers.DocumentBuilderFactory;
+import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
import static org.junit.Assert.assertEquals;
@@ -93,7 +93,7 @@ public class DomTuningDispatchBuilderTest {
return DomTuningDispatchBuilder.build(
new ModelElement(DocumentBuilderFactory.newInstance()
.newDocumentBuilder()
- .parse(new CharSequenceInputStream(xml, StandardCharsets.UTF_8))
+ .parse(new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8)))
.getDocumentElement()));
}
}