{"record":{"id":"d0558fc647b2766a","repo":"apache/shenyu","slug":"max-connections-value-must-be-strictly-positive","errorCode":null,"errorMessage":"Max Connections value must be strictly positive","messagePattern":"Max Connections value must be strictly positive","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-httpclient/src/main/java/org/apache/shenyu/springboot/starter/plugin/httpclient/HttpClientFactory.java","lineNumber":177,"sourceCode":"            }\n            Optional.ofNullable(pool.getMaxIdleTime()).map(Duration::ofMillis).ifPresent(builder::maxIdleTime);\n            Optional.ofNullable(pool.getMaxLifeTime()).map(Duration::ofMillis).ifPresent(builder::maxLifeTime);\n            Optional.ofNullable(pool.getEvictionInterval()).map(Duration::ofMillis).ifPresent(builder::evictInBackground);\n            builder.metrics(pool.getMetrics());\n            return builder.build();\n        }\n    }\n\n    /**\n     * build fixed connection pool.\n     *\n     * @param pool    connection pool params\n     * @param builder connection provider builder\n     */\n    public void buildFixedConnectionPool(final Pool pool,\n                                         final Builder builder) {\n        if (pool.getMaxConnections() <= 0) {\n            throw new IllegalArgumentException(\"Max Connections value must be strictly positive\");\n        }\n        if (pool.getAcquireTimeout() < 0) {\n            throw new IllegalArgumentException(\"Acquire Timeout value must be positive\");\n        }\n        builder.maxConnections(pool.getMaxConnections())\n                .pendingAcquireTimeout(Duration.ofMillis(pool.getAcquireTimeout()))\n                .pendingAcquireMaxCount(-1);\n    }\n\n    /**\n     * build elastic connection provider pool.\n     *\n     * @param builder connection provider builder\n     */\n    public void buildElasticConnectionPool(final Builder builder) {\n        // about the args, please see https://projectreactor.io/docs/netty/release/reference/index.html#_connection_pool_2\n        builder.maxConnections(Integer.MAX_VALUE)\n                .pendingAcquireTimeout(Duration.ofMillis(0))","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/apache/shenyu/blob/567142e07261b3e615ae8850b30f4421f455cc5d/shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-httpclient/src/main/java/org/apache/shenyu/springboot/starter/plugin/httpclient/HttpClientFactory.java#L159-L195","documentation":"When the HTTP client connection pool type is fixed, the pool's maxConnections must be a positive integer because Reactor Netty's Builder.maxConnections requires it. A zero or negative configured value throws this IllegalArgumentException at pool build time.","triggerScenarios":"shenyu.httpclient.pool.type=fixed with shenyu.httpclient.pool.maxConnections set to 0 or a negative number (typo, unit confusion, or copying a placeholder value).","commonSituations":"Writing maxConnections: -1 intending 'unlimited'; leaving a 0 default from an edited yml; parsing a string config that defaulted to 0.","solutions":["Set shenyu.httpclient.pool.maxConnections to a positive number (e.g. 20 or higher for heavy load)","Remove the maxConnections key to use the default value","If you intended unlimited connections, keep a large positive number instead of -1"],"exampleFix":"# before\nshenyu:\n  httpclient:\n    pool:\n      type: fixed\n      max-connections: -1\n# after\nshenyu:\n  httpclient:\n    pool:\n      type: fixed\n      max-connections: 2000","handlingStrategy":"validation","validationCode":"int max = env.getProperty(\"shenyu.httpclient.pool.max-connections\", Integer.class, 20);\nif (max <= 0) {\n    throw new IllegalArgumentException(\"shenyu.httpclient.pool.max-connections must be > 0\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    pool = env.bindProperties(Pool.class);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"strictly positive\")) {\n        log.error(\"Set a positive max-connections for the fixed pool\");\n    } else throw e;\n}","preventionTips":["Never use -1 or 0 as 'unlimited' for maxConnections","Document expected pool values next to config samples","Add config sanity checks to startup tests"],"tags":["httpclient","connection-pool","validation","configuration"],"backgroundTag":"value-out-of-range","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"}