Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
dd40714
:art: #3530 【微信支付】修复未设置平台证书引起的v3请求构造异常
SynchPj Apr 7, 2025
3f0b8d4
:art: #3538 【微信支付】V3接口增加实名支付参数
cloudX2019 Apr 7, 2025
4828a31
:art: #3534 为connectionRequestTimeout设置默认值,避免开发者在虚拟线程中调用框架的httpClient…
yangmengyu2021 Apr 7, 2025
0452a05
:art: 【小程序】修复物流服务查询组件更新物品信息接口的地址
Mar 19, 2025
b6c3d74
:new: #3529 【企业微信】增加批量设置应用在用户工作台展示的数据的接口
TanXiao1005 Mar 19, 2025
b44dd2e
:art: #3541【企业微信】增加设置WebView型应用在用户工作台展示的参数
TanXiao1005 Apr 7, 2025
373c1e6
:bug: #3522 【公众号】修复WxMpMapConfigImpl静态属性存储token导致多个实例时出现token没有隔离的情况
jimmyjimmy-sw Apr 7, 2025
833ff70
【企业微信】接待人员管理 添加接待人员/删除接待人员 增加 department_id_list
Mar 27, 2025
0423e68
:bookmark: 发布 4.7.4.B 测试版本
binarywang Apr 8, 2025
89280ab
:art: #3547【微信支付】修复验证器未正确初始化导致的v3请求构造异常问题
holylcd Apr 14, 2025
e16e0e9
:art: #3548【微信支付】修复公钥模式下V3接口未设置Wechatpay-Serial请求头导致的验签失败
HerveyHall Apr 15, 2025
bb76db0
:art: #3554【企业微信】修复审批通知节点获取不到用户ID的问题
hrygddv Apr 15, 2025
3718b49
:art: #3554【企业微信】修复审批通知节点获取不到用户ID的问题
hrygddv Apr 16, 2025
59f5a99
:new: 添加wx-java-channel-solon-plugin README.md
noear Apr 21, 2025
6a4ed91
:art: #3558 【企业微信】修复会话内容存档接口获取解密的聊天数据时文件信息转换出错的问题
tang2330 Apr 21, 2025
ddfbee2
:bug: #3557 【企业微信】修复agentId数据类型不一致导致的WxCpTpMessageRouterRule.test()方法…
giveup Apr 21, 2025
cbb3b24
:art: #3553【微信支付】v3请求统一加上Wechatpay-Serial请求头
SynchPj Apr 22, 2025
2279105
:art: 优化微信支付请求代码,抽取合并重复代码
binarywang Apr 26, 2025
2d8d1df
:new: #3320【企业微信】增加异步上传临时素材相关接口
imyzt Apr 29, 2025
854b50b
:art: 修复日志代码报错问题
binarywang Apr 29, 2025
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
Prev Previous commit
Next Next commit
🐛 binarywang#3522 【公众号】修复WxMpMapConfigImpl静态属性存储token导致多个实例时出现token没有…
…隔离的情况
  • Loading branch information
jimmyjimmy-sw authored Apr 7, 2025
commit 373c1e65cbc3e1efcc3691728bacadd7fc7d95a7
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class WxMpMapConfigImpl extends WxMpDefaultConfigImpl {

private static final long serialVersionUID = 5311395137835650104L;

private static final ConcurrentHashMap<String, String> CONCURRENT_HASH_MAP = new ConcurrentHashMap<>(1);
private final ConcurrentHashMap<String, String> CONCURRENT_HASH_MAP = new ConcurrentHashMap<>(1);

private static final String MAP_KEY = "access_token";

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package me.chanjar.weixin.mp.api.impl;

import com.google.inject.Inject;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.config.impl.WxMpMapConfigImpl;
import me.chanjar.weixin.mp.util.WxMpConfigStorageHolder;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;

/**
* 测试 ConcurrentHashMap 保存配置信息
* @author jimmyjimmy-sw
*/
@Test
@Guice(modules = ApiTestModule.class)
public class WxMpMapConfigImplTest {

@Inject
private WxMpService wxService;

/**
* 测试多租户保存 WxMpMapConfigImpl 到 WxMpService,切换之后能获取到租户各自AppId对应的token
* @throws WxErrorException
*/
@Test
public void testAppidSwitch() throws WxErrorException {
// 保存租户A的配置信息,并获取token
WxMpMapConfigImpl configAppA = new WxMpMapConfigImpl();
String appidA = "APPID_A";
configAppA.setAppId(appidA);
configAppA.setSecret("APP_SECRET_A");
configAppA.useStableAccessToken(true);
String tokenA = "TOKEN_A";
configAppA.updateAccessToken(tokenA,60 * 60 * 1);
wxService.addConfigStorage(appidA, configAppA);
WxMpConfigStorageHolder.set(appidA);
assertEquals(this.wxService.getAccessToken(),tokenA);

// 保存租户B的配置信息,并获取token
WxMpMapConfigImpl configAppB = new WxMpMapConfigImpl();
String appidB = "APPID_B";
configAppB.setAppId(appidB);
configAppB.setSecret("APP_SECRET_B");
configAppB.useStableAccessToken(true);
String tokenB = "TOKEN_B";
configAppB.updateAccessToken(tokenB,60 * 60 * 1);
wxService.addConfigStorage(appidB, configAppB);
WxMpConfigStorageHolder.set(appidB);
assertEquals(this.wxService.getAccessToken(),tokenB);

// 上下文切换到租户A 获取租户A的token
WxMpConfigStorageHolder.set(appidA);
assertEquals(this.wxService.getAccessToken(),tokenA);
}
}