Skip to content

Commit 55e0653

Browse files
committed
修复更多的warning,尤其是导致打包warning的不规范或不必要的javadoc
1 parent 5d95758 commit 55e0653

File tree

19 files changed

+79
-183
lines changed

19 files changed

+79
-183
lines changed

weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/WxMenu.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package me.chanjar.weixin.common.bean;
22

3-
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
4-
import org.apache.commons.codec.Charsets;
5-
63
import java.io.InputStream;
74
import java.io.InputStreamReader;
85
import java.io.Serializable;
6+
import java.nio.charset.StandardCharsets;
97
import java.util.ArrayList;
108
import java.util.List;
119

10+
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
11+
1212
/**
1313
* 企业号菜单
1414
* @author Daniel Qian
@@ -45,8 +45,6 @@ public String toJson() {
4545
/**
4646
* 要用 http://mp.weixin.qq.com/wiki/16/ff9b7b85220e1396ffa16794a9d95adc.html 格式来反序列化
4747
* 相比 http://mp.weixin.qq.com/wiki/13/43de8269be54a0a6f64413e4dfa94f39.html 的格式,外层多套了一个menu
48-
* @param json
49-
* @return
5048
*/
5149
public static WxMenu fromJson(String json) {
5250
return WxGsonBuilder.create().fromJson(json, WxMenu.class);
@@ -55,11 +53,9 @@ public static WxMenu fromJson(String json) {
5553
/**
5654
* 要用 http://mp.weixin.qq.com/wiki/16/ff9b7b85220e1396ffa16794a9d95adc.html 格式来反序列化
5755
* 相比 http://mp.weixin.qq.com/wiki/13/43de8269be54a0a6f64413e4dfa94f39.html 的格式,外层多套了一个menu
58-
* @param is
59-
* @return
6056
*/
6157
public static WxMenu fromJson(InputStream is) {
62-
return WxGsonBuilder.create().fromJson(new InputStreamReader(is, Charsets.UTF_8), WxMenu.class);
58+
return WxGsonBuilder.create().fromJson(new InputStreamReader(is, StandardCharsets.UTF_8), WxMenu.class);
6359
}
6460

6561
@Override
@@ -195,7 +191,7 @@ public void setLanguage(String language) {
195191
this.language = language;
196192
}
197193

198-
@Override
194+
@Override
199195
public String toString() {
200196
return "matchrule:{" +
201197
"tag_id='" + tagId + '\'' +

weixin-java-common/src/main/java/me/chanjar/weixin/common/session/WxSessionManager.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,11 @@ public interface WxSessionManager {
44

55
/**
66
* 获取某个sessionId对应的session,如果sessionId没有对应的session,则新建一个并返回。
7-
* @param sessionId
8-
* @return
97
*/
108
public WxSession getSession(String sessionId);
119

1210
/**
1311
* 获取某个sessionId对应的session,如果sessionId没有对应的session,若create为true则新建一个,否则返回null。
14-
* @param sessionId
15-
* @param create
16-
* @return
1712
*/
1813
public WxSession getSession(String sessionId, boolean create);
1914

weixin-java-common/src/main/java/me/chanjar/weixin/common/util/crypto/SHA1.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ public class SHA1 {
1212

1313
/**
1414
* 串接arr参数,生成sha1 digest
15-
*
16-
* @param arr
17-
* @return
1815
*/
1916
public static String gen(String... arr) throws NoSuchAlgorithmException {
2017
Arrays.sort(arr);
@@ -27,9 +24,6 @@ public static String gen(String... arr) throws NoSuchAlgorithmException {
2724

2825
/**
2926
* 用&串接arr参数,生成sha1 digest
30-
*
31-
* @param arr
32-
* @return
3327
*/
3428
public static String genWithAmple(String... arr) throws NoSuchAlgorithmException {
3529
Arrays.sort(arr);

weixin-java-common/src/main/java/me/chanjar/weixin/common/util/crypto/WxCryptUtil.java

Lines changed: 52 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,16 @@ public class WxCryptUtil {
3535
private static final Base64 base64 = new Base64();
3636
private static final Charset CHARSET = Charset.forName("utf-8");
3737

38-
private static final ThreadLocal<DocumentBuilder> builderLocal =
39-
new ThreadLocal<DocumentBuilder>() {
40-
@Override protected DocumentBuilder initialValue() {
41-
try {
42-
return DocumentBuilderFactory.newInstance().newDocumentBuilder();
43-
} catch (ParserConfigurationException exc) {
44-
throw new IllegalArgumentException(exc);
45-
}
46-
}
47-
};
38+
private static final ThreadLocal<DocumentBuilder> builderLocal = new ThreadLocal<DocumentBuilder>() {
39+
@Override
40+
protected DocumentBuilder initialValue() {
41+
try {
42+
return DocumentBuilderFactory.newInstance().newDocumentBuilder();
43+
} catch (ParserConfigurationException exc) {
44+
throw new IllegalArgumentException(exc);
45+
}
46+
}
47+
};
4848

4949
protected byte[] aesKey;
5050
protected String token;
@@ -61,7 +61,8 @@ public WxCryptUtil() {
6161
* @param encodingAesKey 公众平台上,开发者设置的EncodingAESKey
6262
* @param appidOrCorpid 公众平台appid/corpid
6363
*/
64-
public WxCryptUtil(String token, String encodingAesKey, String appidOrCorpid) {
64+
public WxCryptUtil(String token, String encodingAesKey,
65+
String appidOrCorpid) {
6566
this.token = token;
6667
this.appidOrCorpid = appidOrCorpid;
6768
this.aesKey = Base64.decodeBase64(encodingAesKey + "=");
@@ -105,7 +106,8 @@ protected String encrypt(String randomStr, String plainText) {
105106
ByteGroup byteCollector = new ByteGroup();
106107
byte[] randomStringBytes = randomStr.getBytes(CHARSET);
107108
byte[] plainTextBytes = plainText.getBytes(CHARSET);
108-
byte[] bytesOfSizeInNetworkOrder = number2BytesInNetworkOrder(plainTextBytes.length);
109+
byte[] bytesOfSizeInNetworkOrder = number2BytesInNetworkOrder(
110+
plainTextBytes.length);
109111
byte[] appIdBytes = appidOrCorpid.getBytes(CHARSET);
110112

111113
// randomStr + networkBytesOrder + text + appid
@@ -154,7 +156,8 @@ protected String encrypt(String randomStr, String plainText) {
154156
* @param encryptedXml 密文,对应POST请求的数据
155157
* @return 解密后的原文
156158
*/
157-
public String decrypt(String msgSignature, String timeStamp, String nonce, String encryptedXml) {
159+
public String decrypt(String msgSignature, String timeStamp, String nonce,
160+
String encryptedXml) {
158161
// 密钥,公众账号的app corpSecret
159162
// 提取密文
160163
String cipherText = extractEncryptPart(encryptedXml);
@@ -186,7 +189,8 @@ public String decrypt(String cipherText) {
186189
// 设置解密模式为AES的CBC模式
187190
Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
188191
SecretKeySpec key_spec = new SecretKeySpec(aesKey, "AES");
189-
IvParameterSpec iv = new IvParameterSpec(Arrays.copyOfRange(aesKey, 0, 16));
192+
IvParameterSpec iv = new IvParameterSpec(
193+
Arrays.copyOfRange(aesKey, 0, 16));
190194
cipher.init(Cipher.DECRYPT_MODE, key_spec, iv);
191195

192196
// 使用BASE64对密文进行解码
@@ -208,9 +212,10 @@ public String decrypt(String cipherText) {
208212

209213
int xmlLength = bytesNetworkOrder2Number(networkOrder);
210214

211-
xmlContent = new String(Arrays.copyOfRange(bytes, 20, 20 + xmlLength), CHARSET);
212-
from_appid = new String(Arrays.copyOfRange(bytes, 20 + xmlLength, bytes.length),
215+
xmlContent = new String(Arrays.copyOfRange(bytes, 20, 20 + xmlLength),
213216
CHARSET);
217+
from_appid = new String(
218+
Arrays.copyOfRange(bytes, 20 + xmlLength, bytes.length), CHARSET);
214219
} catch (Exception e) {
215220
throw new RuntimeException(e);
216221
}
@@ -224,34 +229,32 @@ public String decrypt(String cipherText) {
224229

225230
}
226231

227-
/**
228-
* 微信公众号支付签名算法(详见:http://pay.weixin.qq.com/wiki/doc/api/index.php?chapter=4_3)
229-
* @param packageParams 原始参数
230-
* @param signKey 加密Key(即 商户Key)
231-
* @param charset 编码
232-
* @return 签名字符串
233-
*/
234-
public static String createSign(Map<String, String> packageParams, String signKey) {
235-
SortedMap<String, String> sortedMap = new TreeMap<String, String>();
236-
sortedMap.putAll(packageParams);
237-
238-
List<String> keys = new ArrayList<String>(packageParams.keySet());
239-
Collections.sort(keys);
240-
241-
242-
StringBuffer toSign = new StringBuffer();
243-
for (String key : keys) {
244-
String value = packageParams.get(key);
245-
if (null != value && !"".equals(value) && !"sign".equals(key)
246-
&& !"key".equals(key)) {
247-
toSign.append(key + "=" + value + "&");
248-
}
249-
}
250-
toSign.append("key=" + signKey);
251-
String sign = DigestUtils.md5Hex(toSign.toString())
252-
.toUpperCase();
253-
return sign;
232+
/**
233+
* 微信公众号支付签名算法(详见:http://pay.weixin.qq.com/wiki/doc/api/index.php?chapter=4_3)
234+
* @param packageParams 原始参数
235+
* @param signKey 加密Key(即 商户Key)
236+
* @return 签名字符串
237+
*/
238+
public static String createSign(Map<String, String> packageParams,
239+
String signKey) {
240+
SortedMap<String, String> sortedMap = new TreeMap<String, String>();
241+
sortedMap.putAll(packageParams);
242+
243+
List<String> keys = new ArrayList<String>(packageParams.keySet());
244+
Collections.sort(keys);
245+
246+
StringBuffer toSign = new StringBuffer();
247+
for (String key : keys) {
248+
String value = packageParams.get(key);
249+
if (null != value && !"".equals(value) && !"sign".equals(key)
250+
&& !"key".equals(key)) {
251+
toSign.append(key + "=" + value + "&");
252+
}
254253
}
254+
toSign.append("key=" + signKey);
255+
String sign = DigestUtils.md5Hex(toSign.toString()).toUpperCase();
256+
return sign;
257+
}
255258

256259
/**
257260
* 将一个数字转换成生成4个字节的网络字节序bytes数组
@@ -283,8 +286,6 @@ private int bytesNetworkOrder2Number(byte[] bytesInNetworkOrder) {
283286

284287
/**
285288
* 随机生成16位字符串
286-
*
287-
* @return
288289
*/
289290
private String genRandomStr() {
290291
String base = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
@@ -306,14 +307,12 @@ private String genRandomStr() {
306307
* @param nonce 随机字符串
307308
* @return 生成的xml字符串
308309
*/
309-
private String generateXml(String encrypt, String signature, String timestamp, String nonce) {
310-
String format =
311-
"<xml>\n"
312-
+ "<Encrypt><![CDATA[%1$s]]></Encrypt>\n"
313-
+ "<MsgSignature><![CDATA[%2$s]]></MsgSignature>\n"
314-
+ "<TimeStamp>%3$s</TimeStamp>\n"
315-
+ "<Nonce><![CDATA[%4$s]]></Nonce>\n"
316-
+ "</xml>";
310+
private String generateXml(String encrypt, String signature, String timestamp,
311+
String nonce) {
312+
String format = "<xml>\n" + "<Encrypt><![CDATA[%1$s]]></Encrypt>\n"
313+
+ "<MsgSignature><![CDATA[%2$s]]></MsgSignature>\n"
314+
+ "<TimeStamp>%3$s</TimeStamp>\n" + "<Nonce><![CDATA[%4$s]]></Nonce>\n"
315+
+ "</xml>";
317316
return String.format(format, encrypt, signature, timestamp, nonce);
318317
}
319318

weixin-java-common/src/main/java/me/chanjar/weixin/common/util/fs/FileUtils.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ public class FileUtils {
1414
* @param name 文件名
1515
* @param ext 扩展名
1616
* @param tmpDirFile 临时文件夹目录
17-
* @return
18-
* @throws IOException
1917
*/
2018
public static File createTmpFile(InputStream inputStream, String name, String ext, File tmpDirFile) throws IOException {
2119
FileOutputStream fos = null;
@@ -56,8 +54,6 @@ public static File createTmpFile(InputStream inputStream, String name, String ex
5654
* @param inputStream
5755
* @param name 文件名
5856
* @param ext 扩展名
59-
* @return
60-
* @throws IOException
6157
*/
6258
public static File createTmpFile(InputStream inputStream, String name, String ext) throws IOException {
6359
return createTmpFile(inputStream, name, ext, null);

weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/ApacheHttpClientBuilder.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,35 +17,30 @@ public interface ApacheHttpClientBuilder {
1717
/**
1818
* 代理服务器地址
1919
* @param httpProxyHost
20-
* @return
2120
*/
2221
ApacheHttpClientBuilder httpProxyHost(String httpProxyHost);
2322

2423
/**
2524
* 代理服务器端口
2625
* @param httpProxyPort
27-
* @return
2826
*/
2927
ApacheHttpClientBuilder httpProxyPort(int httpProxyPort);
3028

3129
/**
3230
* 代理服务器用户名
3331
* @param httpProxyUsername
34-
* @return
3532
*/
3633
ApacheHttpClientBuilder httpProxyUsername(String httpProxyUsername);
3734

3835
/**
3936
* 代理服务器密码
4037
* @param httpProxyPassword
41-
* @return
4238
*/
4339
ApacheHttpClientBuilder httpProxyPassword(String httpProxyPassword);
4440

4541
/**
4642
* ssl连接socket工厂
4743
* @param sslConnectionSocketFactory
48-
* @return
4944
*/
5045
ApacheHttpClientBuilder sslConnectionSocketFactory(SSLConnectionSocketFactory sslConnectionSocketFactory);
5146
}

weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/RequestExecutor.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ public interface RequestExecutor<T, E> {
2222
* @param httpProxy http代理对象,如果没有配置代理则为空
2323
* @param uri uri
2424
* @param data 数据
25-
* @return
2625
* @throws WxErrorException
2726
* @throws ClientProtocolException
2827
* @throws IOException

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpMessageMatcher.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ public interface WxCpMessageMatcher {
99

1010
/**
1111
* 消息是否匹配某种模式
12-
* @param message
13-
* @return
1412
*/
1513
public boolean match(WxCpXmlMessage message);
1614

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpMessageRouter.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ List<WxCpMessageRouterRule> getRules() {
124124

125125
/**
126126
* 开始一个新的Route规则
127-
* @return
128127
*/
129128
public WxCpMessageRouterRule rule() {
130129
return new WxCpMessageRouterRule(this);

0 commit comments

Comments
 (0)