You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2022/09/28 01:04:47 UTC

[servicecomb-java-chassis] branch master updated: [SCB-2341]map external http headers and query params to invocation context (#3366)

This is an automated email from the ASF dual-hosted git repository.

liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git


The following commit(s) were added to refs/heads/master by this push:
     new 05aa97f0e [SCB-2341]map external http headers and query params to invocation context (#3366)
05aa97f0e is described below

commit 05aa97f0e739e51a93804b11689f3e0932e7f7fb
Author: liubao68 <bi...@qq.com>
AuthorDate: Wed Sep 28 09:04:40 2022 +0800

    [SCB-2341]map external http headers and query params to invocation context (#3366)
---
 .../common/rest/AbstractRestInvocation.java        | 42 +++++++++++++++++++++-
 .../apache/servicecomb/common/rest/RestConst.java  |  4 +++
 ...onListener.java => SCBApplicationListener.java} |  2 +-
 .../main/resources/META-INF/spring/cse.bean.xml    |  2 +-
 ...stener.java => TestSCBApplicationListener.java} |  4 +--
 .../zeroconfig/client/ClientServerEndpoint.java    | 23 +++++++++---
 .../src/main/resources/application.yml             |  7 +++-
 .../src/main/resources/application.yml             |  5 +++
 .../demo/zeroconfig/tests/ServerTest.java          | 19 ++++++++++
 .../ClientServerEndpoint.yaml                      | 25 +++++++++++++
 .../servicecomb/edge/core/EdgeInvocation.java      |  2 ++
 .../org/apache/servicecomb/config/YAMLUtil.java    | 14 ++++----
 governance/README.md                               | 24 -------------
 .../serviceregistry/auth/TokenCacheManager.java    | 13 +++++--
 .../starter/ServiceCombSpringConfiguration.java    |  6 ++--
 15 files changed, 145 insertions(+), 47 deletions(-)

diff --git a/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/AbstractRestInvocation.java b/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/AbstractRestInvocation.java
index cd7e98577..7a2af1646 100644
--- a/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/AbstractRestInvocation.java
+++ b/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/AbstractRestInvocation.java
@@ -19,6 +19,7 @@ package org.apache.servicecomb.common.rest;
 
 import java.nio.charset.StandardCharsets;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.CompletableFuture;
@@ -26,7 +27,6 @@ import java.util.concurrent.CompletableFuture;
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.Response.Status;
 
-import com.google.common.annotations.VisibleForTesting;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.servicecomb.common.rest.codec.produce.ProduceProcessor;
 import org.apache.servicecomb.common.rest.codec.produce.ProduceProcessorManager;
@@ -36,6 +36,7 @@ import org.apache.servicecomb.common.rest.filter.HttpServerFilterBeforeSendRespo
 import org.apache.servicecomb.common.rest.filter.inner.RestServerCodecFilter;
 import org.apache.servicecomb.common.rest.locator.OperationLocator;
 import org.apache.servicecomb.common.rest.locator.ServicePathManager;
+import org.apache.servicecomb.config.YAMLUtil;
 import org.apache.servicecomb.core.Const;
 import org.apache.servicecomb.core.Handler;
 import org.apache.servicecomb.core.Invocation;
@@ -50,11 +51,18 @@ import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.annotations.VisibleForTesting;
+import com.netflix.config.DynamicPropertyFactory;
+
 public abstract class AbstractRestInvocation {
   private static final Logger LOGGER = LoggerFactory.getLogger(AbstractRestInvocation.class);
 
   public static final String UNKNOWN_OPERATION_ID = "UNKNOWN_OPERATION";
 
+  private final Map<String, Object> headerContextMappers;
+
+  private final Map<String, Object> queryContextMappers;
+
   protected long start;
 
   protected RestOperationMeta restOperationMeta;
@@ -71,6 +79,23 @@ public abstract class AbstractRestInvocation {
 
   public AbstractRestInvocation() {
     this.start = System.nanoTime();
+
+    String headerContextMapper = DynamicPropertyFactory.getInstance()
+        .getStringProperty(RestConst.HEADER_CONTEXT_MAPPER, null).get();
+    String queryContextMapper = DynamicPropertyFactory.getInstance()
+        .getStringProperty(RestConst.QUERY_CONTEXT_MAPPER, null).get();
+
+    if (headerContextMapper != null) {
+      headerContextMappers = YAMLUtil.yaml2Properties(headerContextMapper);
+    } else {
+      headerContextMappers = new HashMap<>();
+    }
+
+    if (queryContextMapper != null) {
+      queryContextMappers = YAMLUtil.yaml2Properties(queryContextMapper);
+    } else {
+      queryContextMappers = new HashMap<>();
+    }
   }
 
   public void setHttpServerFilters(List<HttpServerFilter> httpServerFilters) {
@@ -110,6 +135,21 @@ public abstract class AbstractRestInvocation {
     Map<String, String> cseContext =
         JsonUtils.readValue(strCseContext.getBytes(StandardCharsets.UTF_8), Map.class);
     invocation.mergeContext(cseContext);
+
+    addParameterContext();
+  }
+
+  protected void addParameterContext() {
+    headerContextMappers.forEach((k, v) -> {
+      if (v instanceof String && requestEx.getHeader(k) != null) {
+        invocation.addContext((String) v, requestEx.getHeader(k));
+      }
+    });
+    queryContextMappers.forEach((k, v) -> {
+      if (v instanceof String && requestEx.getParameter(k) != null) {
+        invocation.addContext((String) v, requestEx.getParameter(k));
+      }
+    });
   }
 
   public String getContext(String key) {
diff --git a/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/RestConst.java b/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/RestConst.java
index b35997d89..3d0bd954a 100644
--- a/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/RestConst.java
+++ b/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/RestConst.java
@@ -82,4 +82,8 @@ public final class RestConst {
   public static final String PROVIDER_SCAN_REST_CONTROLLER = "servicecomb.provider.rest.scanRestController";
 
   public static final String PRINT_CODEC_ERROR_MESSGAGE = "servicecomb.codec.printErrorMessage";
+
+  public static final String HEADER_CONTEXT_MAPPER = "servicecomb.context.headerContextMapper";
+
+  public static final String QUERY_CONTEXT_MAPPER = "servicecomb.context.queryContextMapper";
 }
diff --git a/core/src/main/java/org/apache/servicecomb/core/CseApplicationListener.java b/core/src/main/java/org/apache/servicecomb/core/SCBApplicationListener.java
similarity index 99%
rename from core/src/main/java/org/apache/servicecomb/core/CseApplicationListener.java
rename to core/src/main/java/org/apache/servicecomb/core/SCBApplicationListener.java
index 4e50026fd..f8b846fb8 100644
--- a/core/src/main/java/org/apache/servicecomb/core/CseApplicationListener.java
+++ b/core/src/main/java/org/apache/servicecomb/core/SCBApplicationListener.java
@@ -33,7 +33,7 @@ import org.springframework.context.event.ContextRefreshedEvent;
 import org.springframework.context.support.AbstractApplicationContext;
 import org.springframework.core.Ordered;
 
-public class CseApplicationListener
+public class SCBApplicationListener
     implements ApplicationListener<ApplicationEvent>, Ordered, ApplicationContextAware {
   private Class<?> initEventClass = ContextRefreshedEvent.class;
 
diff --git a/core/src/main/resources/META-INF/spring/cse.bean.xml b/core/src/main/resources/META-INF/spring/cse.bean.xml
index 86568ecda..3319062a3 100644
--- a/core/src/main/resources/META-INF/spring/cse.bean.xml
+++ b/core/src/main/resources/META-INF/spring/cse.bean.xml
@@ -28,7 +28,7 @@
   <!-- initializer doing before any bean -->
   <bean class="org.apache.servicecomb.core.ConfigurationSpringInitializer"/>
   <!-- initializer after any bean initialized -->
-  <bean class="org.apache.servicecomb.core.CseApplicationListener"/>
+  <bean class="org.apache.servicecomb.core.SCBApplicationListener"/>
 
   <bean id="cse.executor.groupThreadPool" class="org.apache.servicecomb.core.executor.GroupExecutor"
     init-method="init"/>
diff --git a/core/src/test/java/org/apache/servicecomb/core/TestCseApplicationListener.java b/core/src/test/java/org/apache/servicecomb/core/TestSCBApplicationListener.java
similarity index 94%
rename from core/src/test/java/org/apache/servicecomb/core/TestCseApplicationListener.java
rename to core/src/test/java/org/apache/servicecomb/core/TestSCBApplicationListener.java
index 4325e86db..bca38c939 100644
--- a/core/src/test/java/org/apache/servicecomb/core/TestCseApplicationListener.java
+++ b/core/src/test/java/org/apache/servicecomb/core/TestSCBApplicationListener.java
@@ -27,7 +27,7 @@ import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
 import org.springframework.context.event.ContextClosedEvent;
 
-public class TestCseApplicationListener {
+public class TestSCBApplicationListener {
   @BeforeEach
   public void before() {
     ConfigUtil.installDynamicConfig();
@@ -45,7 +45,7 @@ public class TestCseApplicationListener {
     SCBEngine scbEngine = SCBBootstrap.createSCBEngineForTest();
     scbEngine.setStatus(SCBStatus.UP);
 
-    CseApplicationListener listener = new CseApplicationListener();
+    SCBApplicationListener listener = new SCBApplicationListener();
     listener.onApplicationEvent(contextClosedEvent);
 
     Assertions.assertEquals(SCBStatus.DOWN, scbEngine.getStatus());
diff --git a/demo/demo-zeroconfig-schemadiscovery-registry/demo-zeroconfig-schemadiscovery-registry-client/src/main/java/org/apache/servicecomb/demo/zeroconfig/client/ClientServerEndpoint.java b/demo/demo-zeroconfig-schemadiscovery-registry/demo-zeroconfig-schemadiscovery-registry-client/src/main/java/org/apache/servicecomb/demo/zeroconfig/client/ClientServerEndpoint.java
index b68f18649..9355b3b96 100644
--- a/demo/demo-zeroconfig-schemadiscovery-registry/demo-zeroconfig-schemadiscovery-registry-client/src/main/java/org/apache/servicecomb/demo/zeroconfig/client/ClientServerEndpoint.java
+++ b/demo/demo-zeroconfig-schemadiscovery-registry/demo-zeroconfig-schemadiscovery-registry-client/src/main/java/org/apache/servicecomb/demo/zeroconfig/client/ClientServerEndpoint.java
@@ -28,11 +28,12 @@ import org.apache.servicecomb.provider.rest.common.RestSchema;
 import org.apache.servicecomb.registry.DiscoveryManager;
 import org.apache.servicecomb.registry.api.registry.Microservice;
 import org.apache.servicecomb.swagger.extend.annotations.RawJsonRequestBody;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.servicecomb.swagger.invocation.context.ContextUtils;
+import org.apache.servicecomb.swagger.invocation.context.InvocationContext;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestHeader;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 
@@ -41,9 +42,6 @@ import io.vertx.core.json.JsonObject;
 @RestSchema(schemaId = "ClientServerEndpoint")
 @RequestMapping(path = "/register/url/prefix", produces = MediaType.APPLICATION_JSON)
 public class ClientServerEndpoint {
-  private static final Logger LOGGER
-      = LoggerFactory.getLogger(ClientServerEndpoint.class);
-
   @RpcReference(microserviceName = "demo-zeroconfig-schemadiscovery-registry-server", schemaId = "ServerEndpoint")
   private IServerEndpoint serverEndpoint;
 
@@ -88,4 +86,19 @@ public class ClientServerEndpoint {
   public ClientModel postModel(@RequestBody ClientModel clientModel) {
     return clientModel;
   }
+
+  @GetMapping(path = "/contextMapper")
+  public String contextMapper(@RequestHeader("gatewayHeader") String gatewayHeader,
+      @RequestHeader("clientHeader") String clientHeader,
+      @RequestParam("gatewayQuery") String gatewayQuery,
+      @RequestParam("clientQuery") String clientQuery) {
+    InvocationContext context = ContextUtils.getInvocationContext();
+    if (gatewayHeader.equals(context.getContext("context-gateway-header")) &&
+        clientHeader.equals(context.getContext("context-client-header")) &&
+        gatewayQuery.equals(context.getContext("context-gateway-query")) &&
+        clientQuery.equals(context.getContext("context-client-query"))) {
+      return "success";
+    }
+    return "fail";
+  }
 }
diff --git a/demo/demo-zeroconfig-schemadiscovery-registry/demo-zeroconfig-schemadiscovery-registry-client/src/main/resources/application.yml b/demo/demo-zeroconfig-schemadiscovery-registry/demo-zeroconfig-schemadiscovery-registry-client/src/main/resources/application.yml
index b46710609..f89c65460 100644
--- a/demo/demo-zeroconfig-schemadiscovery-registry/demo-zeroconfig-schemadiscovery-registry-client/src/main/resources/application.yml
+++ b/demo/demo-zeroconfig-schemadiscovery-registry/demo-zeroconfig-schemadiscovery-registry-client/src/main/resources/application.yml
@@ -102,4 +102,9 @@ servicecomb:
     demo-bulkhead: |
       maxConcurrentCalls: 5
       ## services is optional in configuration file
-      services: demo-zeroconfig-schemadiscovery-registry-client
\ No newline at end of file
+      services: demo-zeroconfig-schemadiscovery-registry-client
+  context:
+    headerContextMapper: |
+      clientHeader: context-client-header
+    queryContextMapper: |
+      clientQuery: context-client-query
diff --git a/demo/demo-zeroconfig-schemadiscovery-registry/demo-zeroconfig-schemadiscovery-registry-edge/src/main/resources/application.yml b/demo/demo-zeroconfig-schemadiscovery-registry/demo-zeroconfig-schemadiscovery-registry-edge/src/main/resources/application.yml
index 506270189..685fd5937 100644
--- a/demo/demo-zeroconfig-schemadiscovery-registry/demo-zeroconfig-schemadiscovery-registry-edge/src/main/resources/application.yml
+++ b/demo/demo-zeroconfig-schemadiscovery-registry/demo-zeroconfig-schemadiscovery-registry-edge/src/main/resources/application.yml
@@ -45,3 +45,8 @@ servicecomb:
               path: "/register/url/prefix/.*"
               microserviceName: demo-zeroconfig-schemadiscovery-registry-client
               versionRule: 0+
+  context:
+    headerContextMapper: |
+      gatewayHeader: context-gateway-header
+    queryContextMapper: |
+      gatewayQuery: context-gateway-query
diff --git a/demo/demo-zeroconfig-schemadiscovery-registry/demo-zeroconfig-schemadiscovery-registry-tests/src/main/java/org/apache/servicecomb/demo/zeroconfig/tests/ServerTest.java b/demo/demo-zeroconfig-schemadiscovery-registry/demo-zeroconfig-schemadiscovery-registry-tests/src/main/java/org/apache/servicecomb/demo/zeroconfig/tests/ServerTest.java
index f7333bab9..aaf8233df 100644
--- a/demo/demo-zeroconfig-schemadiscovery-registry/demo-zeroconfig-schemadiscovery-registry-tests/src/main/java/org/apache/servicecomb/demo/zeroconfig/tests/ServerTest.java
+++ b/demo/demo-zeroconfig-schemadiscovery-registry/demo-zeroconfig-schemadiscovery-registry-tests/src/main/java/org/apache/servicecomb/demo/zeroconfig/tests/ServerTest.java
@@ -17,6 +17,8 @@
 
 package org.apache.servicecomb.demo.zeroconfig.tests;
 
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
@@ -25,7 +27,12 @@ import java.util.concurrent.CountDownLatch;
 import org.apache.servicecomb.demo.CategorizedTestCase;
 import org.apache.servicecomb.demo.TestMgr;
 import org.apache.servicecomb.provider.springmvc.reference.RestTemplateBuilder;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.RequestEntity;
+import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Component;
+import org.springframework.util.MultiValueMap;
 import org.springframework.web.client.RestTemplate;
 
 import io.vertx.core.json.JsonObject;
@@ -42,6 +49,18 @@ public class ServerTest implements CategorizedTestCase {
     testJsonObject();
     testString();
     testDateForEdge();
+    testContextMapper();
+  }
+
+  private void testContextMapper() throws URISyntaxException {
+    MultiValueMap<String, String> headers = new HttpHeaders();
+    headers.add("clientHeader", "v1");
+    headers.add("gatewayHeader", "v2");
+    RequestEntity<Void> requestEntity = new RequestEntity<>(headers, HttpMethod.GET,
+        new URI("cse://demo-zeroconfig-schemadiscovery-registry-edge/register/url/prefix/contextMapper?clientQuery=v3&"
+            + "gatewayQuery=v4"));
+    ResponseEntity<String> response = template.exchange(requestEntity, String.class);
+    TestMgr.check(response.getBody(), "success");
   }
 
   @SuppressWarnings("unchecked")
diff --git a/demo/demo-zeroconfig-schemadiscovery-registry/demo-zeroconfig-schemadiscovery-registry-tests/src/main/resources/microservices/demo-zeroconfig-schemadiscovery-registry-edge/ClientServerEndpoint.yaml b/demo/demo-zeroconfig-schemadiscovery-registry/demo-zeroconfig-schemadiscovery-registry-tests/src/main/resources/microservices/demo-zeroconfig-schemadiscovery-registry-edge/ClientServerEndpoint.yaml
index fcfe266d8..7cf4edd1d 100644
--- a/demo/demo-zeroconfig-schemadiscovery-registry/demo-zeroconfig-schemadiscovery-registry-tests/src/main/resources/microservices/demo-zeroconfig-schemadiscovery-registry-edge/ClientServerEndpoint.yaml
+++ b/demo/demo-zeroconfig-schemadiscovery-registry/demo-zeroconfig-schemadiscovery-registry-tests/src/main/resources/microservices/demo-zeroconfig-schemadiscovery-registry-edge/ClientServerEndpoint.yaml
@@ -28,6 +28,31 @@ consumes:
 produces:
   - "application/json"
 paths:
+  /contextMapper:
+    get:
+      operationId: "contextMapper"
+      parameters:
+        - name: "gatewayHeader"
+          in: "header"
+          required: true
+          type: "string"
+        - name: "clientHeader"
+          in: "header"
+          required: true
+          type: "string"
+        - name: "gatewayQuery"
+          in: "query"
+          required: true
+          type: "string"
+        - name: "clientQuery"
+          in: "query"
+          required: true
+          type: "string"
+      responses:
+        "200":
+          description: "response of 200"
+          schema:
+            type: "string"
   /getName:
     get:
       operationId: "getName"
diff --git a/edge/edge-core/src/main/java/org/apache/servicecomb/edge/core/EdgeInvocation.java b/edge/edge-core/src/main/java/org/apache/servicecomb/edge/core/EdgeInvocation.java
index e7853358e..fa0aabee2 100644
--- a/edge/edge-core/src/main/java/org/apache/servicecomb/edge/core/EdgeInvocation.java
+++ b/edge/edge-core/src/main/java/org/apache/servicecomb/edge/core/EdgeInvocation.java
@@ -121,5 +121,7 @@ public class EdgeInvocation extends AbstractRestInvocation {
   @Override
   public void setContext() throws Exception {
     // do not read InvocationContext from HTTP header, for security reason
+
+    addParameterContext();
   }
 }
diff --git a/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/YAMLUtil.java b/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/YAMLUtil.java
index ac3b00a9c..21ace7c09 100644
--- a/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/YAMLUtil.java
+++ b/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/YAMLUtil.java
@@ -29,15 +29,15 @@ import org.yaml.snakeyaml.Yaml;
 import org.yaml.snakeyaml.constructor.Constructor;
 import org.yaml.snakeyaml.constructor.SafeConstructor;
 
-/**
- * Created by   on 2017/1/5.
- */
 public final class YAMLUtil {
-  private static final Yaml SAFE_PARSER = new Yaml(new SafeConstructor());
-
   private YAMLUtil() {
   }
 
+  private static Yaml safeParser() {
+    // Yaml instance is not thread safe, create a new instance for each parser
+    return new Yaml(new SafeConstructor());
+  }
+
   /**
    * load a input {@link InputStream} to be a map {@link Map}, you have to close the inputStream by yourself, such as:<br>
    * <p>try (InputStream in = url.openStream()) {<br>
@@ -50,7 +50,7 @@ public final class YAMLUtil {
   @SuppressWarnings("unchecked")
   public static Map<String, Object> yaml2Properties(InputStream input) {
     Map<String, Object> configurations = new LinkedHashMap<>();
-    SAFE_PARSER.loadAll(input).forEach(data -> {
+    safeParser().loadAll(input).forEach(data -> {
       if (data instanceof Map && isValidMap((Map<Object, Object>) data)) {
         configurations.putAll(retrieveItems("", (Map<String, Object>) data));
       } else {
@@ -84,7 +84,7 @@ public final class YAMLUtil {
   @SuppressWarnings("unchecked")
   public static Map<String, Object> yaml2Properties(String input) {
     Map<String, Object> configurations = new LinkedHashMap<>();
-    SAFE_PARSER.loadAll(input).forEach(data -> {
+    safeParser().loadAll(input).forEach(data -> {
       if (data instanceof Map && isValidMap((Map<Object, Object>) data)) {
         configurations.putAll(retrieveItems("", (Map<String, Object>) data));
       } else {
diff --git a/governance/README.md b/governance/README.md
deleted file mode 100644
index bc6f83e28..000000000
--- a/governance/README.md
+++ /dev/null
@@ -1,24 +0,0 @@
-# About Governance Module
-
-Governance module provides an abstraction on how to describe governance instructions for commonly used
-different microservice frameworks, like Java Chassis, Go Chassis, Spring Cloud, Dubbo, etc. 
-
-This abstraction is based on traffic marking, here is a configuration example.
-
-```yaml
-servicecomb:
-  matchGroup:
-    matchGroup0: |
-      matches:
-        - apiPath:
-            exact: "/hello"
-          name: match0
-  rateLimiting:
-    rateLimiting0: |
-      rules:
-        match: matchGroup0.match0
-      rate: 1
-```
-
-First define a traffic marking rule (match group) `servicecomb.matchGroup.matchGroup0` and detailed matches
-specification. Then define governance rules for any marking rule. Marking rule id is `matchGroup0.match0`. 
diff --git a/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/auth/TokenCacheManager.java b/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/auth/TokenCacheManager.java
index dbb31c7d5..d07d2add0 100644
--- a/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/auth/TokenCacheManager.java
+++ b/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/auth/TokenCacheManager.java
@@ -29,11 +29,11 @@ import javax.ws.rs.core.Response.Status;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.servicecomb.foundation.auth.Cipher;
 import org.apache.servicecomb.foundation.common.concurrent.ConcurrentHashMapEx;
+import org.apache.servicecomb.registry.api.event.ServiceCenterEventBus;
 import org.apache.servicecomb.service.center.client.ServiceCenterClient;
 import org.apache.servicecomb.service.center.client.model.RbacTokenRequest;
 import org.apache.servicecomb.service.center.client.model.RbacTokenResponse;
 import org.apache.servicecomb.serviceregistry.event.NotPermittedEvent;
-import org.apache.servicecomb.registry.api.event.ServiceCenterEventBus;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -116,7 +116,16 @@ public final class TokenCacheManager {
       this.cipher = cipher;
 
       if (enabled()) {
-        executorService = Executors.newFixedThreadPool(1, t -> new Thread(t, "rbac-executor-" + this.registryName));
+        executorService = Executors.newFixedThreadPool(1, t -> new Thread(t, "rbac-executor-" + this.registryName) {
+          @Override
+          public void run() {
+            try {
+              super.run();
+            } catch (Throwable e) {
+              LOGGER.error("", e);
+            }
+          }
+        });
         cache = CacheBuilder.newBuilder()
             .maximumSize(1)
             .refreshAfterWrite(refreshTime(), TimeUnit.MILLISECONDS)
diff --git a/spring-boot/spring-boot-starters/java-chassis-spring-boot-starter/src/main/java/org/apache/servicecomb/springboot2/starter/ServiceCombSpringConfiguration.java b/spring-boot/spring-boot-starters/java-chassis-spring-boot-starter/src/main/java/org/apache/servicecomb/springboot2/starter/ServiceCombSpringConfiguration.java
index 1226e15e2..89cf311a3 100644
--- a/spring-boot/spring-boot-starters/java-chassis-spring-boot-starter/src/main/java/org/apache/servicecomb/springboot2/starter/ServiceCombSpringConfiguration.java
+++ b/spring-boot/spring-boot-starters/java-chassis-spring-boot-starter/src/main/java/org/apache/servicecomb/springboot2/starter/ServiceCombSpringConfiguration.java
@@ -18,7 +18,7 @@ package org.apache.servicecomb.springboot2.starter;
 
 import javax.inject.Inject;
 
-import org.apache.servicecomb.core.CseApplicationListener;
+import org.apache.servicecomb.core.SCBApplicationListener;
 import org.apache.servicecomb.foundation.common.utils.BeanUtils;
 import org.springframework.boot.context.event.ApplicationReadyEvent;
 import org.springframework.context.annotation.Configuration;
@@ -28,7 +28,7 @@ import org.springframework.context.annotation.ImportResource;
 @ImportResource({BeanUtils.DEFAULT_BEAN_CORE_RESOURCE, BeanUtils.DEFAULT_BEAN_NORMAL_RESOURCE})
 class ServiceCombSpringConfiguration {
   @Inject
-  public void setCseApplicationListener(CseApplicationListener cseApplicationListener) {
-    cseApplicationListener.setInitEventClass(ApplicationReadyEvent.class);
+  public void setCseApplicationListener(SCBApplicationListener applicationListener) {
+    applicationListener.setInitEventClass(ApplicationReadyEvent.class);
   }
 }