diff --git a/modules/lang-groovy/build.gradle b/modules/lang-groovy/build.gradle index 7db4eab4403..73ad6043f37 100644 --- a/modules/lang-groovy/build.gradle +++ b/modules/lang-groovy/build.gradle @@ -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 { diff --git a/plugins/analysis-icu/build.gradle b/plugins/analysis-icu/build.gradle index a662f727eeb..9ed155b5fc4 100644 --- a/plugins/analysis-icu/build.gradle +++ b/plugins/analysis-icu/build.gradle @@ -30,6 +30,3 @@ dependencies { dependencyLicenses { mapping from: /lucene-.*/, to: 'lucene' } - -compileJava.options.compilerArgs << "-Xlint:-deprecation" - diff --git a/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuCollationTokenFilterFactory.java b/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuCollationTokenFilterFactory.java index 1e7cd1b09f4..a8b71f3f2f9 100644 --- a/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuCollationTokenFilterFactory.java +++ b/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuCollationTokenFilterFactory.java @@ -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); } diff --git a/plugins/discovery-azure/build.gradle b/plugins/discovery-azure/build.gradle index 12b479eb487..f6b56c9823a 100644 --- a/plugins/discovery-azure/build.gradle +++ b/plugins/discovery-azure/build.gradle @@ -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 diff --git a/plugins/discovery-ec2/build.gradle b/plugins/discovery-ec2/build.gradle index 403b2638257..e8baa1ec502 100644 --- a/plugins/discovery-ec2/build.gradle +++ b/plugins/discovery-ec2/build.gradle @@ -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 diff --git a/plugins/discovery-ec2/src/main/java/org/elasticsearch/cloud/aws/AwsEc2ServiceImpl.java b/plugins/discovery-ec2/src/main/java/org/elasticsearch/cloud/aws/AwsEc2ServiceImpl.java index 349a513455c..40dc8409dd4 100644 --- a/plugins/discovery-ec2/src/main/java/org/elasticsearch/cloud/aws/AwsEc2ServiceImpl.java +++ b/plugins/discovery-ec2/src/main/java/org/elasticsearch/cloud/aws/AwsEc2ServiceImpl.java @@ -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 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 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, diff --git a/plugins/discovery-ec2/src/main/java/org/elasticsearch/plugin/discovery/ec2/Ec2DiscoveryPlugin.java b/plugins/discovery-ec2/src/main/java/org/elasticsearch/plugin/discovery/ec2/Ec2DiscoveryPlugin.java index ffa76c6b9b3..3b3d206c255 100644 --- a/plugins/discovery-ec2/src/main/java/org/elasticsearch/plugin/discovery/ec2/Ec2DiscoveryPlugin.java +++ b/plugins/discovery-ec2/src/main/java/org/elasticsearch/plugin/discovery/ec2/Ec2DiscoveryPlugin.java @@ -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> nodeServices() { Collection> services = new ArrayList<>(); services.add(AwsEc2ServiceImpl.class); diff --git a/plugins/discovery-multicast/build.gradle b/plugins/discovery-multicast/build.gradle index f48f62841b7..295f28c094b 100644 --- a/plugins/discovery-multicast/build.gradle +++ b/plugins/discovery-multicast/build.gradle @@ -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" diff --git a/plugins/discovery-multicast/src/main/java/org/elasticsearch/plugin/discovery/multicast/MulticastZenPing.java b/plugins/discovery-multicast/src/main/java/org/elasticsearch/plugin/discovery/multicast/MulticastZenPing.java index 82bf1bf088c..81f8ed28f84 100644 --- a/plugins/discovery-multicast/src/main/java/org/elasticsearch/plugin/discovery/multicast/MulticastZenPing.java +++ b/plugins/discovery-multicast/src/main/java/org/elasticsearch/plugin/discovery/multicast/MulticastZenPing.java @@ -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 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 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 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 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) { diff --git a/plugins/mapper-attachments/build.gradle b/plugins/mapper-attachments/build.gradle index bbe89aa1fd4..70741c2094d 100644 --- a/plugins/mapper-attachments/build.gradle +++ b/plugins/mapper-attachments/build.gradle @@ -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' diff --git a/plugins/mapper-attachments/src/main/java/org/elasticsearch/mapper/attachments/AttachmentMapper.java b/plugins/mapper-attachments/src/main/java/org/elasticsearch/mapper/attachments/AttachmentMapper.java index d43b5df7e4a..7c54e6f17ce 100644 --- a/plugins/mapper-attachments/src/main/java/org/elasticsearch/mapper/attachments/AttachmentMapper.java +++ b/plugins/mapper-attachments/src/main/java/org/elasticsearch/mapper/attachments/AttachmentMapper.java @@ -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) 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; diff --git a/plugins/repository-azure/build.gradle b/plugins/repository-azure/build.gradle index f0c21bb3828..85a927c02f9 100644 --- a/plugins/repository-azure/build.gradle +++ b/plugins/repository-azure/build.gradle @@ -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' diff --git a/plugins/repository-azure/src/main/java/org/elasticsearch/cloud/azure/storage/AzureStorageSettings.java b/plugins/repository-azure/src/main/java/org/elasticsearch/cloud/azure/storage/AzureStorageSettings.java index c7380e2fd7f..fdc0f40b27b 100644 --- a/plugins/repository-azure/src/main/java/org/elasticsearch/cloud/azure/storage/AzureStorageSettings.java +++ b/plugins/repository-azure/src/main/java/org/elasticsearch/cloud/azure/storage/AzureStorageSettings.java @@ -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> parse(Settings settings) { AzureStorageSettings primaryStorage = null; Map secondaryStorage = new HashMap<>(); diff --git a/plugins/repository-azure/src/test/java/org/elasticsearch/cloud/azure/AbstractAzureRepositoryServiceTestCase.java b/plugins/repository-azure/src/test/java/org/elasticsearch/cloud/azure/AbstractAzureRepositoryServiceTestCase.java index b3e878927e9..43714e4d538 100644 --- a/plugins/repository-azure/src/test/java/org/elasticsearch/cloud/azure/AbstractAzureRepositoryServiceTestCase.java +++ b/plugins/repository-azure/src/test/java/org/elasticsearch/cloud/azure/AbstractAzureRepositoryServiceTestCase.java @@ -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"); diff --git a/plugins/repository-azure/src/test/java/org/elasticsearch/repositories/azure/AzureSettingsParserTest.java b/plugins/repository-azure/src/test/java/org/elasticsearch/repositories/azure/AzureSettingsParserTest.java index 59e8b8945c0..8cb9262af85 100644 --- a/plugins/repository-azure/src/test/java/org/elasticsearch/repositories/azure/AzureSettingsParserTest.java +++ b/plugins/repository-azure/src/test/java/org/elasticsearch/repositories/azure/AzureSettingsParserTest.java @@ -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") diff --git a/plugins/repository-hdfs/build.gradle b/plugins/repository-hdfs/build.gradle index 68ab6f56ddb..924f8cd1d42 100644 --- a/plugins/repository-hdfs/build.gradle +++ b/plugins/repository-hdfs/build.gradle @@ -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', diff --git a/plugins/repository-s3/build.gradle b/plugins/repository-s3/build.gradle index b11aa732b25..a083309891e 100644 --- a/plugins/repository-s3/build.gradle +++ b/plugins/repository-s3/build.gradle @@ -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 diff --git a/plugins/repository-s3/src/main/java/org/elasticsearch/cloud/aws/InternalAwsS3Service.java b/plugins/repository-s3/src/main/java/org/elasticsearch/cloud/aws/InternalAwsS3Service.java index 51594c01302..fc26d3e6b71 100644 --- a/plugins/repository-s3/src/main/java/org/elasticsearch/cloud/aws/InternalAwsS3Service.java +++ b/plugins/repository-s3/src/main/java/org/elasticsearch/cloud/aws/InternalAwsS3Service.java @@ -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 clientDescriptor = new Tuple(endpoint, account); AmazonS3Client client = clients.get(clientDescriptor); diff --git a/plugins/repository-s3/src/main/java/org/elasticsearch/plugin/repository/s3/S3RepositoryPlugin.java b/plugins/repository-s3/src/main/java/org/elasticsearch/plugin/repository/s3/S3RepositoryPlugin.java index a7305727353..2b486e5505c 100644 --- a/plugins/repository-s3/src/main/java/org/elasticsearch/plugin/repository/s3/S3RepositoryPlugin.java +++ b/plugins/repository-s3/src/main/java/org/elasticsearch/plugin/repository/s3/S3RepositoryPlugin.java @@ -77,6 +77,7 @@ public class S3RepositoryPlugin extends Plugin { } @Override + @SuppressWarnings("rawtypes") // Supertype declaration has raw types public Collection> nodeServices() { return Collections.>singleton(S3Module.getS3ServiceImpl()); }