Skip to content

Commit 1f736ad

Browse files
committed
优化注释和README
1 parent 6c239d1 commit 1f736ad

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ WechatPayHttpClientBuilder builder = WechatPayHttpClientBuilder.create()
6464
// ... 接下来,你仍然可以通过builder设置各种参数,来配置你的HttpClient
6565

6666
// 通过WechatPayHttpClientBuilder构造的HttpClient,会自动的处理签名和验签
67-
HttpClient httpClient = builder.build();
67+
CloseableHttpClient httpClient = builder.build();
6868

6969
// 后面跟使用Apache HttpClient一样
70-
HttpResponse response = httpClient.execute(...);
70+
ClosableHttpResponse response = httpClient.execute(...);
7171
```
7272

7373
参数说明:
@@ -200,10 +200,10 @@ WechatPayHttpClientBuilder builder = WechatPayHttpClientBuilder.create()
200200
// ... 接下来,你仍然可以通过builder设置各种参数,来配置你的HttpClient
201201

202202
// 通过WechatPayHttpClientBuilder构造的HttpClient,会自动的处理签名和验签,并进行证书自动更新
203-
HttpClient httpClient = builder.build();
203+
CloseableHttpClient httpClient = builder.build();
204204

205205
// 后面跟使用Apache HttpClient一样
206-
HttpResponse response = httpClient.execute(...);
206+
CloseableHttpResponse response = httpClient.execute(...);
207207
```
208208

209209
### 风险

src/main/java/com/wechat/pay/contrib/apache/httpclient/auth/AutoUpdateCertificatesVerifier.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
/**
3434
* 在原有CertificatesVerifier基础上,增加自动更新证书功能
35-
* 该类已废弃,请使用 ScheduledUpdateCertificatesVerifier
35+
* 该类已废弃,请使用ScheduledUpdateCertificatesVerifier
3636
*
3737
* @author xy-peng
3838
*/

