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 io.netty.util.internal.logging.InternalLoggerFactory;
import java.lang.reflect.Constructor; 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 * This static factory should be used to load {@link ResourceLeakDetector}s as needed
@ -103,12 +101,7 @@ public abstract class ResourceLeakDetectorFactory {
DefaultResourceLeakDetectorFactory() { DefaultResourceLeakDetectorFactory() {
String customLeakDetector; String customLeakDetector;
try { try {
customLeakDetector = AccessController.doPrivileged(new PrivilegedAction<String>() { customLeakDetector = SystemPropertyUtil.get("io.netty.customResourceLeakDetector");
@Override
public String run() {
return SystemPropertyUtil.get("io.netty.customResourceLeakDetector");
}
});
} catch (Throwable cause) { } catch (Throwable cause) {
logger.error("Could not access System property: io.netty.customResourceLeakDetector", cause); logger.error("Could not access System property: io.netty.customResourceLeakDetector", cause);
customLeakDetector = null; 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.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory; import io.netty.util.internal.logging.InternalLoggerFactory;
import java.security.AccessController;
import java.security.PrivateKey; import java.security.PrivateKey;
import java.security.PrivilegedAction;
import java.security.SignatureException; import java.security.SignatureException;
import java.security.cert.CertPathValidatorException; import java.security.cert.CertPathValidatorException;
import java.security.cert.Certificate; import java.security.cert.Certificate;
@ -81,15 +79,9 @@ public abstract class ReferenceCountedOpenSslContext extends SslContext implemen
private static final InternalLogger logger = private static final InternalLogger logger =
InternalLoggerFactory.getInstance(ReferenceCountedOpenSslContext.class); InternalLoggerFactory.getInstance(ReferenceCountedOpenSslContext.class);
private static final int DEFAULT_BIO_NON_APPLICATION_BUFFER_SIZE = private static final int DEFAULT_BIO_NON_APPLICATION_BUFFER_SIZE = Math.max(1,
AccessController.doPrivileged(new PrivilegedAction<Integer>() { SystemPropertyUtil.getInt("io.netty.handler.ssl.openssl.bioNonApplicationBufferSize",
@Override 2048));
public Integer run() {
return Math.max(1,
SystemPropertyUtil.getInt("io.netty.handler.ssl.openssl.bioNonApplicationBufferSize",
2048));
}
});
static final boolean USE_TASKS = static final boolean USE_TASKS =
SystemPropertyUtil.getBoolean("io.netty.handler.ssl.openssl.useTasks", false); SystemPropertyUtil.getBoolean("io.netty.handler.ssl.openssl.useTasks", false);
private static final Integer DH_KEY_LENGTH; private static final Integer DH_KEY_LENGTH;
@ -170,12 +162,7 @@ public abstract class ReferenceCountedOpenSslContext extends SslContext implemen
Integer dhLen = null; Integer dhLen = null;
try { try {
String dhKeySize = AccessController.doPrivileged(new PrivilegedAction<String>() { String dhKeySize = SystemPropertyUtil.get("jdk.tls.ephemeralDHKeySize");
@Override
public String run() {
return SystemPropertyUtil.get("jdk.tls.ephemeralDHKeySize");
}
});
if (dhKeySize != null) { if (dhKeySize != null) {
try { try {
dhLen = Integer.valueOf(dhKeySize); dhLen = Integer.valueOf(dhKeySize);