apache/shenyu · error · ShenyuException

shared thread pool is not enable, config

Error message

shared thread pool is not enable, config ${shenyu.sharedPool.enable} in your xml/yml !

What it means

ApplicationConfigCache.initThreadPool for the TARS plugin mirrors the SOFA/Dubbo logic: with threadpool=shared it fetches ShenyuThreadPoolExecutor from Spring and throws ShenyuException when the bean doesn't exist (shared pool disabled), while fixed/eager/limited throw UnsupportedOperationException.

Solutions

  1. Set shenyu.sharedPool.enable: true in application.yml and restart.
  2. Or switch the tars threadpool config to 'cached'.
  3. Verify the ShenyuThreadPoolExecutor bean is actually registered (check startup logs / dependency list).
  4. Avoid fixed/eager/limited threadpool values for tars — they are unsupported.

Example fix

// before (application.yml)
shenyu:
  tars:
    threadpool: shared
// after
shenyu:
  sharedPool:
    enable: true
  tars:
    threadpool: shared
Defensive patterns

Strategy: validation

Validate before calling

if ("shared".equals(config.getThreadpool())
        && SpringBeanUtils.getInstance().getApplicationContext()
            .getBeansOfType(ShenyuThreadPoolExecutor.class).isEmpty()) {
    throw new IllegalStateException("tars shared threadpool requires shenyu.sharedPool.enable=true");
}

Try / catch

try {
    applicationConfigCache.init(tarsConfig);
} catch (ShenyuException e) {
    LOG.error("tars init failed: {}", e.getMessage());
}

Prevention

When it happens

Trigger: tars plugin configuration has threadpool=shared while the ShenyuThreadPoolExecutor bean is absent because shenyu.sharedPool.enable is not true; initThreadPool runs during plugin cache initialization.

Common situations: Enabling the tars plugin without enabling the shared pool; copying shared-threadpool config from docs without adding shenyu.sharedPool.enable; bean missing due to missing starter dependency.

Understand the failure class

Background: "X is required", "must be set", "cannot be empty": the missing-required-config error family, from Vertex AI project/location to WeChat keys — this error's family across 18 libraries.

Related errors


AI-assisted analysis of apache/shenyu@567142e072 (2026-09-12). Data as JSON: /api/errors/de7922300e9d51b4. Report an issue: GitHub.

Appendix: source

Thrown at shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-tars/src/main/java/org/apache/shenyu/plugin/tars/cache/ApplicationConfigCache.java:141

            initThreadPool(tarsRegisterConfig);
            Optional.ofNullable(threadPool).ifPresent(this::setCommunicatorThreadPool);
        }
    }

    /**
     * init thread pool.
     */
    private void initThreadPool(final TarsRegisterConfig config) {
        if (Objects.nonNull(threadPool)) {
            return;
        }
        switch (config.getThreadpool()) {
            case Constants.SHARED:
                try {
                    threadPool = SpringBeanUtils.getInstance().getBean(ShenyuThreadPoolExecutor.class);
                    return;
                } catch (NoSuchBeanDefinitionException t) {
                    throw new ShenyuException("shared thread pool is not enable, config ${shenyu.sharedPool.enable} in your xml/yml !", t);
                }
            case Constants.FIXED:
            case Constants.EAGER:
            case Constants.LIMITED:
                throw new UnsupportedOperationException();
            case Constants.CACHED:
                int corePoolSize = Optional.ofNullable(config.getCorethreads()).orElse(0);
                int maximumPoolSize = Optional.ofNullable(config.getThreads()).orElse(Integer.MAX_VALUE);
                int queueSize = Optional.ofNullable(config.getQueues()).orElse(0);
                threadPool = new ThreadPoolExecutor(corePoolSize, maximumPoolSize, 60L, TimeUnit.SECONDS,
                        queueSize > 0 ? new LinkedBlockingQueue<>(queueSize) : new SynchronousQueue<>(), factory);
                return;
            default:
        }
    }

    /**
     * Set communicator thread pool.

View on GitHub (pinned to 567142e072)