Skip to content

[BUG] Hystrix / Resilience4J / Sentinel / RateLimiter plugins NPE when a matched rule has no cached handle #6877

Description

@Aias00

Description

handlerPlugin checks if the new RedisConfigProperties differs from the cached singleton. If it differs, it constructs a new RedisConnectionFactory (which opens Lettuce connection pools via afterPropertiesSet()), stores the new ReactiveRedisTemplate and RedisConfigProperties into Singleton.INST, but never calls destroy() on the OLD LettuceConnectionFactory. The old factory's connection pool (sockets, NIO event loops, threads) is orphaned. Trigger: any admin update that changes the redis URL, password, database, or pool settings.

Location

  • shenyu-plugin/shenyu-plugin-fault-tolerance/shenyu-plugin-ratelimiter/src/main/java/org/apache/shenyu/plugin/ratelimiter/handler/RateLimiterPluginDataHandler.java:50-65
  • shenyu-infra/shenyu-infra-redis/src/main/java/org/apache/shenyu/infra/redis/RedisConnectionFactory.java:43-48

Impact

Each redis config change permanently leaks a Lettuce connection pool. Repeated config updates accumulate leaked connections, eventually exhausting file descriptors / sockets and degrading gateway stability.

Suggested fix

Before installing the new factory, retrieve the old ReactiveRedisTemplate from Singleton.INST, extract its LettuceConnectionFactory (or track the old RedisConnectionFactory), and call destroy() on it before Singleton.INST.single(...).

Related existing

None — distinct from #6645 (RedisRateLimiter fail-open) because this is a resource-leak in the data handler's config-update path, not the rate-limiting execution path.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions