perf:阿里云短信中TreeMap改为ConcurrentHashMap
This commit is contained in:
@@ -15,7 +15,12 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author admin
|
* @author admin
|
||||||
@@ -56,9 +61,9 @@ public class AliyunSmsSender implements TieshengMessageSender {
|
|||||||
* @param map 业务参数
|
* @param map 业务参数
|
||||||
* @return 返回数据
|
* @return 返回数据
|
||||||
*/
|
*/
|
||||||
public String request(String action, SortedMap<String, String> map) {
|
public String request(String action, ConcurrentHashMap<String, String> map) {
|
||||||
|
|
||||||
SortedMap<String, String> queryMap = new TreeMap<>();
|
ConcurrentHashMap<String, String> queryMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
// 系统参数
|
// 系统参数
|
||||||
queryMap.put("AccessKeyId", getAccessKeyId());
|
queryMap.put("AccessKeyId", getAccessKeyId());
|
||||||
@@ -77,7 +82,9 @@ public class AliyunSmsSender implements TieshengMessageSender {
|
|||||||
|
|
||||||
// 构造带签名字符串
|
// 构造带签名字符串
|
||||||
StringBuilder sortQueryStringTmp = new StringBuilder();
|
StringBuilder sortQueryStringTmp = new StringBuilder();
|
||||||
for (String key : queryMap.keySet()) {
|
|
||||||
|
List<String> list = queryMap.keySet().stream().sorted().collect(Collectors.toList());
|
||||||
|
for (String key : list) {
|
||||||
sortQueryStringTmp.append("&").append(specialUrlEncode(key)).append("=").append(specialUrlEncode(queryMap.get(key)));
|
sortQueryStringTmp.append("&").append(specialUrlEncode(key)).append("=").append(specialUrlEncode(queryMap.get(key)));
|
||||||
}
|
}
|
||||||
String sortedQueryString = sortQueryStringTmp.substring(1);
|
String sortedQueryString = sortQueryStringTmp.substring(1);
|
||||||
@@ -112,7 +119,7 @@ public class AliyunSmsSender implements TieshengMessageSender {
|
|||||||
.toString());
|
.toString());
|
||||||
|
|
||||||
// 业务API参数
|
// 业务API参数
|
||||||
SortedMap<String, String> queryMap = new TreeMap<>();
|
ConcurrentHashMap<String, String> queryMap = new ConcurrentHashMap<>();
|
||||||
queryMap.put("PhoneNumbers", phoneNumbers);
|
queryMap.put("PhoneNumbers", phoneNumbers);
|
||||||
queryMap.put("SignName", getSignName());
|
queryMap.put("SignName", getSignName());
|
||||||
queryMap.put("TemplateCode", templateCode);
|
queryMap.put("TemplateCode", templateCode);
|
||||||
|
|||||||
Reference in New Issue
Block a user