Skip to content

Commit 38a961c

Browse files
Add @SuppressWarnings("removal") to not fail the build with -Werror for some JDKs (#11931) (#11934)
(cherry picked from commit 6dee955) Signed-off-by: Andriy Redko <andriy.redko@aiven.io> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent a2eb7f2 commit 38a961c

File tree

24 files changed

+28
-2
lines changed

24 files changed

+28
-2
lines changed

distribution/archives/integ-test-zip/src/test/java/org/opensearch/test/rest/JsonLogsFormatAndParseIT.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ protected Matcher<String> nodeNameMatcher() {
5151
return is("integTest-0");
5252
}
5353

54+
@SuppressWarnings("removal")
5455
@Override
5556
protected BufferedReader openReader(Path logFile) {
5657
assumeFalse("Skipping test because it is being run against an external cluster.",

plugins/discovery-azure-classic/src/internalClusterTest/java/org/opensearch/discovery/azure/classic/AzureDiscoveryClusterFormationTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ private static SSLContext getSSLContext() throws Exception {
296296
* The {@link HttpsServer} in the JDK has issues with TLSv1.3 when running in a JDK prior to
297297
* 12.0.1 so we pin to TLSv1.2 when running on an earlier JDK
298298
*/
299+
@SuppressWarnings("removal")
299300
private static String getProtocol() {
300301
if (Runtime.version().compareTo(Version.parse("12")) < 0) {
301302
return "TLSv1.2";

plugins/discovery-azure-classic/src/main/java/org/opensearch/cloud/azure/classic/management/AzureComputeServiceImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ private static String getRequiredSetting(Settings settings, Setting<String> sett
112112
return value;
113113
}
114114

115+
@SuppressWarnings("removal")
115116
@Override
116117
public HostedServiceGetDetailedResponse getServiceDetails() {
117118
SpecialPermission.check();

plugins/discovery-ec2/src/test/java/org/opensearch/discovery/ec2/Ec2NetworkTests.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ public static void startHttp() throws Exception {
8989
httpServer.start();
9090
}
9191

92+
@SuppressWarnings("removal")
9293
@Before
9394
public void setup() {
9495
// redirect EC2 metadata service to httpServer
@@ -116,6 +117,7 @@ public void testNetworkHostEc2() throws IOException {
116117
/**
117118
* Test for network.host: _ec2_
118119
*/
120+
@SuppressWarnings("removal")
119121
public void testNetworkHostUnableToResolveEc2() {
120122
// redirect EC2 metadata service to unknown location
121123
AccessController.doPrivileged(

plugins/discovery-gce/src/main/java/org/opensearch/cloud/gce/util/Access.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
* {@code connect}. This class wraps the operations requiring access in
4949
* {@link AccessController#doPrivileged(PrivilegedAction)} blocks.
5050
*/
51+
@SuppressWarnings("removal")
5152
public final class Access {
5253

5354
private Access() {}

plugins/ingest-attachment/src/main/java/org/opensearch/ingest/attachment/TikaImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ final class TikaImpl {
112112
/**
113113
* parses with tika, throwing any exception hit while parsing the document
114114
*/
115+
@SuppressWarnings("removal")
115116
static String parse(final byte content[], final Metadata metadata, final int limit) throws TikaException, IOException {
116117
// check that its not unprivileged code like a script
117118
SpecialPermission.check();
@@ -136,6 +137,7 @@ static String parse(final byte content[], final Metadata metadata, final int lim
136137

137138
// apply additional containment for parsers, this is intersected with the current permissions
138139
// its hairy, but worth it so we don't have some XML flaw reading random crap from the FS
140+
@SuppressWarnings("removal")
139141
private static final AccessControlContext RESTRICTED_CONTEXT = new AccessControlContext(
140142
new ProtectionDomain[] { new ProtectionDomain(null, getRestrictedPermissions()) }
141143
);

plugins/repository-azure/src/main/java/org/opensearch/repositories/azure/AzureStorageService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ private static class NioThreadFactory implements ThreadFactory {
389389
private final AtomicInteger threadNumber = new AtomicInteger(1);
390390
private final String namePrefix;
391391

392+
@SuppressWarnings("removal")
392393
NioThreadFactory() {
393394
SecurityManager s = System.getSecurityManager();
394395
group = (s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup();

plugins/repository-gcs/src/main/java/org/opensearch/repositories/gcs/GoogleCloudStorageRetryingInputStream.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ class GoogleCloudStorageRetryingInputStream extends InputStream {
107107
currentStream = openStream();
108108
}
109109

110+
@SuppressWarnings("removal")
110111
@SuppressForbidden(reason = "need access to storage client")
111112
private static com.google.api.services.storage.Storage getStorage(Storage client) {
112113
return AccessController.doPrivileged((PrivilegedAction<com.google.api.services.storage.Storage>) () -> {

plugins/repository-hdfs/src/main/java/org/opensearch/repositories/hdfs/HdfsPlugin.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import java.util.Collections;
5353
import java.util.Map;
5454

55+
@SuppressWarnings("removal")
5556
public final class HdfsPlugin extends Plugin implements RepositoryPlugin {
5657

5758
// initialize some problematic classes with elevated privileges

plugins/repository-hdfs/src/main/java/org/opensearch/repositories/hdfs/HdfsRepository.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ private static String getHostName() {
254254
}
255255
}
256256

257+
@SuppressWarnings("removal")
257258
@Override
258259
protected HdfsBlobStore createBlobStore() {
259260
// initialize our blobstore using elevated privileges.

plugins/repository-hdfs/src/main/java/org/opensearch/repositories/hdfs/HdfsSecurityContext.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
* Keeps track of the current user for a given repository, as well as which
5858
* permissions to grant the blob store restricted execution methods.
5959
*/
60+
@SuppressWarnings("removal")
6061
class HdfsSecurityContext {
6162

6263
private static final Permission[] SIMPLE_AUTH_PERMISSIONS;

plugins/repository-hdfs/src/test/java/org/opensearch/repositories/hdfs/HaHdfsFailoverTestSuiteIT.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
/**
6363
* Integration test that runs against an HA-Enabled HDFS instance
6464
*/
65+
@SuppressWarnings("removal")
6566
public class HaHdfsFailoverTestSuiteIT extends OpenSearchRestTestCase {
6667

6768
public void testHAFailoverWithRepository() throws Exception {

plugins/repository-hdfs/src/test/java/org/opensearch/repositories/hdfs/HdfsBlobStoreContainerTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
@ThreadLeakFilters(filters = { HdfsClientThreadLeakFilter.class })
6565
public class HdfsBlobStoreContainerTests extends OpenSearchTestCase {
6666

67+
@SuppressWarnings("removal")
6768
private FileContext createTestContext() {
6869
FileContext fileContext;
6970
try {

plugins/repository-s3/src/test/java/org/opensearch/repositories/s3/RepositoryCredentialsTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
import static org.hamcrest.Matchers.not;
7676
import static org.hamcrest.Matchers.notNullValue;
7777

78+
@SuppressWarnings("removal")
7879
@SuppressForbidden(reason = "test requires to set a System property to allow insecure settings when running in IDE")
7980
public class RepositoryCredentialsTests extends OpenSearchSingleNodeTestCase implements ConfigPathSupport {
8081

plugins/telemetry-otel/src/main/java/org/opensearch/telemetry/OTelTelemetrySettings.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ private OTelTelemetrySettings() {}
6666
/**
6767
* Span Exporter type setting.
6868
*/
69-
@SuppressWarnings("unchecked")
69+
@SuppressWarnings({ "unchecked", "removal" })
7070
public static final Setting<Class<SpanExporter>> OTEL_TRACER_SPAN_EXPORTER_CLASS_SETTING = new Setting<>(
7171
"telemetry.otel.tracer.span.exporter.class",
7272
LoggingSpanExporter.class.getName(),
@@ -90,7 +90,7 @@ private OTelTelemetrySettings() {}
9090
/**
9191
* Metrics Exporter type setting.
9292
*/
93-
@SuppressWarnings("unchecked")
93+
@SuppressWarnings({ "unchecked", "removal" })
9494
public static final Setting<Class<MetricExporter>> OTEL_METRICS_EXPORTER_CLASS_SETTING = new Setting<>(
9595
"telemetry.otel.metrics.exporter.class",
9696
LoggingMetricExporter.class.getName(),

plugins/telemetry-otel/src/main/java/org/opensearch/telemetry/metrics/OTelMetricsTelemetry.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public OTelMetricsTelemetry(RefCountedReleasable<OpenTelemetrySdk> openTelemetry
4242
this.otelMeter = meterProvider.get(OTelTelemetryPlugin.INSTRUMENTATION_SCOPE_NAME);
4343
}
4444

45+
@SuppressWarnings("removal")
4546
@Override
4647
public Counter createCounter(String name, String description, String unit) {
4748
DoubleCounter doubleCounter = AccessController.doPrivileged(
@@ -54,6 +55,7 @@ public Counter createCounter(String name, String description, String unit) {
5455
return new OTelCounter(doubleCounter);
5556
}
5657

58+
@SuppressWarnings("removal")
5759
@Override
5860
public Counter createUpDownCounter(String name, String description, String unit) {
5961
DoubleUpDownCounter doubleUpDownCounter = AccessController.doPrivileged(

plugins/telemetry-otel/src/main/java/org/opensearch/telemetry/metrics/exporter/OTelMetricsExporterFactory.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public static MetricExporter create(Settings settings) {
5151
return metricExporter;
5252
}
5353

54+
@SuppressWarnings("removal")
5455
private static MetricExporter instantiateExporter(Class<MetricExporter> exporterProviderClass) {
5556
try {
5657
// Check we ourselves are not being called by unprivileged code.

plugins/telemetry-otel/src/main/java/org/opensearch/telemetry/tracing/OTelResourceProvider.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ private OTelResourceProvider() {}
4848
* @param settings cluster settings
4949
* @return OpenTelemetrySdk instance
5050
*/
51+
@SuppressWarnings("removal")
5152
public static OpenTelemetrySdk get(TelemetrySettings telemetrySettings, Settings settings) {
5253
return AccessController.doPrivileged(
5354
(PrivilegedAction<OpenTelemetrySdk>) () -> get(

plugins/telemetry-otel/src/main/java/org/opensearch/telemetry/tracing/exporter/OTelSpanExporterFactory.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public static SpanExporter create(Settings settings) {
5151
return spanExporter;
5252
}
5353

54+
@SuppressWarnings("removal")
5455
private static SpanExporter instantiateSpanExporter(Class<SpanExporter> spanExporterProviderClass) {
5556
try {
5657
// Check we ourselves are not being called by unprivileged code.

qa/evil-tests/src/test/java/org/opensearch/bootstrap/OpenSearchPolicyUnitTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
* Unit tests for OpenSearchPolicy: these cannot run with security manager,
5151
* we don't allow messing with the policy
5252
*/
53+
@SuppressWarnings("removal")
5354
public class OpenSearchPolicyUnitTests extends OpenSearchTestCase {
5455
/**
5556
* Test policy with null codesource.

qa/evil-tests/src/test/java/org/opensearch/bootstrap/SystemCallFilterTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public class SystemCallFilterTests extends OpenSearchTestCase {
4141
/** command to try to run in tests */
4242
static final String EXECUTABLE = Constants.WINDOWS ? "calc" : "ls";
4343

44+
@SuppressWarnings("removal")
4445
@Override
4546
public void setUp() throws Exception {
4647
super.setUp();

qa/evil-tests/src/test/java/org/opensearch/plugins/PluginSecurityTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import static org.hamcrest.Matchers.containsInAnyOrder;
4242

4343
/** Tests plugin manager security check */
44+
@SuppressWarnings("removal")
4445
public class PluginSecurityTests extends OpenSearchTestCase {
4546

4647
/** Test that we can parse the set of permissions correctly for a simple policy */

qa/logging-config/src/test/java/org/opensearch/qa/custom_logging/CustomLoggingConfigIT.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public void testSuccessfulStartupWithCustomConfig() throws Exception {
6262
});
6363
}
6464

65+
@SuppressWarnings("removal")
6566
private List<String> readAllLines(Path logFile) {
6667
return AccessController.doPrivileged((PrivilegedAction<List<String>>) () -> {
6768
try {

qa/unconfigured-node-name/src/test/java/org/opensearch/unconfigured_node_name/JsonLogsFormatAndParseIT.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ protected Matcher<String> nodeNameMatcher() {
6161
return equalTo(HOSTNAME);
6262
}
6363

64+
@SuppressWarnings("removal")
6465
@Override
6566
protected BufferedReader openReader(Path logFile) {
6667
return AccessController.doPrivileged((PrivilegedAction<BufferedReader>) () -> {

0 commit comments

Comments
 (0)