Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 9, 2026

修复HttpClient5升级后的NPE问题

问题分析

升级到4.8后,当没有配置代理密码时,getHttpProxyPassword() 返回null,导致调用 .toCharArray() 时发生NPE。

修复计划

  • 分析问题:确认所有HttpComponents实现类的null检查情况
  • 验证现有代码:确认 *HttpComponentsImpl 类已修复
  • 检查测试覆盖:查看是否有相关测试
  • 创建测试用例:为null情况添加测试
  • 运行测试验证:确保修复不会破坏现有功能
  • 代码审查:使用code_review工具检查
  • 安全扫描:使用codeql_checker检查

涉及模块

  • weixin-java-mp (已修复)
  • weixin-java-miniapp (已修复)
  • weixin-java-cp (已修复)
  • weixin-java-open (已修复)
  • weixin-java-qidian (已修复)
  • weixin-java-channel (已修复)

所有 *HttpComponentsImpl 类都已正确处理null情况。

Original prompt

This section details on the original issue you should resolve

<issue_title>升级到4.8后用httpclient5 NPE了。</issue_title>
<issue_description>### 简要描述
升级到4.8后用httpclient5 NPE了。

模块版本情况

  • WxJava 模块名: weixin-java-mp-4.8.0
Image
 @Override
  public void initHttp() {
    WxMpConfigStorage configStorage = this.getWxMpConfigStorage();
    HttpComponentsClientBuilder apacheHttpClientBuilder = DefaultHttpComponentsClientBuilder.get();

    apacheHttpClientBuilder.httpProxyHost(configStorage.getHttpProxyHost())
      .httpProxyPort(configStorage.getHttpProxyPort())
      .httpProxyUsername(configStorage.getHttpProxyUsername())
      .httpProxyPassword(configStorage.getHttpProxyPassword().toCharArray());

    if (configStorage.getHttpProxyHost() != null && configStorage.getHttpProxyPort() > 0) {
      this.httpProxy = new HttpHost(configStorage.getHttpProxyHost(), configStorage.getHttpProxyPort());
    }

    this.httpClient = apacheHttpClientBuilder.build();
  }

具体的类:WxMpServiceHttpComponentsImpl
NPE具体的行: configStorage.getHttpProxyPassword().toCharArray()这里的toCharArray()会NPE。
第一次使用这个类库,我也不确定是真的NPE还是我的使用方式不对,麻烦大佬看下。</issue_description>

Comments on the Issue (you are @copilot in this section)

Custom agent used: 全部用中文
需要用中文,包括PR标题和分析总结过程


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@binarywang
Copy link
Owner

已在其他PR里修复

@binarywang binarywang closed this Jan 9, 2026
Copilot AI requested a review from binarywang January 9, 2026 06:25
Copilot stopped work on behalf of binarywang due to an error January 9, 2026 06:25
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.8后用httpclient5 NPE了。

2 participants