forked from External/mage
make jboss remoting2 work with openjdk11
This commit is contained in:
parent
a91b210456
commit
f36792be93
5 changed files with 61 additions and 29 deletions
32
Mage.Common/src/main/java/mage/remote/CustomThreadPool.java
Normal file
32
Mage.Common/src/main/java/mage/remote/CustomThreadPool.java
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
package mage.remote;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.jboss.util.threadpool.BasicThreadPool;
|
||||
|
||||
public class CustomThreadPool extends BasicThreadPool {
|
||||
private static final Logger logger = Logger.getLogger(SessionImpl.class);
|
||||
|
||||
@Override
|
||||
public void setMaximumPoolSize(int size) {
|
||||
/*
|
||||
* I really don't want to implement a whole new threadpool
|
||||
* just to fix this and the executor is private
|
||||
*/
|
||||
try {
|
||||
Field executorField = BasicThreadPool.class.getField("executor");
|
||||
executorField.setAccessible(true);
|
||||
ThreadPoolExecutor executor = (ThreadPoolExecutor) executorField.get(this);
|
||||
synchronized (executor) {
|
||||
executor.setMaximumPoolSize(size);
|
||||
executor.setCorePoolSize(size);
|
||||
}
|
||||
} catch (NoSuchFieldException | SecurityException e) {
|
||||
logger.error("Failed to get field executor from BasicThreadPool", e);
|
||||
} catch (IllegalArgumentException | IllegalAccessException e) {
|
||||
logger.error("Failed to get executor object from BasicThreadPool", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue