{"record":{"id":"1be4f16a5f6b0537","repo":"apache/shenyu","slug":"shared-thread-pool-is-not-enable-config-shenyu-sharedpool-1be4f1","errorCode":null,"errorMessage":"shared thread pool is not enable, config ${shenyu.sharedPool.enable} in your xml/yml !","messagePattern":"shared thread pool is not enable, config (.+?) in your xml/yml !","errorType":"exception","errorClass":"ShenyuException","httpStatus":null,"severity":"error","filePath":"shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-sofa/src/main/java/org/apache/shenyu/plugin/sofa/cache/ApplicationConfigCache.java","lineNumber":166,"sourceCode":"        Field field = ReflectionUtils.findField(AsyncRuntime.class, \"asyncThreadPool\");\n        ReflectionUtils.makeAccessible(field);\n        ReflectionUtils.setField(field, AsyncRuntime.class, threadPool);\n    }\n    \n    /**\n     * Init thread pool.\n     */\n    private void initThreadPool(final SofaRegisterConfig config) {\n        if (Objects.nonNull(threadPool)) {\n            return;\n        }\n        switch (config.getThreadpool()) {\n            case Constants.SHARED:\n                try {\n                    threadPool = SpringBeanUtils.getInstance().getBean(ShenyuThreadPoolExecutor.class);\n                    return;\n                } catch (NoSuchBeanDefinitionException t) {\n                    throw new ShenyuException(\"shared thread pool is not enable, config ${shenyu.sharedPool.enable} in your xml/yml !\", t);\n                }\n            case Constants.FIXED:\n            case Constants.EAGER:\n            case Constants.LIMITED:\n                throw new UnsupportedOperationException();\n            case Constants.CACHED:\n                int corePoolSize = Optional.ofNullable(config.getCorethreads()).orElse(0);\n                int maximumPoolSize = Optional.ofNullable(config.getThreads()).orElse(Integer.MAX_VALUE);\n                int queueSize = Optional.ofNullable(config.getQueues()).orElse(0);\n                threadPool = new ThreadPoolExecutor(corePoolSize, maximumPoolSize, 60L, TimeUnit.SECONDS,\n                        queueSize > 0 ? new LinkedBlockingQueue<>(queueSize) : new SynchronousQueue<>(), factory);\n                return;\n            default:\n        }\n    }\n    \n    /**\n     * Init ref reference config.","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/apache/shenyu/blob/567142e07261b3e615ae8850b30f4421f455cc5d/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-sofa/src/main/java/org/apache/shenyu/plugin/sofa/cache/ApplicationConfigCache.java#L148-L184","documentation":"ApplicationConfigCache.initThreadPool for the SOFA plugin resolves the executor for sofa RPC calls. With threadpool=shared it looks up the ShenyuThreadPoolExecutor bean and throws ShenyuException if the bean is missing because shared pool support was not enabled; fixed/eager/limited throw UnsupportedOperationException outright.","triggerScenarios":"sofa plugin config sets threadpool=shared while shenyu.sharedPool.enable is false/absent; initThreadPool runs during ApplicationConfigCache.init when the sofa plugin loads configuration.","commonSituations":"Sofa plugin enabled with default/example config referencing 'shared'; application.yml missing shenyu.sharedPool.enable; the shared pool starter not included in bootstrap dependencies.","solutions":["Set shenyu.sharedPool.enable: true in the gateway's application.yml.","Or change the sofa threadpool config to 'cached' (supported default).","Confirm the dependency/starter that registers ShenyuThreadPoolExecutor is present in the bootstrap pom.","Restart the gateway so init() runs with the corrected configuration."],"exampleFix":"// before\nshenyu:\n  sofa:\n    threadpool: shared\n// after\nshenyu:\n  sharedPool:\n    enable: true\n  sofa:\n    threadpool: shared","handlingStrategy":"validation","validationCode":"if (\"shared\".equals(config.getThreadpool())\n        && SpringBeanUtils.getInstance().getApplicationContext()\n            .getBeansOfType(ShenyuThreadPoolExecutor.class).isEmpty()) {\n    throw new IllegalStateException(\"sofa shared threadpool requires shenyu.sharedPool.enable=true\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    applicationConfigCache.init(sofaConfig);\n} catch (ShenyuException e) {\n    LOG.error(\"sofa init failed: {}\", e.getMessage());\n}","preventionTips":["Enable shenyu.sharedPool.enable=true whenever the sofa plugin uses threadpool=shared.","Fall back to 'cached' threadpool when a dedicated pool is acceptable.","Add config validation at bootstrap before the plugin initializes its cache.","Keep bootstrap dependencies aligned with the threadpool mode selected."],"tags":["sofa","threadpool","configuration","init"],"backgroundTag":"missing-required-config","analyzedSha":"567142e07261b3e615ae8850b30f4421f455cc5d","analyzedAt":"2026-09-12T10:08:21.293Z","contentChangedAt":"2026-09-12T10:08:21.293Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}