@EnableDynamicThreadPool controls MicrometerMonitorAutoConfiguration (#1413)

pull/1412/merge
zjHe 11 months ago committed by GitHub
parent 1b744ac91f
commit 1e95ce8fb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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());
}
}
}

@ -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.

@ -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;
}

@ -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) {

@ -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();

Loading…
Cancel
Save