Bruceyan/issue#1134 (#1135)

* Fix: Prevent parameter refresh failure during web container startup due to issues with the execution order of the ApplicationRunner.

* Use `isContainerStarted` conditional logic when updating parameters.

* fix: remove 'isContainerStarted' conditional logic.
pull/1282/head
yanrongzhen 2 years ago committed by GitHub
parent 257011dd32
commit 1aa04a9057
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -25,12 +25,16 @@ import cn.hippo4j.common.model.ThreadPoolRunStateInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import java.util.concurrent.Executor;
/**
* Abstract web thread pool service.
*/
@Slf4j
@Order(Ordered.HIGHEST_PRECEDENCE)
public abstract class AbstractWebThreadPoolService implements WebThreadPoolService, ApplicationRunner {
private final IWebThreadPoolHandlerSupport support;

@ -18,22 +18,28 @@
package cn.hippo4j.adapter.web;
import cn.hippo4j.common.config.ApplicationContextHolder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.web.context.WebServerApplicationContext;
import org.springframework.boot.web.server.WebServer;
import org.springframework.context.ApplicationContext;
import org.springframework.util.ReflectionUtils;
import java.lang.reflect.Field;
import java.util.concurrent.Executor;
/**
* Default WebThreadPoolService abstract class,
* reuses common capabilities for web container operations.
*/
@Slf4j
public abstract class DefaultAbstractWebThreadPoolService extends AbstractWebThreadPoolService {
public DefaultAbstractWebThreadPoolService(IWebThreadPoolHandlerSupport support) {
super(support);
}
private static final String STARTED_FIELD_NAME = "started";
/**
* Get the internal abstract method of the web container thread pool,
* to be implemented by subclasses.

@ -20,18 +20,25 @@ package cn.hippo4j.config.springboot1x.starter.web;
import cn.hippo4j.adapter.web.AbstractWebThreadPoolService;
import cn.hippo4j.adapter.web.IWebThreadPoolHandlerSupport;
import cn.hippo4j.common.config.ApplicationContextHolder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.embedded.EmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedWebApplicationContext;
import org.springframework.util.ReflectionUtils;
import java.lang.reflect.Field;
/**
* Abstract class for adapting WebThreadPoolService to Spring 1.x version.
*/
@Slf4j
public abstract class AbstractWebThreadPoolService1x extends AbstractWebThreadPoolService {
public AbstractWebThreadPoolService1x(IWebThreadPoolHandlerSupport support) {
super(support);
}
private static final String STARTED_FIELD_NAME = "started";
/**
* Get the embedded Servlet container from the Spring application context.
*/
@ -46,4 +53,5 @@ public abstract class AbstractWebThreadPoolService1x extends AbstractWebThreadPo
public Integer getPort() {
return getContainer().getPort();
}
}

Loading…
Cancel
Save