Skip to content

Commit

Permalink
No need to explicit use the AccessController when SystemPropertyUtil …
Browse files Browse the repository at this point in the history
…is used (netty#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
  • Loading branch information
normanmaurer committed Sep 19, 2019
1 parent 57e0481 commit 2fe2a15
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
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
Expand Down Expand Up @@ -103,12 +101,7 @@ private static final class DefaultResourceLeakDetectorFactory extends ResourceLe
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@
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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -170,12 +162,7 @@ public ApplicationProtocolConfig.SelectedListenerFailureBehavior selectedListene
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);
Expand Down

0 comments on commit 2fe2a15

Please sign in to comment.