Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-38784] Build the threadPoolExecutor in the right place
  • Loading branch information
fbelzunc committed Mar 3, 2017
1 parent 079bd37 commit 1f53b9d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 29 deletions.
Expand Up @@ -208,25 +208,6 @@ public class ActiveDirectorySecurityRealm extends AbstractPasswordBasedSecurityR

public transient String testSite;

/**
* The core pool size for the {@link ExecutorService}
*/
private static final int corePoolSize = Integer.parseInt(System.getProperty("hudson.plugins.active_directory.threadPoolExecutor.corePoolSize", "4"));

/**
* The max pool size for the {@link ExecutorService}
*/
private static final int maxPoolSize = Integer.parseInt(System.getProperty("hudson.plugins.active_directory.threadPoolExecutor.maxPoolSize", "8"));

/**
* The keep alive time for the {@link ExecutorService}
*/
private static final long keepAliveTime = Long.parseLong(System.getProperty("hudson.plugins.active_directory.threadPoolExecutor.keepAliveTime", "10000"));

/**
* The queue size for the {@link ExecutorService}
*/
private static final int queueSize = Integer.parseInt(System.getProperty("hudson.plugins.active_directory.threadPoolExecutor.queueSize", "25"));

public ActiveDirectorySecurityRealm(String domain, String site, String bindName, String bindPassword, String server) {
this(domain, site, bindName, bindPassword, server, GroupLookupStrategy.AUTO, false);
Expand Down Expand Up @@ -261,15 +242,6 @@ public ActiveDirectorySecurityRealm(String domain, List<ActiveDirectoryDomain> d
this.groupLookupStrategy = groupLookupStrategy;
this.removeIrrelevantGroups = removeIrrelevantGroups;
this.cache = cache;
this.threadPoolExecutor = new ThreadPoolExecutor(
corePoolSize,
maxPoolSize,
keepAliveTime,
TimeUnit.MILLISECONDS,
new ArrayBlockingQueue<Runnable>(queueSize),
new NamingThreadFactory(new DaemonThreadFactory(), "ActiveDirectory.updateUserCache"),
new ThreadPoolExecutor.DiscardPolicy()
);
}

@DataBoundSetter
Expand Down
Expand Up @@ -30,6 +30,8 @@
import hudson.security.GroupDetails;
import hudson.security.SecurityRealm;
import hudson.security.UserMayOrMayNotExistException;
import hudson.util.DaemonThreadFactory;
import hudson.util.NamingThreadFactory;
import hudson.util.Secret;

import javax.naming.NameNotFoundException;
Expand Down Expand Up @@ -135,6 +137,26 @@ public class ActiveDirectoryUnixAuthenticationProvider extends AbstractActiveDir
*/
private final static String LDAP_READ_TIMEOUT = "com.sun.jndi.ldap.read.timeout";

/**
* The core pool size for the {@link ExecutorService}
*/
private static final int corePoolSize = Integer.parseInt(System.getProperty("hudson.plugins.active_directory.threadPoolExecutor.corePoolSize", "4"));

/**
* The max pool size for the {@link ExecutorService}
*/
private static final int maxPoolSize = Integer.parseInt(System.getProperty("hudson.plugins.active_directory.threadPoolExecutor.maxPoolSize", "8"));

/**
* The keep alive time for the {@link ExecutorService}
*/
private static final long keepAliveTime = Long.parseLong(System.getProperty("hudson.plugins.active_directory.threadPoolExecutor.keepAliveTime", "10000"));

/**
* The queue size for the {@link ExecutorService}
*/
private static final int queueSize = Integer.parseInt(System.getProperty("hudson.plugins.active_directory.threadPoolExecutor.queueSize", "25"));

public ActiveDirectoryUnixAuthenticationProvider(ActiveDirectorySecurityRealm realm) {
this.site = realm.site;
this.domains = realm.domains;
Expand All @@ -154,7 +176,15 @@ public ActiveDirectoryUnixAuthenticationProvider(ActiveDirectorySecurityRealm re
this.userCache = cache.getUserCache();
this.groupCache = cache.getGroupCache();

this.threadPoolExecutor = realm.threadPoolExecutor;
this.threadPoolExecutor = new ThreadPoolExecutor(
corePoolSize,
maxPoolSize,
keepAliveTime,
TimeUnit.MILLISECONDS,
new ArrayBlockingQueue<Runnable>(queueSize),
new NamingThreadFactory(new DaemonThreadFactory(), "ActiveDirectory.updateUserCache"),
new ThreadPoolExecutor.DiscardPolicy()
);

Map<String, String> extraEnvVarsMap = ActiveDirectorySecurityRealm.EnvironmentProperty.toMap(realm.environmentProperties);
// TODO In JDK 8u65 I am facing JDK-8139721, JDK-8139942 which makes the plugin to break. Uncomment line once it is fixed.
Expand Down

0 comments on commit 1f53b9d

Please sign in to comment.