diff --git a/infra/common/src/test/java/cn/hippo4j/common/executor/support/ThreadPoolExecutorUtilTest.java b/infra/common/src/test/java/cn/hippo4j/common/executor/support/ThreadPoolExecutorUtilTest.java index 97383037..88f523bb 100644 --- a/infra/common/src/test/java/cn/hippo4j/common/executor/support/ThreadPoolExecutorUtilTest.java +++ b/infra/common/src/test/java/cn/hippo4j/common/executor/support/ThreadPoolExecutorUtilTest.java @@ -45,12 +45,11 @@ public class ThreadPoolExecutorUtilTest { maxPoolSize, 1L, TimeUnit.SECONDS, - new ArrayBlockingQueue<>(10) - ); + new ArrayBlockingQueue<>(10)); } @Test - public void testEquals(){ + public void testEquals() { // Test when the new core pool size equals the original maximum pool size. int newCorePoolSize1 = maxPoolSize; int newMaxPoolSize1 = 6; @@ -60,7 +59,7 @@ public class ThreadPoolExecutorUtilTest { } @Test - public void testGreater(){ + public void testGreater() { // Test when the new core pool size is greater than the original maximum pool size. int newCorePoolSize2 = 8; int newMaxPoolSize2 = 10; @@ -70,7 +69,7 @@ public class ThreadPoolExecutorUtilTest { } @Test - public void testLess(){ + public void testLess() { // Test when the new core pool size is less than the original maximum pool size. int newCorePoolSize3 = 3; int newMaxPoolSize3 = 5; @@ -80,7 +79,7 @@ public class ThreadPoolExecutorUtilTest { } @Test - public void testException(){ + public void testException() { // Test when the new core pool size is greater than the new maximum pool size, which should throw an IllegalArgumentException. int newCorePoolSize4 = 6; int newMaxPoolSize4 = 4; @@ -89,7 +88,7 @@ public class ThreadPoolExecutorUtilTest { } catch (IllegalArgumentException e) { // Expected to throw an exception. Assert.assertEquals("newCorePoolSize must be smaller than newMaximumPoolSize", e.getMessage()); - log.error("newCorePoolSize must be smaller than newMaximumPoolSize;{}",e.getMessage()); + log.error("newCorePoolSize must be smaller than newMaximumPoolSize;{}", e.getMessage()); } } } diff --git a/starters/threadpool/monitor/hippo4j-spring-boot-starter-monitor-micrometer/src/main/java/cn/hippo4j/springboot/starter/monitor/micrometer/MicrometerMonitorAutoConfiguration.java b/starters/threadpool/monitor/hippo4j-spring-boot-starter-monitor-micrometer/src/main/java/cn/hippo4j/springboot/starter/monitor/micrometer/MicrometerMonitorAutoConfiguration.java index 1eb7b70b..73834bb8 100644 --- a/starters/threadpool/monitor/hippo4j-spring-boot-starter-monitor-micrometer/src/main/java/cn/hippo4j/springboot/starter/monitor/micrometer/MicrometerMonitorAutoConfiguration.java +++ b/starters/threadpool/monitor/hippo4j-spring-boot-starter-monitor-micrometer/src/main/java/cn/hippo4j/springboot/starter/monitor/micrometer/MicrometerMonitorAutoConfiguration.java @@ -27,7 +27,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.boot.autoconfigure.AutoConfigureBefore; /** * Micrometer monitor auto configuration. diff --git a/starters/threadpool/server/src/main/java/cn/hippo4j/springboot/starter/support/AdaptedThreadPoolDestroyPostProcessor.java b/starters/threadpool/server/src/main/java/cn/hippo4j/springboot/starter/support/AdaptedThreadPoolDestroyPostProcessor.java index ce425560..9b60a4f6 100644 --- a/starters/threadpool/server/src/main/java/cn/hippo4j/springboot/starter/support/AdaptedThreadPoolDestroyPostProcessor.java +++ b/starters/threadpool/server/src/main/java/cn/hippo4j/springboot/starter/support/AdaptedThreadPoolDestroyPostProcessor.java @@ -81,14 +81,14 @@ public class AdaptedThreadPoolDestroyPostProcessor implements DestructionAwareBe @Override public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { // forked default implementation from spring-beans-5.1.14.RELEASE.jar - // org.springframework.beans.factory.config.BeanPostProcessor#postProcessBeforeInitialization + // org.springframework.beans.factory.config.BeanPostProcessor#postProcessBeforeInitialization return bean; } @Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { // forked default implementation from spring-beans-5.1.14.RELEASE.jar - // org.springframework.beans.factory.config.BeanPostProcessor#postProcessAfterInitialization + // org.springframework.beans.factory.config.BeanPostProcessor#postProcessAfterInitialization return bean; } diff --git a/threadpool/monitor/micrometer/src/main/java/cn/hippo4j/monitor/micrometer/AdapterThreadPoolMicrometerMonitorHandler.java b/threadpool/monitor/micrometer/src/main/java/cn/hippo4j/monitor/micrometer/AdapterThreadPoolMicrometerMonitorHandler.java index ea993663..fe28dc21 100644 --- a/threadpool/monitor/micrometer/src/main/java/cn/hippo4j/monitor/micrometer/AdapterThreadPoolMicrometerMonitorHandler.java +++ b/threadpool/monitor/micrometer/src/main/java/cn/hippo4j/monitor/micrometer/AdapterThreadPoolMicrometerMonitorHandler.java @@ -58,7 +58,9 @@ public class AdapterThreadPoolMicrometerMonitorHandler extends AbstractAdapterTh Tag.of(APPLICATION_NAME_TAG, applicationName)); Metrics.gauge(metricName("core.size"), tags, threadPoolAdapterState, ThreadPoolAdapterState::getCoreSize); Metrics.gauge(metricName("maximum.size"), tags, threadPoolAdapterState, ThreadPoolAdapterState::getMaximumSize); - Metrics.gauge(metricName("queue.capacity"), tags, threadPoolAdapterState, ThreadPoolAdapterState::getBlockingQueueCapacity); + if (threadPoolAdapterState.getBlockingQueueCapacity() != null) { + Metrics.gauge(metricName("queue.capacity"), tags, threadPoolAdapterState, ThreadPoolAdapterState::getBlockingQueueCapacity); + } } private String metricName(String name) { diff --git a/threadpool/server/common/src/test/java/cn/hippo4j/server/common/base/ServiceExceptionTest.java b/threadpool/server/common/src/test/java/cn/hippo4j/server/common/base/ServiceExceptionTest.java index fc55129b..833afe1b 100644 --- a/threadpool/server/common/src/test/java/cn/hippo4j/server/common/base/ServiceExceptionTest.java +++ b/threadpool/server/common/src/test/java/cn/hippo4j/server/common/base/ServiceExceptionTest.java @@ -32,14 +32,14 @@ import java.util.Objects; public class ServiceExceptionTest { @Test - public void ServiceExceptionTest1(){ + public void ServiceExceptionTest1() { ServiceException serviceException = new ServiceException(); Assert.isTrue(Objects.equals(serviceException.getErrorCode().getCode(), "3")); Assert.isTrue(Objects.equals(serviceException.getMessage(), "SERVICE_ERROR")); } @Test - public void ServiceExceptionTest2(){ + public void ServiceExceptionTest2() { ErrorCode errorCode = ErrorCodeEnum.LOGIN_TIMEOUT; ServiceException serviceException = new ServiceException(errorCode); Assert.isTrue(Objects.equals(serviceException.getErrorCode().getCode(), ErrorCodeEnum.LOGIN_TIMEOUT.getCode())); @@ -47,21 +47,21 @@ public class ServiceExceptionTest { } @Test - public void ServiceExceptionTest3(){ + public void ServiceExceptionTest3() { String message = ErrorCodeEnum.SERVICE_ERROR.getMessage(); ServiceException serviceException = new ServiceException(message); Assert.isTrue(Objects.equals(serviceException.getMessage(), message)); } @Test - public void ServiceExceptionTest4(){ + public void ServiceExceptionTest4() { Throwable cause = new Throwable(); ServiceException serviceException = new ServiceException(cause); Assert.isTrue(Objects.equals(serviceException.getCause().getMessage(), cause.getMessage())); } @Test - public void ServiceExceptionTest5(){ + public void ServiceExceptionTest5() { String message = ErrorCodeEnum.SERVICE_ERROR.getMessage(); Throwable cause = new Throwable(); ServiceException serviceException = new ServiceException(message, cause); @@ -70,7 +70,7 @@ public class ServiceExceptionTest { } @Test - public void ServiceExceptionTest6(){ + public void ServiceExceptionTest6() { String message = ErrorCodeEnum.SERVICE_ERROR.getMessage(); Throwable cause = new Throwable(); ServiceException serviceException = new ServiceException(cause, message); @@ -79,7 +79,7 @@ public class ServiceExceptionTest { } @Test - public void ServiceExceptionTest7(){ + public void ServiceExceptionTest7() { Throwable cause = new Throwable(); ErrorCode errorCode = ErrorCodeEnum.LOGIN_TIMEOUT; ServiceException serviceException = new ServiceException(cause, errorCode); @@ -88,7 +88,7 @@ public class ServiceExceptionTest { } @Test - public void ServiceExceptionTest8(){ + public void ServiceExceptionTest8() { Throwable cause = new Throwable(); ErrorCode errorCode = ErrorCodeEnum.LOGIN_TIMEOUT; String message = ErrorCodeEnum.SERVICE_ERROR.getMessage();