Remove -Xlint exclusions in the ingest-common module. (#40505)
Fix the generics in processors extending AbstractStringProcessor and its factory. Relates to #40366
This commit is contained in:
parent
e256eb361a
commit
89837eb918
|
@ -29,9 +29,6 @@ dependencies {
|
||||||
compile project(':libs:dissect')
|
compile project(':libs:dissect')
|
||||||
}
|
}
|
||||||
|
|
||||||
compileJava.options.compilerArgs << "-Xlint:-unchecked,-rawtypes"
|
|
||||||
compileTestJava.options.compilerArgs << "-Xlint:-unchecked,-rawtypes"
|
|
||||||
|
|
||||||
integTestCluster {
|
integTestCluster {
|
||||||
module project(':modules:lang-painless')
|
module project(':modules:lang-painless')
|
||||||
}
|
}
|
|
@ -80,8 +80,8 @@ abstract class AbstractStringProcessor<T> extends AbstractProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AbstractStringProcessor create(Map<String, Processor.Factory> registry, String tag,
|
public AbstractStringProcessor<?> create(Map<String, Processor.Factory> registry, String tag,
|
||||||
Map<String, Object> config) throws Exception {
|
Map<String, Object> config) throws Exception {
|
||||||
String field = ConfigurationUtils.readStringProperty(processorType, tag, config, "field");
|
String field = ConfigurationUtils.readStringProperty(processorType, tag, config, "field");
|
||||||
boolean ignoreMissing = ConfigurationUtils.readBooleanProperty(processorType, tag, config, "ignore_missing", false);
|
boolean ignoreMissing = ConfigurationUtils.readBooleanProperty(processorType, tag, config, "ignore_missing", false);
|
||||||
String targetField = ConfigurationUtils.readStringProperty(processorType, tag, config, "target_field", field);
|
String targetField = ConfigurationUtils.readStringProperty(processorType, tag, config, "target_field", field);
|
||||||
|
@ -89,7 +89,7 @@ abstract class AbstractStringProcessor<T> extends AbstractProcessor {
|
||||||
return newProcessor(tag, config, field, ignoreMissing, targetField);
|
return newProcessor(tag, config, field, ignoreMissing, targetField);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract AbstractStringProcessor newProcessor(String processorTag, Map<String, Object> config, String field,
|
protected abstract AbstractStringProcessor<?> newProcessor(String processorTag, Map<String, Object> config, String field,
|
||||||
boolean ignoreMissing, String targetField);
|
boolean ignoreMissing, String targetField);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ import java.util.Map;
|
||||||
* Processor that converts the content of string fields to the byte value.
|
* Processor that converts the content of string fields to the byte value.
|
||||||
* Throws exception is the field is not of type string or can not convert to the numeric byte value
|
* Throws exception is the field is not of type string or can not convert to the numeric byte value
|
||||||
*/
|
*/
|
||||||
public final class BytesProcessor extends AbstractStringProcessor {
|
public final class BytesProcessor extends AbstractStringProcessor<Long> {
|
||||||
|
|
||||||
public static final String TYPE = "bytes";
|
public static final String TYPE = "bytes";
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ import static org.elasticsearch.ingest.ConfigurationUtils.readStringProperty;
|
||||||
* Processor that allows to search for patterns in field content and replace them with corresponding string replacement.
|
* Processor that allows to search for patterns in field content and replace them with corresponding string replacement.
|
||||||
* Support fields of string type only, throws exception if a field is of a different type.
|
* Support fields of string type only, throws exception if a field is of a different type.
|
||||||
*/
|
*/
|
||||||
public final class GsubProcessor extends AbstractStringProcessor {
|
public final class GsubProcessor extends AbstractStringProcessor<String> {
|
||||||
|
|
||||||
public static final String TYPE = "gsub";
|
public static final String TYPE = "gsub";
|
||||||
|
|
||||||
|
@ -67,8 +67,8 @@ public final class GsubProcessor extends AbstractStringProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected AbstractStringProcessor newProcessor(String processorTag, Map<String, Object> config, String field,
|
protected GsubProcessor newProcessor(String processorTag, Map<String, Object> config, String field,
|
||||||
boolean ignoreMissing, String targetField) {
|
boolean ignoreMissing, String targetField) {
|
||||||
String pattern = readStringProperty(TYPE, processorTag, config, "pattern");
|
String pattern = readStringProperty(TYPE, processorTag, config, "pattern");
|
||||||
String replacement = readStringProperty(TYPE, processorTag, config, "replacement");
|
String replacement = readStringProperty(TYPE, processorTag, config, "replacement");
|
||||||
Pattern searchPattern;
|
Pattern searchPattern;
|
||||||
|
|
|
@ -27,7 +27,7 @@ import java.util.Map;
|
||||||
* Throws exception is the field is not of type string.
|
* Throws exception is the field is not of type string.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public final class LowercaseProcessor extends AbstractStringProcessor {
|
public final class LowercaseProcessor extends AbstractStringProcessor<String> {
|
||||||
|
|
||||||
public static final String TYPE = "lowercase";
|
public static final String TYPE = "lowercase";
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ import java.util.Map;
|
||||||
* Processor that trims the content of string fields.
|
* Processor that trims the content of string fields.
|
||||||
* Throws exception is the field is not of type string.
|
* Throws exception is the field is not of type string.
|
||||||
*/
|
*/
|
||||||
public final class TrimProcessor extends AbstractStringProcessor {
|
public final class TrimProcessor extends AbstractStringProcessor<String> {
|
||||||
|
|
||||||
public static final String TYPE = "trim";
|
public static final String TYPE = "trim";
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ import java.util.Map;
|
||||||
/**
|
/**
|
||||||
* Processor that URL-decodes a string
|
* Processor that URL-decodes a string
|
||||||
*/
|
*/
|
||||||
public final class URLDecodeProcessor extends AbstractStringProcessor {
|
public final class URLDecodeProcessor extends AbstractStringProcessor<String> {
|
||||||
|
|
||||||
public static final String TYPE = "urldecode";
|
public static final String TYPE = "urldecode";
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ import java.util.Map;
|
||||||
* Processor that converts the content of string fields to uppercase.
|
* Processor that converts the content of string fields to uppercase.
|
||||||
* Throws exception is the field is not of type string.
|
* Throws exception is the field is not of type string.
|
||||||
*/
|
*/
|
||||||
public final class UppercaseProcessor extends AbstractStringProcessor {
|
public final class UppercaseProcessor extends AbstractStringProcessor<String> {
|
||||||
|
|
||||||
public static final String TYPE = "uppercase";
|
public static final String TYPE = "uppercase";
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ public abstract class AbstractStringProcessorFactoryTestCase extends ESTestCase
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void assertProcessor(AbstractStringProcessor processor) {}
|
protected void assertProcessor(AbstractStringProcessor<?> processor) {}
|
||||||
|
|
||||||
public void testCreate() throws Exception {
|
public void testCreate() throws Exception {
|
||||||
AbstractStringProcessor.Factory factory = newFactory();
|
AbstractStringProcessor.Factory factory = newFactory();
|
||||||
|
@ -47,7 +47,7 @@ public abstract class AbstractStringProcessorFactoryTestCase extends ESTestCase
|
||||||
Map<String, Object> config = new HashMap<>();
|
Map<String, Object> config = new HashMap<>();
|
||||||
config.put("field", fieldName);
|
config.put("field", fieldName);
|
||||||
|
|
||||||
AbstractStringProcessor processor = factory.create(null, processorTag, modifyConfig(config));
|
AbstractStringProcessor<?> processor = factory.create(null, processorTag, modifyConfig(config));
|
||||||
assertThat(processor.getTag(), equalTo(processorTag));
|
assertThat(processor.getTag(), equalTo(processorTag));
|
||||||
assertThat(processor.getField(), equalTo(fieldName));
|
assertThat(processor.getField(), equalTo(fieldName));
|
||||||
assertThat(processor.isIgnoreMissing(), is(false));
|
assertThat(processor.isIgnoreMissing(), is(false));
|
||||||
|
@ -64,7 +64,7 @@ public abstract class AbstractStringProcessorFactoryTestCase extends ESTestCase
|
||||||
config.put("field", fieldName);
|
config.put("field", fieldName);
|
||||||
config.put("ignore_missing", true);
|
config.put("ignore_missing", true);
|
||||||
|
|
||||||
AbstractStringProcessor processor = factory.create(null, processorTag, modifyConfig(config));
|
AbstractStringProcessor<?> processor = factory.create(null, processorTag, modifyConfig(config));
|
||||||
assertThat(processor.getTag(), equalTo(processorTag));
|
assertThat(processor.getTag(), equalTo(processorTag));
|
||||||
assertThat(processor.getField(), equalTo(fieldName));
|
assertThat(processor.getField(), equalTo(fieldName));
|
||||||
assertThat(processor.isIgnoreMissing(), is(true));
|
assertThat(processor.isIgnoreMissing(), is(true));
|
||||||
|
@ -82,7 +82,7 @@ public abstract class AbstractStringProcessorFactoryTestCase extends ESTestCase
|
||||||
config.put("field", fieldName);
|
config.put("field", fieldName);
|
||||||
config.put("target_field", targetFieldName);
|
config.put("target_field", targetFieldName);
|
||||||
|
|
||||||
AbstractStringProcessor processor = factory.create(null, processorTag, modifyConfig(config));
|
AbstractStringProcessor<?> processor = factory.create(null, processorTag, modifyConfig(config));
|
||||||
assertThat(processor.getTag(), equalTo(processorTag));
|
assertThat(processor.getTag(), equalTo(processorTag));
|
||||||
assertThat(processor.getField(), equalTo(fieldName));
|
assertThat(processor.getField(), equalTo(fieldName));
|
||||||
assertThat(processor.isIgnoreMissing(), is(false));
|
assertThat(processor.isIgnoreMissing(), is(false));
|
||||||
|
|
|
@ -33,7 +33,7 @@ import static org.hamcrest.Matchers.equalTo;
|
||||||
|
|
||||||
public abstract class AbstractStringProcessorTestCase<T> extends ESTestCase {
|
public abstract class AbstractStringProcessorTestCase<T> extends ESTestCase {
|
||||||
|
|
||||||
protected abstract AbstractStringProcessor newProcessor(String field, boolean ignoreMissing, String targetField);
|
protected abstract AbstractStringProcessor<T> newProcessor(String field, boolean ignoreMissing, String targetField);
|
||||||
|
|
||||||
protected String modifyInput(String input) {
|
protected String modifyInput(String input) {
|
||||||
return input;
|
return input;
|
||||||
|
@ -41,8 +41,8 @@ public abstract class AbstractStringProcessorTestCase<T> extends ESTestCase {
|
||||||
|
|
||||||
protected abstract T expectedResult(String input);
|
protected abstract T expectedResult(String input);
|
||||||
|
|
||||||
protected Class<T> expectedResultType(){
|
protected Class<?> expectedResultType(){
|
||||||
return (Class<T>) String.class; // most results types are Strings
|
return String.class; // most results types are Strings
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testProcessor() throws Exception {
|
public void testProcessor() throws Exception {
|
||||||
|
|
|
@ -29,12 +29,12 @@ import org.hamcrest.CoreMatchers;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
|
||||||
public class BytesProcessorTests extends AbstractStringProcessorTestCase {
|
public class BytesProcessorTests extends AbstractStringProcessorTestCase<Long> {
|
||||||
|
|
||||||
private String modifiedInput;
|
private String modifiedInput;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected AbstractStringProcessor newProcessor(String field, boolean ignoreMissing, String targetField) {
|
protected AbstractStringProcessor<Long> newProcessor(String field, boolean ignoreMissing, String targetField) {
|
||||||
return new BytesProcessor(randomAlphaOfLength(10), field, ignoreMissing, targetField);
|
return new BytesProcessor(randomAlphaOfLength(10), field, ignoreMissing, targetField);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class GsubProcessorFactoryTests extends AbstractStringProcessorFactoryTes
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void assertProcessor(AbstractStringProcessor processor) {
|
protected void assertProcessor(AbstractStringProcessor<?> processor) {
|
||||||
GsubProcessor gsubProcessor = (GsubProcessor) processor;
|
GsubProcessor gsubProcessor = (GsubProcessor) processor;
|
||||||
assertThat(gsubProcessor.getPattern().toString(), equalTo("\\."));
|
assertThat(gsubProcessor.getPattern().toString(), equalTo("\\."));
|
||||||
assertThat(gsubProcessor.getReplacement(), equalTo("-"));
|
assertThat(gsubProcessor.getReplacement(), equalTo("-"));
|
||||||
|
|
|
@ -21,10 +21,10 @@ package org.elasticsearch.ingest.common;
|
||||||
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class GsubProcessorTests extends AbstractStringProcessorTestCase {
|
public class GsubProcessorTests extends AbstractStringProcessorTestCase<String> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected AbstractStringProcessor newProcessor(String field, boolean ignoreMissing, String targetField) {
|
protected AbstractStringProcessor<String> newProcessor(String field, boolean ignoreMissing, String targetField) {
|
||||||
return new GsubProcessor(randomAlphaOfLength(10), field, Pattern.compile("\\."), "-", ignoreMissing, targetField);
|
return new GsubProcessor(randomAlphaOfLength(10), field, Pattern.compile("\\."), "-", ignoreMissing, targetField);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,9 +21,9 @@ package org.elasticsearch.ingest.common;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public class LowercaseProcessorTests extends AbstractStringProcessorTestCase {
|
public class LowercaseProcessorTests extends AbstractStringProcessorTestCase<String> {
|
||||||
@Override
|
@Override
|
||||||
protected AbstractStringProcessor newProcessor(String field, boolean ignoreMissing, String targetField) {
|
protected AbstractStringProcessor<String> newProcessor(String field, boolean ignoreMissing, String targetField) {
|
||||||
return new LowercaseProcessor(randomAlphaOfLength(10), field, ignoreMissing, targetField);
|
return new LowercaseProcessor(randomAlphaOfLength(10), field, ignoreMissing, targetField);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,10 +19,10 @@
|
||||||
|
|
||||||
package org.elasticsearch.ingest.common;
|
package org.elasticsearch.ingest.common;
|
||||||
|
|
||||||
public class TrimProcessorTests extends AbstractStringProcessorTestCase {
|
public class TrimProcessorTests extends AbstractStringProcessorTestCase<String> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected AbstractStringProcessor newProcessor(String field, boolean ignoreMissing, String targetField) {
|
protected AbstractStringProcessor<String> newProcessor(String field, boolean ignoreMissing, String targetField) {
|
||||||
return new TrimProcessor(randomAlphaOfLength(10), field, ignoreMissing, targetField);
|
return new TrimProcessor(randomAlphaOfLength(10), field, ignoreMissing, targetField);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,14 +22,14 @@ package org.elasticsearch.ingest.common;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
|
|
||||||
public class URLDecodeProcessorTests extends AbstractStringProcessorTestCase {
|
public class URLDecodeProcessorTests extends AbstractStringProcessorTestCase<String> {
|
||||||
@Override
|
@Override
|
||||||
protected String modifyInput(String input) {
|
protected String modifyInput(String input) {
|
||||||
return "Hello%20G%C3%BCnter" + input;
|
return "Hello%20G%C3%BCnter" + input;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected AbstractStringProcessor newProcessor(String field, boolean ignoreMissing, String targetField) {
|
protected AbstractStringProcessor<String> newProcessor(String field, boolean ignoreMissing, String targetField) {
|
||||||
return new URLDecodeProcessor(randomAlphaOfLength(10), field, ignoreMissing, targetField);
|
return new URLDecodeProcessor(randomAlphaOfLength(10), field, ignoreMissing, targetField);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,10 +21,10 @@ package org.elasticsearch.ingest.common;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public class UppercaseProcessorTests extends AbstractStringProcessorTestCase {
|
public class UppercaseProcessorTests extends AbstractStringProcessorTestCase<String> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected AbstractStringProcessor newProcessor(String field, boolean ignoreMissing, String targetField) {
|
protected AbstractStringProcessor<String> newProcessor(String field, boolean ignoreMissing, String targetField) {
|
||||||
return new UppercaseProcessor(randomAlphaOfLength(10), field, ignoreMissing, targetField);
|
return new UppercaseProcessor(randomAlphaOfLength(10), field, ignoreMissing, targetField);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue