Skip to content

Commit

Permalink
Fix Exception in HystrixThreadPoolDefault.touchConfig() on Java 11
Browse files Browse the repository at this point in the history
Java 11 ThreadPoolExecutor.setCorePoolSize() throws an IllegalArgumentException if the new coreSize is larger than the current maximumPoolSize.
Similarly, setMaximumPoolSize() throws an exception if the new value is less than the current coreSize.
  • Loading branch information
michaelnelson123 committed Nov 12, 2022
1 parent 3cb2158 commit c03a389
Showing 1 changed file with 8 additions and 2 deletions.
Expand Up @@ -227,8 +227,14 @@ private void touchConfig() {
dynamicCoreSize + " and maximumSize = " + configuredMaximumSize + ". Maximum size will be set to " +
dynamicMaximumSize + ", the coreSize value, since it must be equal to or greater than the coreSize value");
}
threadPool.setCorePoolSize(dynamicCoreSize);
threadPool.setMaximumPoolSize(dynamicMaximumSize);
// In JDK 11, setCorePoolSize will not allow a value greater than the current maximumPoolSize and setMaximumPoolSize has a similar restriction.
if (dynamicCoreSize <= threadPool.getMaximumPoolSize()) {
threadPool.setCorePoolSize(dynamicCoreSize);
threadPool.setMaximumPoolSize(dynamicMaximumSize);
} else {
threadPool.setMaximumPoolSize(dynamicMaximumSize);
threadPool.setCorePoolSize(dynamicCoreSize);
}
}

threadPool.setKeepAliveTime(properties.keepAliveTimeMinutes().get(), TimeUnit.MINUTES);
Expand Down

0 comments on commit c03a389

Please sign in to comment.