Remove -Xlint:-deprecation from plugins
Instead we suppress warnings about using deprecated stuff near the usage site with a comment about why its ok.
This commit is contained in:
parent
dcd8a8207f
commit
81a7607256
|
@ -26,8 +26,8 @@ dependencies {
|
|||
compile 'org.codehaus.groovy:groovy:2.4.4:indy'
|
||||
}
|
||||
|
||||
compileJava.options.compilerArgs << '-Xlint:-rawtypes,-unchecked,-cast,-deprecation'
|
||||
compileTestJava.options.compilerArgs << '-Xlint:-rawtypes,-unchecked,-cast,-deprecation'
|
||||
compileJava.options.compilerArgs << '-Xlint:-rawtypes,-unchecked,-cast'
|
||||
compileTestJava.options.compilerArgs << '-Xlint:-rawtypes,-unchecked,-cast'
|
||||
|
||||
integTest {
|
||||
cluster {
|
||||
|
|
|
@ -30,6 +30,3 @@ dependencies {
|
|||
dependencyLicenses {
|
||||
mapping from: /lucene-.*/, to: 'lucene'
|
||||
}
|
||||
|
||||
compileJava.options.compilerArgs << "-Xlint:-deprecation"
|
||||
|
||||
|
|
|
@ -19,18 +19,19 @@
|
|||
|
||||
package org.elasticsearch.index.analysis;
|
||||
|
||||
import com.ibm.icu.text.Collator;
|
||||
import com.ibm.icu.text.RuleBasedCollator;
|
||||
import com.ibm.icu.util.ULocale;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Files;
|
||||
|
||||
import org.apache.lucene.analysis.TokenStream;
|
||||
import org.elasticsearch.common.io.Streams;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.env.Environment;
|
||||
import org.elasticsearch.index.IndexSettings;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Files;
|
||||
import com.ibm.icu.text.Collator;
|
||||
import com.ibm.icu.text.RuleBasedCollator;
|
||||
import com.ibm.icu.util.ULocale;
|
||||
|
||||
/**
|
||||
* An ICU based collation token filter. There are two ways to configure collation:
|
||||
|
@ -45,6 +46,7 @@ public class IcuCollationTokenFilterFactory extends AbstractTokenFilterFactory {
|
|||
|
||||
private final Collator collator;
|
||||
|
||||
@SuppressWarnings("deprecation") // Intentionally sets deprecated options for backwards compatibility
|
||||
public IcuCollationTokenFilterFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) {
|
||||
super(indexSettings, name, settings);
|
||||
|
||||
|
@ -165,6 +167,7 @@ public class IcuCollationTokenFilterFactory extends AbstractTokenFilterFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation") // Constructs a deprecated filter for backwards compatibility
|
||||
public TokenStream create(TokenStream tokenStream) {
|
||||
return new ICUCollationKeyFilter(tokenStream, collator);
|
||||
}
|
||||
|
|
|
@ -57,8 +57,6 @@ dependencyLicenses {
|
|||
}
|
||||
|
||||
compileJava.options.compilerArgs << '-Xlint:-path,-serial,-unchecked'
|
||||
// TODO: why is deprecation needed here but not in maven....?
|
||||
compileJava.options.compilerArgs << '-Xlint:-deprecation'
|
||||
|
||||
thirdPartyAudit.excludes = [
|
||||
// classes are missing
|
||||
|
|
|
@ -42,8 +42,6 @@ dependencyLicenses {
|
|||
mapping from: /jackson-.*/, to: 'jackson'
|
||||
}
|
||||
|
||||
compileJava.options.compilerArgs << '-Xlint:-rawtypes,-deprecation'
|
||||
|
||||
test {
|
||||
// this is needed for insecure plugins, remove if possible!
|
||||
systemProperty 'tests.artifact', project.name
|
||||
|
|
|
@ -33,6 +33,7 @@ import com.amazonaws.internal.StaticCredentialsProvider;
|
|||
import com.amazonaws.retry.RetryPolicy;
|
||||
import com.amazonaws.services.ec2.AmazonEC2;
|
||||
import com.amazonaws.services.ec2.AmazonEC2Client;
|
||||
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.cloud.aws.network.Ec2NameResolver;
|
||||
import org.elasticsearch.cloud.aws.node.Ec2CustomNodeAttributes;
|
||||
|
@ -71,6 +72,8 @@ public class AwsEc2ServiceImpl extends AbstractLifecycleComponent<AwsEc2Service>
|
|||
discoveryNodeService.addCustomAttributeProvider(new Ec2CustomNodeAttributes(settings));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation") // Supports deprecated parameters for backwards compatibility
|
||||
public synchronized AmazonEC2 client() {
|
||||
if (client != null) {
|
||||
return client;
|
||||
|
@ -135,7 +138,7 @@ public class AwsEc2ServiceImpl extends AbstractLifecycleComponent<AwsEc2Service>
|
|||
int retriesAttempted) {
|
||||
// with 10 retries the max delay time is 320s/320000ms (10 * 2^5 * 1 * 1000)
|
||||
logger.warn("EC2 API request failed, retry again. Reason was:", exception);
|
||||
return 1000L * (long) (10d * Math.pow(2, ((double) retriesAttempted) / 2.0d) * (1.0d + rand.nextDouble()));
|
||||
return 1000L * (long) (10d * Math.pow(2, retriesAttempted / 2.0d) * (1.0d + rand.nextDouble()));
|
||||
}
|
||||
},
|
||||
10,
|
||||
|
|
|
@ -19,6 +19,11 @@
|
|||
|
||||
package org.elasticsearch.plugin.discovery.ec2;
|
||||
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.elasticsearch.SpecialPermission;
|
||||
import org.elasticsearch.cloud.aws.AwsEc2ServiceImpl;
|
||||
import org.elasticsearch.cloud.aws.Ec2Module;
|
||||
|
@ -32,16 +37,11 @@ import org.elasticsearch.discovery.ec2.AwsEc2UnicastHostsProvider;
|
|||
import org.elasticsearch.discovery.ec2.Ec2Discovery;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class Ec2DiscoveryPlugin extends Plugin {
|
||||
|
||||
|
||||
// ClientConfiguration clinit has some classloader problems
|
||||
// TODO: fix that
|
||||
static {
|
||||
|
@ -87,6 +87,7 @@ public class Ec2DiscoveryPlugin extends Plugin {
|
|||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes") // Supertype uses rawtype
|
||||
public Collection<Class<? extends LifecycleComponent>> nodeServices() {
|
||||
Collection<Class<? extends LifecycleComponent>> services = new ArrayList<>();
|
||||
services.add(AwsEc2ServiceImpl.class);
|
||||
|
|
|
@ -21,5 +21,3 @@ esplugin {
|
|||
description 'The Multicast Discovery plugin allows discovery other nodes using multicast requests'
|
||||
classname 'org.elasticsearch.plugin.discovery.multicast.MulticastDiscoveryPlugin'
|
||||
}
|
||||
|
||||
compileJava.options.compilerArgs << "-Xlint:-deprecation"
|
||||
|
|
|
@ -19,7 +19,18 @@
|
|||
|
||||
package org.elasticsearch.plugin.discovery.multicast;
|
||||
|
||||
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.SocketAddress;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.apache.lucene.util.Constants;
|
||||
import org.elasticsearch.ExceptionsHelper;
|
||||
import org.elasticsearch.SpecialPermission;
|
||||
|
@ -55,17 +66,7 @@ import org.elasticsearch.transport.TransportRequestHandler;
|
|||
import org.elasticsearch.transport.TransportResponse;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.SocketAddress;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
|
||||
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNode.readNode;
|
||||
import static org.elasticsearch.common.settings.Settings.Builder.EMPTY_SETTINGS;
|
||||
|
@ -144,13 +145,9 @@ public class MulticastZenPing extends AbstractLifecycleComponent<ZenPing> implem
|
|||
boolean shared = settings.getAsBoolean("discovery.zen.ping.multicast.shared", Constants.MAC_OS_X);
|
||||
// OSX does not correctly send multicasts FROM the right interface
|
||||
boolean deferToInterface = settings.getAsBoolean("discovery.zen.ping.multicast.defer_group_to_set_interface", Constants.MAC_OS_X);
|
||||
// don't use publish address, the use case for that is e.g. a firewall or proxy and
|
||||
// may not even be bound to an interface on this machine! use the first bound address.
|
||||
List<InetAddress> addresses = Arrays.asList(networkService.resolveBindHostAddresses(address == null ? null : new String[] { address }));
|
||||
NetworkUtils.sortAddresses(addresses);
|
||||
|
||||
final MulticastChannel.Config config = new MulticastChannel.Config(port, group, bufferSize, ttl,
|
||||
addresses.get(0), deferToInterface);
|
||||
getMulticastInterface(), deferToInterface);
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
sm.checkPermission(new SpecialPermission());
|
||||
|
@ -167,6 +164,16 @@ public class MulticastZenPing extends AbstractLifecycleComponent<ZenPing> implem
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("deprecation") // Used to support funky configuration options
|
||||
private InetAddress getMulticastInterface() throws IOException {
|
||||
// don't use publish address, the use case for that is e.g. a firewall or proxy and
|
||||
// may not even be bound to an interface on this machine! use the first bound address.
|
||||
List<InetAddress> addresses = Arrays.asList(networkService.resolveBindHostAddresses(address == null ? null : new String[] { address }));
|
||||
NetworkUtils.sortAddresses(addresses);
|
||||
return addresses.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doStop() {
|
||||
if (multicastChannel != null) {
|
||||
|
|
|
@ -61,7 +61,7 @@ dependencies {
|
|||
compile 'org.apache.commons:commons-compress:1.10'
|
||||
}
|
||||
|
||||
compileJava.options.compilerArgs << '-Xlint:-cast,-deprecation,-rawtypes'
|
||||
compileJava.options.compilerArgs << '-Xlint:-cast,-rawtypes'
|
||||
|
||||
forbiddenPatterns {
|
||||
exclude '**/*.docx'
|
||||
|
|
|
@ -100,6 +100,7 @@ public class AttachmentMapper extends FieldMapper {
|
|||
super(ref);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttachmentMapper.AttachmentFieldType clone() {
|
||||
return new AttachmentMapper.AttachmentFieldType(this);
|
||||
}
|
||||
|
@ -109,6 +110,7 @@ public class AttachmentMapper extends FieldMapper {
|
|||
return CONTENT_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String value(Object value) {
|
||||
return value == null?null:value.toString();
|
||||
}
|
||||
|
@ -292,7 +294,7 @@ public class AttachmentMapper extends FieldMapper {
|
|||
type = "string";
|
||||
}
|
||||
Mapper.TypeParser typeParser = parserContext.typeParser(type);
|
||||
Mapper.Builder<?, ?> mapperBuilder = typeParser.parse(propName, (Map<String, Object>) propNode, parserContext);
|
||||
Mapper.Builder<?, ?> mapperBuilder = typeParser.parse(propName, propNode, parserContext);
|
||||
|
||||
return mapperBuilder;
|
||||
}
|
||||
|
@ -414,6 +416,7 @@ public class AttachmentMapper extends FieldMapper {
|
|||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation") // https://github.com/elastic/elasticsearch/issues/15843
|
||||
public Mapper parse(ParseContext context) throws IOException {
|
||||
byte[] content = null;
|
||||
String contentType = null;
|
||||
|
|
|
@ -35,6 +35,5 @@ dependencyLicenses {
|
|||
mapping from: /stax-.*/, to: 'stax'
|
||||
}
|
||||
|
||||
compileJava.options.compilerArgs << '-Xlint:-deprecation,-serial'
|
||||
compileTestJava.options.compilerArgs << '-Xlint:-deprecation'
|
||||
compileJava.options.compilerArgs << '-Xlint:-serial'
|
||||
|
||||
|
|
|
@ -19,6 +19,9 @@
|
|||
|
||||
package org.elasticsearch.cloud.azure.storage;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.elasticsearch.cloud.azure.storage.AzureStorageService.Storage;
|
||||
import org.elasticsearch.common.collect.Tuple;
|
||||
import org.elasticsearch.common.logging.ESLogger;
|
||||
|
@ -28,9 +31,6 @@ import org.elasticsearch.common.unit.ByteSizeValue;
|
|||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.repositories.RepositorySettings;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class AzureStorageSettings {
|
||||
private static ESLogger logger = ESLoggerFactory.getLogger(AzureStorageSettings.class.getName());
|
||||
|
||||
|
@ -78,6 +78,7 @@ public class AzureStorageSettings {
|
|||
* @param settings settings to parse
|
||||
* @return A tuple with v1 = primary storage and v2 = secondary storage
|
||||
*/
|
||||
@SuppressWarnings("deprecation") // Supports deprecated settings
|
||||
public static Tuple<AzureStorageSettings, Map<String, AzureStorageSettings>> parse(Settings settings) {
|
||||
AzureStorageSettings primaryStorage = null;
|
||||
Map<String, AzureStorageSettings> secondaryStorage = new HashMap<>();
|
||||
|
|
|
@ -19,8 +19,9 @@
|
|||
|
||||
package org.elasticsearch.cloud.azure;
|
||||
|
||||
import com.microsoft.azure.storage.LocationMode;
|
||||
import com.microsoft.azure.storage.StorageException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.elasticsearch.cloud.azure.storage.AzureStorageService;
|
||||
import org.elasticsearch.cloud.azure.storage.AzureStorageService.Storage;
|
||||
import org.elasticsearch.cloud.azure.storage.AzureStorageServiceMock;
|
||||
|
@ -33,8 +34,8 @@ import org.elasticsearch.test.store.MockFSDirectoryService;
|
|||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Collection;
|
||||
import com.microsoft.azure.storage.LocationMode;
|
||||
import com.microsoft.azure.storage.StorageException;
|
||||
|
||||
public abstract class AbstractAzureRepositoryServiceTestCase extends AbstractAzureTestCase {
|
||||
|
||||
|
@ -76,6 +77,7 @@ public abstract class AbstractAzureRepositoryServiceTestCase extends AbstractAzu
|
|||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation") // Supports deprecated settings for testing backwards compatibility
|
||||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
Settings.Builder builder = Settings.settingsBuilder()
|
||||
.put(Storage.CONTAINER, "snapshots");
|
||||
|
|
|
@ -19,14 +19,14 @@
|
|||
|
||||
package org.elasticsearch.repositories.azure;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.elasticsearch.cloud.azure.storage.AzureStorageService.Storage;
|
||||
import org.elasticsearch.cloud.azure.storage.AzureStorageSettings;
|
||||
import org.elasticsearch.common.collect.Tuple;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
|
@ -67,6 +67,7 @@ public class AzureSettingsParserTest extends LuceneTestCase {
|
|||
}
|
||||
|
||||
public void testDeprecatedSettings() {
|
||||
@SuppressWarnings("deprecation")
|
||||
Settings settings = Settings.builder()
|
||||
.put(Storage.ACCOUNT_DEPRECATED, "myaccount1")
|
||||
.put(Storage.KEY_DEPRECATED, "mykey1")
|
||||
|
|
|
@ -96,8 +96,6 @@ integTest {
|
|||
}
|
||||
}
|
||||
|
||||
compileJava.options.compilerArgs << '-Xlint:-deprecation,-rawtypes'
|
||||
|
||||
thirdPartyAudit.excludes = [
|
||||
// classes are missing, because we added hadoop jars one by one until tests pass.
|
||||
'com.google.gson.stream.JsonReader',
|
||||
|
|
|
@ -43,8 +43,6 @@ dependencyLicenses {
|
|||
mapping from: /jackson-.*/, to: 'jackson'
|
||||
}
|
||||
|
||||
compileJava.options.compilerArgs << '-Xlint:-deprecation,-rawtypes'
|
||||
|
||||
test {
|
||||
// this is needed for insecure plugins, remove if possible!
|
||||
systemProperty 'tests.artifact', project.name
|
||||
|
|
|
@ -31,6 +31,7 @@ import com.amazonaws.http.IdleConnectionReaper;
|
|||
import com.amazonaws.internal.StaticCredentialsProvider;
|
||||
import com.amazonaws.services.s3.AmazonS3;
|
||||
import com.amazonaws.services.s3.AmazonS3Client;
|
||||
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.common.collect.Tuple;
|
||||
import org.elasticsearch.common.component.AbstractLifecycleComponent;
|
||||
|
@ -94,7 +95,7 @@ public class InternalAwsS3Service extends AbstractLifecycleComponent<AwsS3Servic
|
|||
return getClient(endpoint, protocol, account, key, maxRetries);
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("deprecation") // Handles deprecated settings.
|
||||
private synchronized AmazonS3 getClient(String endpoint, String protocol, String account, String key, Integer maxRetries) {
|
||||
Tuple<String, String> clientDescriptor = new Tuple<String, String>(endpoint, account);
|
||||
AmazonS3Client client = clients.get(clientDescriptor);
|
||||
|
|
|
@ -77,6 +77,7 @@ public class S3RepositoryPlugin extends Plugin {
|
|||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes") // Supertype declaration has raw types
|
||||
public Collection<Class<? extends LifecycleComponent>> nodeServices() {
|
||||
return Collections.<Class<? extends LifecycleComponent>>singleton(S3Module.getS3ServiceImpl());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue