Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 24, 2025

Issue

The ComponentVerifyTicket in Redis-based configuration storage classes was being cached with Integer.MAX_VALUE expiration time (essentially infinite), which contradicts WeChat's official documentation stating that component_verify_ticket has a validity period of 12 hours.

This could lead to:

  • Stale tickets being used beyond their valid lifetime
  • Potential authentication failures when WeChat invalidates tickets server-side
  • Poor cache management and memory usage

Solution

Updated the expiration time in setComponentVerifyTicket() method from Integer.MAX_VALUE to 43200 seconds (12 hours) across all Redis-based configuration storage implementations:

Before:

redisOps.setValue(this.componentVerifyTicketKey, componentVerifyTicket, Integer.MAX_VALUE, TimeUnit.SECONDS);

After:

redisOps.setValue(this.componentVerifyTicketKey, componentVerifyTicket, 43200, TimeUnit.SECONDS);

Files Changed

  • WxOpenInRedissonConfigStorage.java
  • WxOpenInRedisConfigStorage.java
  • WxOpenInRedisTemplateConfigStorage.java
  • Added verification tests in corresponding test files

References

Testing

  • ✅ All existing tests pass
  • ✅ Added new tests to verify ComponentVerifyTicket functionality
  • ✅ Full build and checkstyle validation successful
  • ✅ Changes are backward compatible

This change aligns the cache behavior with WeChat's official specifications and ensures proper token lifecycle management.

Fixes #3683


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…hours

Co-authored-by: binarywang <1343140+binarywang@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] 4.7.0 版本 WxOpenInRedissonConfigStorage,ComponentVerifyTicket 缓存失效时间是 Integer.MAX_VALUE Fix ComponentVerifyTicket Redis cache expiration from infinite to 12 hours Sep 24, 2025
@Copilot Copilot AI requested a review from binarywang September 24, 2025 14:01
Copilot finished work on behalf of binarywang September 24, 2025 14:01
@binarywang binarywang added this to the 4.7.9 milestone Sep 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4.7.0 版本 WxOpenInRedissonConfigStorage,ComponentVerifyTicket 缓存失效时间是 Integer.MAX_VALUE
2 participants