No need to explicit use the AccessController when SystemPropertyUtil is used (#9577)

Motivation:

SystemPropertyUtil already uses the AccessController internally so not need to wrap its usage with AccessController as well.

Modifications:

Remove explicit AccessController usage when SystemPropertyUtil is used.

Result:

Code cleanup
This commit is contained in:
Norman Maurer 2019-09-19 08:41:27 +02:00 committed by GitHub
parent 57e048147b
commit 2fe2a15593
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 25 deletions

View File

@ -23,8 +23,6 @@ import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory;
import java.lang.reflect.Constructor;
import java.security.AccessController;
import java.security.PrivilegedAction;
/**
* This static factory should be used to load {@link ResourceLeakDetector}s as needed
@ -103,12 +101,7 @@ public abstract class ResourceLeakDetectorFactory {
DefaultResourceLeakDetectorFactory() {
String customLeakDetector;
try {
customLeakDetector = AccessController.doPrivileged(new PrivilegedAction<String>() {
@Override
public String run() {
return SystemPropertyUtil.get("io.netty.customResourceLeakDetector");
}
});
customLeakDetector = SystemPropertyUtil.get("io.netty.customResourceLeakDetector");
} catch (Throwable cause) {
logger.error("Could not access System property: io.netty.customResourceLeakDetector", cause);
customLeakDetector = null;

View File

@ -34,9 +34,7 @@ import io.netty.util.internal.UnstableApi;
import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory;
import java.security.AccessController;
import java.security.PrivateKey;
import java.security.PrivilegedAction;
import java.security.SignatureException;
import java.security.cert.CertPathValidatorException;
import java.security.cert.Certificate;
@ -81,15 +79,9 @@ public abstract class ReferenceCountedOpenSslContext extends SslContext implemen
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(ReferenceCountedOpenSslContext.class);
private static final int DEFAULT_BIO_NON_APPLICATION_BUFFER_SIZE =
AccessController.doPrivileged(new PrivilegedAction<Integer>() {
@Override
public Integer run() {
return Math.max(1,
SystemPropertyUtil.getInt("io.netty.handler.ssl.openssl.bioNonApplicationBufferSize",
2048));
}
});
private static final int DEFAULT_BIO_NON_APPLICATION_BUFFER_SIZE = Math.max(1,
SystemPropertyUtil.getInt("io.netty.handler.ssl.openssl.bioNonApplicationBufferSize",
2048));
static final boolean USE_TASKS =
SystemPropertyUtil.getBoolean("io.netty.handler.ssl.openssl.useTasks", false);
private static final Integer DH_KEY_LENGTH;
@ -170,12 +162,7 @@ public abstract class ReferenceCountedOpenSslContext extends SslContext implemen
Integer dhLen = null;
try {
String dhKeySize = AccessController.doPrivileged(new PrivilegedAction<String>() {
@Override
public String run() {
return SystemPropertyUtil.get("jdk.tls.ephemeralDHKeySize");
}
});
String dhKeySize = SystemPropertyUtil.get("jdk.tls.ephemeralDHKeySize");
if (dhKeySize != null) {
try {
dhLen = Integer.valueOf(dhKeySize);