From e1dc839590f61da7e22e83aefc3922b0a0132cce Mon Sep 17 00:00:00 2001 From: rblazquez Date: Fri, 5 Feb 2021 09:38:18 +0100 Subject: [PATCH] FRWK-673 Fixed chaning the thead pool sizing for Java9+ --- build.gradle | 32 +++++++++++++++++-- .../netflix/hystrix/HystrixThreadPool.java | 13 ++++++-- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index 15e60a933..db61cd7f1 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,13 @@ buildscript { } plugins { - id 'nebula.netflixoss' version '3.4.0' +// id 'nebula.netflixoss' version '3.4.0' + id 'nebula.maven-publish' version '4.9.1' + id 'nebula.release' version '4.1.0' + id 'nebula.dependency-lock' version '4.3.0' + id 'nebula.info' version '3.2.1' + id 'idea' + id 'eclipse' id 'me.champeau.gradle.jmh' version '0.3.1' id 'net.saliman.cobertura' version '2.2.8' } @@ -17,6 +23,8 @@ ext { githubProjectName = rootProject.name } +group = "com.netflix" + allprojects { repositories { jcenter() @@ -26,8 +34,14 @@ allprojects { } subprojects { - apply plugin: 'nebula.netflixoss' apply plugin: 'java' + apply plugin: 'idea' + apply plugin: 'eclipse' + apply plugin: 'nebula.maven-publish' + apply plugin: 'nebula.release' + apply plugin: 'nebula.source-jar' + apply plugin: 'nebula.dependency-lock' + apply plugin: 'nebula.info' apply plugin: 'nebula.provided-base' apply plugin: 'nebula.compile-api' @@ -53,4 +67,18 @@ subprojects { scopes.COMPILE.plus += [configurations.provided] } } + + publishing { + repositories { + maven { + def releasesRepoUrl = "https://nexusng.tuenti.io/repository/maven-release-private/" + def snapshotsRepoUrl = "https://nexusng.tuenti.io/repository/maven-snapshot-private/" + url = version.toString().contains("SNAPSHOT") ? snapshotsRepoUrl : releasesRepoUrl + credentials { + username = System.getenv "NEXUS_USER" + password = System.getenv "NEXUS_PASS" + } + } + } + } } diff --git a/hystrix-core/src/main/java/com/netflix/hystrix/HystrixThreadPool.java b/hystrix-core/src/main/java/com/netflix/hystrix/HystrixThreadPool.java index c68641dbf..972f0d71a 100644 --- a/hystrix-core/src/main/java/com/netflix/hystrix/HystrixThreadPool.java +++ b/hystrix-core/src/main/java/com/netflix/hystrix/HystrixThreadPool.java @@ -221,14 +221,21 @@ private void touchConfig() { } // In JDK 6, setCorePoolSize and setMaximumPoolSize will execute a lock operation. Avoid them if the pool size is not changed. - if (threadPool.getCorePoolSize() != dynamicCoreSize || (allowSizesToDiverge && threadPool.getMaximumPoolSize() != dynamicMaximumSize)) { + int currentMaxPoolSize = threadPool.getMaximumPoolSize(); + if (threadPool.getCorePoolSize() != dynamicCoreSize || (allowSizesToDiverge && currentMaxPoolSize != dynamicMaximumSize)) { if (maxTooLow) { logger.error("Hystrix ThreadPool configuration for : " + metrics.getThreadPoolKey().name() + " is trying to set coreSize = " + 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 Java9+ the condition corePoolSize <= maximumPoolSize should be always true + if (dynamicCoreSize > currentMaxPoolSize) { + threadPool.setMaximumPoolSize(dynamicMaximumSize); + threadPool.setCorePoolSize(dynamicCoreSize); + } else { + threadPool.setCorePoolSize(dynamicCoreSize); + threadPool.setMaximumPoolSize(dynamicMaximumSize); + } } threadPool.setKeepAliveTime(properties.keepAliveTimeMinutes().get(), TimeUnit.MINUTES);