Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed ThreadPoolExecutor setCorePoolSize implementation on Java 10+ #1874

Open
daf182 opened this issue Oct 27, 2018 · 4 comments
Open

Changed ThreadPoolExecutor setCorePoolSize implementation on Java 10+ #1874

daf182 opened this issue Oct 27, 2018 · 4 comments

Comments

@daf182
Copy link

daf182 commented Oct 27, 2018

On OpenJdk 11 the implementation of ThreadPoolExecutor's setCorePoolSize was changed and contains an additional constraints comparing the maxPoolSize and corePoolSize values.

If maxPoolSize is not changed but corePoolSize is given as a higher number of default maxPoolSize it throws IllegalArgumentException.

This causes issue here:
https://github.com/Netflix/Hystrix/blob/master/hystrix-core/src/main/java/com/netflix/hystrix/HystrixThreadPool.java#L230-L231

@daf182 daf182 changed the title Changed ThreadPoolExecutor setCorePoolSizeImplementation Changed ThreadPoolExecutor setCorePoolSize implementation Oct 27, 2018
@daf182 daf182 changed the title Changed ThreadPoolExecutor setCorePoolSize implementation Changed ThreadPoolExecutor setCorePoolSize implementation on Java 10+ Oct 29, 2018
@andystanton
Copy link

Looks like it's Java 9+.

From the Java 8 API docs for ThreadPoolExecutor#setCorePoolSize:

Throws:
IllegalArgumentException - if corePoolSize < 0

From the Java 9 API docs for ThreadPoolExecutor#setCorePoolSize:

Throws:
IllegalArgumentException - if corePoolSize < 0 or corePoolSize is greater than the maximum pool size

Here's a minimal example - it can be triggered if the core size is changed through Archaius:

@Test
void simplestTest() throws Exception {
    var command = new HystrixCommand<>(HystrixCommand.Setter
            .withGroupKey(HystrixCommandGroupKey.Factory.asKey("Group"))
            .andCommandKey(HystrixCommandKey.Factory.asKey("Command"))) {
        @Override
        protected String run() throws Exception {
            return null;
        }
    };
    // ConfigurationManager is from Archaius
    ConfigurationManager.getConfigInstance().setProperty("hystrix.threadpool.Group.coreSize", 11);
    command.execute();
}

This exception is thrown when the command is executed:

com.netflix.hystrix.exception.HystrixRuntimeException: Command failed while executing.
...
Caused by: java.lang.IllegalArgumentException
	at java.base/java.util.concurrent.ThreadPoolExecutor.setCorePoolSize(ThreadPoolExecutor.java:1535)
	at com.netflix.hystrix.HystrixThreadPool$HystrixThreadPoolDefault.touchConfig(HystrixThreadPool.java:230)
	at com.netflix.hystrix.HystrixThreadPool$HystrixThreadPoolDefault.getScheduler(HystrixThreadPool.java:205)

@DanieleCali
Copy link

The Hystrix documentation here: https://github.com/Netflix/Hystrix/wiki/Configuration#maximumSize
it says you can't modify the maximumSize hystrix property if you don't set the allowMaximumSizeToDivergeFromCoreSize to true.
setting this property to true you are able to have different values for the core pool size and the maximum pool size.

@Fival85
Copy link

Fival85 commented May 20, 2020

The issue appears also when you set the coresize greater then the default maximum size, because of a failed implementation of the HystrixThreadPool class. The error appears, because firstly the core size is set and after this the maximus size of the threadpool. At the moment when the core size is set and it is bigger then the default size (10) the IllegalArgumentException is thrown.

In this case you could set allowMaximumSizeToDivergeFromCoreSize as you like. It doesnt fix the error!

tweimer added a commit to tweimer/Hystrix that referenced this issue Nov 1, 2021
@xinxin2015
Copy link

xinxin2015 commented May 26, 2022

I meet this issue also,but how can I replay this issue,no one would write 'ConfigurationManager.getConfigInstance().setProperty("hystrix.threadpool.Group.coreSize", 11);' such code in application,anywhere interface to modify the properties?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants