fix:adjust timeout and close executor

pull/1127/head
hezijian 3 years ago
parent 0613a92cda
commit 51579ffe32

@ -31,7 +31,7 @@ public class ClientShutdown {
private CountDownLatch countDownLatch = new CountDownLatch(1);
private final static Long TIME_OUT_SECOND = 5L;
private final static Long TIME_OUT_SECOND = 1L;
public void prepareDestroy() throws InterruptedException {
prepareClose = true;

@ -28,6 +28,7 @@ import cn.hippo4j.springboot.starter.remote.HttpAgent;
import cn.hippo4j.springboot.starter.remote.ServerHealthCheck;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.util.StringUtils;
import java.net.URLDecoder;
@ -56,7 +57,7 @@ import static cn.hippo4j.common.constant.Constants.WORD_SEPARATOR;
* Client worker.
*/
@Slf4j
public class ClientWorker {
public class ClientWorker implements DisposableBean {
private final long timeout;
@ -102,6 +103,11 @@ public class ClientWorker {
}, 1L, TimeUnit.MILLISECONDS);
}
@Override
public void destroy() throws Exception {
executorService.shutdownNow();
}
class LongPollingRunnable implements Runnable {
private boolean cacheMapInitEmptyFlag;
@ -116,6 +122,9 @@ public class ClientWorker {
@Override
@SneakyThrows
public void run() {
if (executorService.isShutdown()) {
return;
}
if (cacheMapInitEmptyFlag) {
cacheCondition.await();
cacheMapInitEmptyFlag = false;

Loading…
Cancel
Save