You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by GitBox <gi...@apache.org> on 2022/06/04 03:03:59 UTC

[GitHub] [incubator-shenyu] dragon-zhang commented on a diff in pull request #3482: [ISSUE #3406] Sofa and tars using shared thread pool.

dragon-zhang commented on code in PR #3482:
URL: https://github.com/apache/incubator-shenyu/pull/3482#discussion_r889450777


##########
shenyu-plugin/shenyu-plugin-sofa/src/main/java/org/apache/shenyu/plugin/sofa/cache/ApplicationConfigCache.java:
##########
@@ -108,6 +123,52 @@ public void init(final SofaRegisterConfig sofaRegisterConfig) {
             registryConfig.setRegister(false);
             registryConfig.setAddress(sofaRegisterConfig.getRegister());
         }
+        if (StringUtils.isNotBlank(sofaRegisterConfig.getThreadpool())) {
+            initThreadPool(sofaRegisterConfig);
+            setAsyncRuntimeThreadPool();
+        }
+    }
+
+    /**
+     * Set sofa asyncRuntime thread pool.
+     */
+    private void setAsyncRuntimeThreadPool() {
+        if (Objects.nonNull(threadPool)) {
+            Field field = ReflectionUtils.findField(AsyncRuntime.class, "asyncThreadPool");
+            ReflectionUtils.makeAccessible(field);

Review Comment:
   Using `java.util.Optional` to add null judgment.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org