Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
<version>4.12.0</version>
<scope>provided</scope>
</dependency>
<!-- HttpClient 5.x - 默认依赖(推荐使用) -->
<!-- HttpClient 5.x - 可选依赖,显式使用 HttpComponents 实现时需要 -->
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>

@augmentcode augmentcode Bot Jul 7, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pom.xml:168 这里在 dependencyManagement 中声明的 httpclient5 没有统一管理成 provided/optional,虽然注释写“可选”,但某些模块若未显式写 scope 会把 HC5 以 compile 传递给使用方(例如 weixin-java-aispeech 当前就是无 <scope> 声明)。考虑在这里统一约束 scope 以避免依赖树意外变重。

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Expand Down
2 changes: 0 additions & 2 deletions weixin-java-channel/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,10 @@
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @author <a href="https://github.com/lixize">Zeyes</a>
*/
@Slf4j
public class WxChannelServiceImpl extends WxChannelServiceHttpComponentsImpl {
public class WxChannelServiceImpl extends WxChannelServiceHttpClientImpl {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 修正 Channel Starter 的 HttpComponents 默认实现

单应用 Channel 的 Spring 和 Solon AutoConfiguration 都始终 new WxChannelServiceImpl(),同时各自的 WxChannelProperties 默认 httpClientType = HttpComponents;这行把默认类改成 HC4 后,使用 Starter 默认配置的应用会静默得到 APACHE_HTTP,不再符合 Starter 的默认 HttpComponents 语义。需要同步改 AutoConfiguration 按配置创建 WxChannelServiceHttpComponentsImpl,或调整 Starter 默认值。

Useful? React with 👍 / 👎.


public WxChannelServiceImpl() {
}
Expand Down
5 changes: 2 additions & 3 deletions weixin-java-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@
<artifactId>okhttp</artifactId>
<scope>provided</scope>
</dependency>
<!-- HttpClient 5.x - 默认依赖(推荐使用) -->
<!-- HttpClient 5.x - 可选依赖,显式使用 HttpComponents 实现时需要 -->
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
<scope>provided</scope>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 保留 Starter 的 HttpClient5 运行时依赖

这里把 httpclient5 改成 provided 后,依赖 weixin-java-common 的 Starter 不再向用户应用传递 HC5;但多个 Starter 仍会默认或在 HttpComponents 分支创建 *HttpComponentsImpl(例如 Spring MiniApp 的 WxMaProperties 默认 HttpComponents,AutoConfiguration 创建 WxMaServiceHttpComponentsImpl,而该 Starter POM 没有直接声明 httpclient5)。用户只引入 Starter 并使用默认配置时,setConfig/initHttp 加载 HC5 实现会因缺少 org.apache.hc.* 类失败;需要在这些 Starter 直接声明 httpclient5,或不要从 common 的传递依赖中移除它。

Useful? React with 👍 / 👎.

</dependency>

<!-- HttpClient 4.x - 默认依赖(为了保持向后兼容) -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<scope>provided</scope>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
Expand All @@ -45,7 +45,6 @@
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>

@augmentcode augmentcode Bot Jul 7, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weixin-java-common/pom.xml:47 目前只在 httpclient 依赖上排除了 commons-logging,但 httpmime 变为 compile 依赖后可能通过传递依赖把 commons-logging 再引入,进而与本模块的 jcl-over-slf4j 产生桥接失效/类冲突风险;建议确认所有引入路径都已排除。

Severity: medium

Other Locations
  • weixin-java-channel/pom.xml:34
  • weixin-java-channel/pom.xml:38
  • weixin-java-miniapp/pom.xml:36
  • weixin-java-miniapp/pom.xml:40
  • weixin-java-mp/pom.xml:36
  • weixin-java-mp/pom.xml:40
  • weixin-java-open/pom.xml:53
  • weixin-java-open/pom.xml:57
  • weixin-java-cp/pom.xml:35
  • weixin-java-qidian/pom.xml:36

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

<scope>provided</scope>
</dependency>

<dependency>
Expand Down
1 change: 0 additions & 1 deletion weixin-java-cp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
Expand Down
2 changes: 0 additions & 2 deletions weixin-java-miniapp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,10 @@
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
* @author <a href="https://github.com/binarywang">Binary Wang</a>
*/
@Slf4j
public class WxMaServiceImpl extends WxMaServiceHttpComponentsImpl {
public class WxMaServiceImpl extends WxMaServiceHttpClientImpl {

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.error.WxMpErrorMsgEnum;
import me.chanjar.weixin.common.util.http.HttpClientType;
import me.chanjar.weixin.common.util.http.RequestExecutor;
import org.apache.commons.lang3.StringUtils;
import org.mockito.Mockito;
Expand Down Expand Up @@ -118,6 +119,8 @@ public void testGetRequestHttpProxy() {

@Test
public void testGetRequestType() {
assertThat(new WxMaServiceImpl().getRequestType()).isEqualTo(HttpClientType.APACHE_HTTP);
assertThat(new WxMaServiceHttpComponentsImpl().getRequestType()).isEqualTo(HttpClientType.HTTP_COMPONENTS);
}

@Test
Expand Down
2 changes: 0 additions & 2 deletions weixin-java-mp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,10 @@
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
Comment on lines 35 to 36

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 排除重新传递的 commons-logging

这些业务模块把 httpclientprovided 改成传递依赖时,没有保留 weixin-java-commoncommons-logging 的排除;因此依赖 weixin-java-mp(miniapp/channel/open/cp/qidian 也类似)的下游会同时拿到 commons-logging 和 common 里的 jcl-over-slf4j,两者提供同一组 org.apache.commons.logging 类,运行时类路径顺序可能让日志桥接失效。建议在这些新传递的 httpclient 依赖上加同样的 exclusion,或直接依赖 common 的已排除版本。

Useful? React with 👍 / 👎.

<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

/**
* <pre>
* 默认接口实现类,使用apache httpClient 5实现
* 默认接口实现类,使用 Apache HttpClient 4 实现.
* Created by Binary Wang on 2017-5-27.
* </pre>
*
* @author <a href="https://github.com/binarywang">Binary Wang</a>
*/
public class WxMpServiceImpl extends WxMpServiceHttpComponentsImpl {
public class WxMpServiceImpl extends WxMpServiceHttpClientImpl {
}
2 changes: 0 additions & 2 deletions weixin-java-open/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,10 @@
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
/**
* @author <a href="https://github.com/007gzs">007</a>
*/
public class WxOpenServiceImpl extends WxOpenServiceHttpComponentsImpl {
public class WxOpenServiceImpl extends WxOpenServiceApacheHttpClientImpl {

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

/**
* <pre>
* 微信支付接口请求实现类,默认使用Apache HttpClient 5实现
* 微信支付接口请求实现类,默认使用 Apache HttpClient 4 实现.
* Created by Binary Wang on 2017-7-8.
* </pre>
*
* @author <a href="https://github.com/binarywang">Binary Wang</a>
*/
public class WxPayServiceImpl extends WxPayServiceHttpComponentsImpl {
public class WxPayServiceImpl extends WxPayServiceApacheHttpImpl {
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ public class BaseWxPayServiceImplTest {
@Inject
private WxPayService payService;

@Test
public void testDefaultImplUsesApacheHttpClient() {
assertThat(new WxPayServiceImpl()).isInstanceOf(WxPayServiceApacheHttpImpl.class);
}

/**
* Test method for {@link WxPayService#unifiedOrder(WxPayUnifiedOrderRequest)}.
*
Expand Down
1 change: 0 additions & 1 deletion weixin-java-qidian/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

/**
* <pre>
* 默认接口实现类,使用apache httpClient 5实现
* 默认接口实现类,使用 Apache HttpClient 4 实现.
* Created by Binary Wang on 2017-5-27.
* </pre>
*
* @author <a href="https://github.com/binarywang">Binary Wang</a>
*/
public class WxQidianServiceImpl extends WxQidianServiceHttpComponentsImpl {
public class WxQidianServiceImpl extends WxQidianServiceHttpClientImpl {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 修正 Qidian Spring Starter 的 HttpComponents 分支

Spring Boot Qidian Starter 的 WxQidianProperties 默认 HttpComponents,但 WxQidianServiceAutoConfiguration 没有 case HttpComponents,会落到 new WxQidianServiceImpl();这行改为继承 HC4 后,默认配置或显式选择 HttpComponents 的 Spring 用户都会得到 HttpClient 实现。需要补上 WxQidianServiceHttpComponentsImpl 分支,或同步调整默认配置。

Useful? React with 👍 / 👎.

}