Skip to content

Commit

Permalink
Add @SuppressWarnings("removal") to not fail the build with -Werror f…
Browse files Browse the repository at this point in the history
…or some JDKs (opensearch-project#11931)

Signed-off-by: Andriy Redko <[email protected]>
  • Loading branch information
reta authored and rayshrey committed Mar 18, 2024
1 parent 269482f commit a34fc99
Show file tree
Hide file tree
Showing 24 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ protected Matcher<String> nodeNameMatcher() {
return is("integTest-0");
}

@SuppressWarnings("removal")
@Override
protected BufferedReader openReader(Path logFile) {
assumeFalse("Skipping test because it is being run against an external cluster.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ private static SSLContext getSSLContext() throws Exception {
* The {@link HttpsServer} in the JDK has issues with TLSv1.3 when running in a JDK prior to
* 12.0.1 so we pin to TLSv1.2 when running on an earlier JDK
*/
@SuppressWarnings("removal")
private static String getProtocol() {
if (Runtime.version().compareTo(Version.parse("12")) < 0) {
return "TLSv1.2";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ private static String getRequiredSetting(Settings settings, Setting<String> sett
return value;
}

@SuppressWarnings("removal")
@Override
public HostedServiceGetDetailedResponse getServiceDetails() {
SpecialPermission.check();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public static void startHttp() throws Exception {
httpServer.start();
}

@SuppressWarnings("removal")
@Before
public void setup() {
// redirect EC2 metadata service to httpServer
Expand Down Expand Up @@ -116,6 +117,7 @@ public void testNetworkHostEc2() throws IOException {
/**
* Test for network.host: _ec2_
*/
@SuppressWarnings("removal")
public void testNetworkHostUnableToResolveEc2() {
// redirect EC2 metadata service to unknown location
AccessController.doPrivileged(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
* {@code connect}. This class wraps the operations requiring access in
* {@link AccessController#doPrivileged(PrivilegedAction)} blocks.
*/
@SuppressWarnings("removal")
public final class Access {

private Access() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ final class TikaImpl {
/**
* parses with tika, throwing any exception hit while parsing the document
*/
@SuppressWarnings("removal")
static String parse(final byte content[], final Metadata metadata, final int limit) throws TikaException, IOException {
// check that its not unprivileged code like a script
SpecialPermission.check();
Expand All @@ -136,6 +137,7 @@ static String parse(final byte content[], final Metadata metadata, final int lim

// apply additional containment for parsers, this is intersected with the current permissions
// its hairy, but worth it so we don't have some XML flaw reading random crap from the FS
@SuppressWarnings("removal")
private static final AccessControlContext RESTRICTED_CONTEXT = new AccessControlContext(
new ProtectionDomain[] { new ProtectionDomain(null, getRestrictedPermissions()) }
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ private static class NioThreadFactory implements ThreadFactory {
private final AtomicInteger threadNumber = new AtomicInteger(1);
private final String namePrefix;

@SuppressWarnings("removal")
NioThreadFactory() {
SecurityManager s = System.getSecurityManager();
group = (s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class GoogleCloudStorageRetryingInputStream extends InputStream {
currentStream = openStream();
}

@SuppressWarnings("removal")
@SuppressForbidden(reason = "need access to storage client")
private static com.google.api.services.storage.Storage getStorage(Storage client) {
return AccessController.doPrivileged((PrivilegedAction<com.google.api.services.storage.Storage>) () -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import java.util.Collections;
import java.util.Map;

@SuppressWarnings("removal")
public final class HdfsPlugin extends Plugin implements RepositoryPlugin {

// initialize some problematic classes with elevated privileges
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ private static String getHostName() {
}
}

@SuppressWarnings("removal")
@Override
protected HdfsBlobStore createBlobStore() {
// initialize our blobstore using elevated privileges.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
* Keeps track of the current user for a given repository, as well as which
* permissions to grant the blob store restricted execution methods.
*/
@SuppressWarnings("removal")
class HdfsSecurityContext {

private static final Permission[] SIMPLE_AUTH_PERMISSIONS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
/**
* Integration test that runs against an HA-Enabled HDFS instance
*/
@SuppressWarnings("removal")
public class HaHdfsFailoverTestSuiteIT extends OpenSearchRestTestCase {

public void testHAFailoverWithRepository() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
@ThreadLeakFilters(filters = { HdfsClientThreadLeakFilter.class })
public class HdfsBlobStoreContainerTests extends OpenSearchTestCase {

@SuppressWarnings("removal")
private FileContext createTestContext() {
FileContext fileContext;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.notNullValue;

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private OTelTelemetrySettings() {}
/**
* Span Exporter type setting.
*/
@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked", "removal" })
public static final Setting<Class<SpanExporter>> OTEL_TRACER_SPAN_EXPORTER_CLASS_SETTING = new Setting<>(
"telemetry.otel.tracer.span.exporter.class",
LoggingSpanExporter.class.getName(),
Expand All @@ -90,7 +90,7 @@ private OTelTelemetrySettings() {}
/**
* Metrics Exporter type setting.
*/
@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked", "removal" })
public static final Setting<Class<MetricExporter>> OTEL_METRICS_EXPORTER_CLASS_SETTING = new Setting<>(
"telemetry.otel.metrics.exporter.class",
LoggingMetricExporter.class.getName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public OTelMetricsTelemetry(RefCountedReleasable<OpenTelemetrySdk> openTelemetry
this.otelMeter = meterProvider.get(OTelTelemetryPlugin.INSTRUMENTATION_SCOPE_NAME);
}

@SuppressWarnings("removal")
@Override
public Counter createCounter(String name, String description, String unit) {
DoubleCounter doubleCounter = AccessController.doPrivileged(
Expand All @@ -54,6 +55,7 @@ public Counter createCounter(String name, String description, String unit) {
return new OTelCounter(doubleCounter);
}

@SuppressWarnings("removal")
@Override
public Counter createUpDownCounter(String name, String description, String unit) {
DoubleUpDownCounter doubleUpDownCounter = AccessController.doPrivileged(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public static MetricExporter create(Settings settings) {
return metricExporter;
}

@SuppressWarnings("removal")
private static MetricExporter instantiateExporter(Class<MetricExporter> exporterProviderClass) {
try {
// Check we ourselves are not being called by unprivileged code.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ private OTelResourceProvider() {}
* @param settings cluster settings
* @return OpenTelemetrySdk instance
*/
@SuppressWarnings("removal")
public static OpenTelemetrySdk get(TelemetrySettings telemetrySettings, Settings settings) {
return AccessController.doPrivileged(
(PrivilegedAction<OpenTelemetrySdk>) () -> get(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public static SpanExporter create(Settings settings) {
return spanExporter;
}

@SuppressWarnings("removal")
private static SpanExporter instantiateSpanExporter(Class<SpanExporter> spanExporterProviderClass) {
try {
// Check we ourselves are not being called by unprivileged code.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
* Unit tests for OpenSearchPolicy: these cannot run with security manager,
* we don't allow messing with the policy
*/
@SuppressWarnings("removal")
public class OpenSearchPolicyUnitTests extends OpenSearchTestCase {
/**
* Test policy with null codesource.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class SystemCallFilterTests extends OpenSearchTestCase {
/** command to try to run in tests */
static final String EXECUTABLE = Constants.WINDOWS ? "calc" : "ls";

@SuppressWarnings("removal")
@Override
public void setUp() throws Exception {
super.setUp();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import static org.hamcrest.Matchers.containsInAnyOrder;

/** Tests plugin manager security check */
@SuppressWarnings("removal")
public class PluginSecurityTests extends OpenSearchTestCase {

/** Test that we can parse the set of permissions correctly for a simple policy */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public void testSuccessfulStartupWithCustomConfig() throws Exception {
});
}

@SuppressWarnings("removal")
private List<String> readAllLines(Path logFile) {
return AccessController.doPrivileged((PrivilegedAction<List<String>>) () -> {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ protected Matcher<String> nodeNameMatcher() {
return equalTo(HOSTNAME);
}

@SuppressWarnings("removal")
@Override
protected BufferedReader openReader(Path logFile) {
return AccessController.doPrivileged((PrivilegedAction<BufferedReader>) () -> {
Expand Down

0 comments on commit a34fc99

Please sign in to comment.