src/main/java/com/wechat/pay/contrib/apache/httpclient/auth/CertificatesVerifier.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public X509Certificate getValidCertificate() {
7676
public X509Certificate getLatestCertificate() {
7777
X509Certificate latestCert = null;
7878
for (X509Certificate x509Cert : certificates.values()) {
79-
// 若 latestCert 为空或 x509Cert 的证书有效开始时间在 latestCert 之后,则更新 latestCert
79+
// 若latestCert为空或x509Cert的证书有效开始时间在latestCert之后,则更新latestCert
8080
if (latestCert == null || x509Cert.getNotBefore().after(latestCert.getNotBefore())) {
8181
latestCert = x509Cert;
8282
}

src/main/java/com/wechat/pay/contrib/apache/httpclient/auth/ScheduledUpdateCertificatesVerifier.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import java.util.concurrent.locks.ReentrantLock;
77

88
/**
9-
* 在原有 CertificatesVerifier 基础上,增加定时更新证书功能(默认1小时)
9+
* 在原有CertificatesVerifier基础上,增加定时更新证书功能(默认1小时)
1010
*/
1111
public class ScheduledUpdateCertificatesVerifier implements Verifier {
1212

@@ -30,7 +30,7 @@ public ScheduledUpdateCertificatesVerifier(Credentials credentials, byte[] apiv3
3030
*/
3131
public void initCertManager(Credentials credentials, byte[] apiv3Key) {
3232
if (credentials == null || apiv3Key.length == 0) {
33-
throw new IllegalArgumentException("credentials 或 apiv3Key 为空");
33+
throw new IllegalArgumentException("credentials或apiv3Key为空");
3434
}
3535
certManagerSingleton.init(credentials, apiv3Key, UPDATE_INTERVAL_MINUTE);
3636
}
@@ -43,7 +43,7 @@ public X509Certificate getLatestCertificate() {
4343
@Override
4444
public boolean verify(String serialNumber, byte[] message, String signature) {
4545
if (serialNumber.isEmpty() || message.length == 0 || signature.isEmpty()) {
46-
throw new IllegalArgumentException("serialNumber 或 message 或 signature 为空");
46+
throw new IllegalArgumentException("serialNumber或message或signature为空");
4747
}
4848
if (lock.tryLock()) {
4949
try {
@@ -68,7 +68,7 @@ public X509Certificate getValidCertificate() {
6868

6969

7070
/**
71-
* 停止定时更新,停止无法再重新启动
71+
* 停止定时更新,停止后无法再重新启动
7272
*/
7373
public void stopScheduledUpdate() {
7474
certManagerSingleton.close();

src/main/java/com/wechat/pay/contrib/apache/httpclient/auth/Verifier.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public interface Verifier {
1010
boolean verify(String serialNumber, byte[] message, String signature);
1111

1212
/**
13-
* 该方法已废弃,请使用 getLatestCertificate 代替
13+
* 该方法已废弃,请使用getLatestCertificate代替
1414
*/
1515
@Deprecated
1616
X509Certificate getValidCertificate();

src/main/java/com/wechat/pay/contrib/apache/httpclient/cert/CertManagerSingleton.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ public class CertManagerSingleton {
3636
* 证书下载地址
3737
*/
3838
private static final String CERT_DOWNLOAD_PATH = "https://api.mch.weixin.qq.com/v3/certificates";
39-
private static final String SCHEDULE_UPDATE_CERT_THREAD_NAME = "schedule_update_cert_thread";
39+
private static final String SCHEDULE_UPDATE_CERT_THREAD_NAME = "scheduled_update_cert_thread";
4040
private volatile static CertManagerSingleton instance = null;
4141
private byte[] apiV3Key;
4242
/**
43-
* 平台证书 map
43+
* 平台证书map
4444
*/
4545
private ConcurrentHashMap<BigInteger, X509Certificate> certificates;
4646
private Credentials credentials;
@@ -77,7 +77,7 @@ public static CertManagerSingleton getInstance() {
7777
*/
7878
public synchronized void init(Credentials credentials, byte[] apiV3Key, long minutesInterval) {
7979
if (credentials == null || apiV3Key.length == 0 || minutesInterval == 0) {
80-
throw new IllegalArgumentException("credentials 或 apiV3Key 或 minutesInterval 为空");
80+
throw new IllegalArgumentException("credentials或apiV3Key或minutesInterval为空");
8181
}
8282
if (this.credentials == null || this.apiV3Key.length == 0 || this.executor == null
8383
|| this.certificates == null) {
@@ -109,7 +109,7 @@ public synchronized void init(Credentials credentials, byte[] apiV3Key, long min
109109
*/
110110
public void close() {
111111
if (executor == null) {
112-
throw new IllegalStateException("请先调用 init 方法初始化实例");
112+
throw new IllegalStateException("请先调用init方法初始化实例");
113113
}
114114
try {
115115
executor.shutdownNow();
@@ -123,7 +123,7 @@ public void close() {
123123
*/
124124
public Map<BigInteger, X509Certificate> getCertificates() {
125125
if (certificates == null) {
126-
throw new IllegalStateException("请先调用 init 方法初始化实例");
126+
throw new IllegalStateException("请先调用init方法初始化实例");
127127
}
128128
return certificates;
129129
}
@@ -135,11 +135,11 @@ public Map<BigInteger, X509Certificate> getCertificates() {
135135
*/
136136
public X509Certificate getLatestCertificate() {
137137
if (certificates == null) {
138-
throw new IllegalStateException("请先调用 init 方法初始化实例");
138+
throw new IllegalStateException("请先调用init方法初始化实例");
139139
}
140140
X509Certificate latestCert = null;
141141
for (X509Certificate x509Cert : certificates.values()) {
142-
// 若 latestCert 为空或 x509Cert 的证书有效开始时间在 latestCert 之后,则更新 latestCert
142+
// 若latestCert为空或x509Cert的证书有效开始时间在latestCert之后,则更新latestCert
143143
if (latestCert == null || x509Cert.getNotBefore().after(latestCert.getNotBefore())) {
144144
latestCert = x509Cert;
145145
}

0 commit comments

Comments
 (0)