refactor(open,channel): 消除 redis 配置存储与媒体下载执行器中的重复代码 - #4084
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
refactor(open,channel): 消除 redis 配置存储与媒体下载执行器中的重复代码#4084devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
open: 三个 WxOpenInRedis*ConfigStorage 的 20 个方法逐字符相同,抽取 AbstractWxOpenInRedisOpsConfigStorage 统一实现,子类仅保留构造函数。 channel: 两个媒体下载执行器中的 uri 拼参与临时文件命名逻辑上移到 ChannelMediaDownloadRequestExecutor。 Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
续 #4082,继续清理 CPD 扫描出的模块内重复(均不改变对外 API 与行为)。
weixin-java-open:
WxOpenInRedisConfigStorage、WxOpenInRedisTemplateConfigStorage、WxOpenInRedissonConfigStorage三个类各 140 行,除构造函数外的 20 个方法(component ticket / access token、authorizer token、jsapi ticket、card api ticket、lock)逐字符相同,都只是在操作WxRedisOps。抽取:三个实现类只剩构造函数(
super(redisOps, keyPrefix)),公共构造函数签名、可见性与@NonNull语义全部保留;原private final WxRedisOps redisOps字段本就不对外暴露。weixin-java-channel:
ApacheHttpChannelMediaDownloadRequestExecutor与HttpComponentsChannelMediaDownloadRequestExecutor使用不同的 HttpClient 类型(httpclient4 / hc5),无法直接合并,但其中与 HTTP 库无关的两段逻辑重复,上移到公共父类ChannelMediaDownloadRequestExecutor:appendDataToUri(uri, data):请求参数拼接(?/&判断)。saveTmpFile(inputStream, fileName):文件名为空取时间戳、baseName 少于 3 字符取时间戳、扩展名为空取unknown,再调用createTmpFile。原代码中
if (StringUtils.isBlank(fileName) || baseName.length() < 3)的前半段判断在该位置恒为 false(fileName上一行已被兜底成时间戳),新实现改为等价且更直观的StringUtils.isBlank(baseName) || baseName.length() < 3,结果一致。验证
mvn -pl weixin-java-open,weixin-java-channel -am -DskipTests install编译通过。WxOpenInRedisConfigStorageTest(根 POM surefire<skip>true</skip>):改动前后同为 9 个用例 8 通过 1 失败,失败用例testGetComponentVerifyTicket是既有的用例间顺序依赖问题(被test_ticket_for_expiration覆盖),与本次改动无关,已在 develop 基线上复现确认。Link to Devin session: https://app.devin.ai/sessions/65a1cece5efb4304a7e6b85aaa562d7a
Requested by: @binarywang