mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
optimize code to match p3c check rules
Signed-off-by: jimin.jm <jimin.jm@alibaba-inc.com>
This commit is contained in:
@@ -60,7 +60,7 @@ public class SmsInitializerEventListener
|
||||
// 初始化acsClient,暂不支持region化
|
||||
try {
|
||||
DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou",
|
||||
SmsProperties.smsProduct, SmsProperties.smsDomain);
|
||||
SmsProperties.SMS_PRODUCT, SmsProperties.SMS_DOMAIN);
|
||||
Collection<MessageListener> messageListeners = event.getApplicationContext()
|
||||
.getBeansOfType(MessageListener.class).values();
|
||||
if (messageListeners.isEmpty()) {
|
||||
|
@@ -85,8 +85,8 @@ public class DefaultAlicomMessagePuller {
|
||||
this.executorService = executorService;
|
||||
}
|
||||
|
||||
protected static final Map<String, Object> sLockObjMap = new HashMap<String, Object>();
|
||||
protected static Map<String, Boolean> sPollingMap = new ConcurrentHashMap<String, Boolean>();
|
||||
protected static final Map<String, Object> S_LOCK_OBJ_MAP = new HashMap<>();
|
||||
protected static Map<String, Boolean> sPollingMap = new ConcurrentHashMap<>();
|
||||
protected Object lockObj;
|
||||
|
||||
public boolean setPolling(String queueName) {
|
||||
@@ -309,11 +309,11 @@ public class DefaultAlicomMessagePuller {
|
||||
task.messageType = messageType;
|
||||
task.queueName = queueName;
|
||||
|
||||
synchronized (sLockObjMap) {
|
||||
lockObj = sLockObjMap.get(queueName);
|
||||
synchronized (S_LOCK_OBJ_MAP) {
|
||||
lockObj = S_LOCK_OBJ_MAP.get(queueName);
|
||||
if (lockObj == null) {
|
||||
lockObj = new Object();
|
||||
sLockObjMap.put(queueName, lockObj);
|
||||
S_LOCK_OBJ_MAP.put(queueName, lockObj);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -355,11 +355,11 @@ public class DefaultAlicomMessagePuller {
|
||||
task.messageType = messageType;
|
||||
task.queueName = queueName;
|
||||
|
||||
synchronized (sLockObjMap) {
|
||||
lockObj = sLockObjMap.get(queueName);
|
||||
synchronized (S_LOCK_OBJ_MAP) {
|
||||
lockObj = S_LOCK_OBJ_MAP.get(queueName);
|
||||
if (lockObj == null) {
|
||||
lockObj = new Object();
|
||||
sLockObjMap.put(queueName, lockObj);
|
||||
S_LOCK_OBJ_MAP.put(queueName, lockObj);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -402,11 +402,11 @@ public class DefaultAlicomMessagePuller {
|
||||
task.messageType = messageType;
|
||||
task.queueName = queueName;
|
||||
|
||||
synchronized (sLockObjMap) {
|
||||
lockObj = sLockObjMap.get(queueName);
|
||||
synchronized (S_LOCK_OBJ_MAP) {
|
||||
lockObj = S_LOCK_OBJ_MAP.get(queueName);
|
||||
if (lockObj == null) {
|
||||
lockObj = new Object();
|
||||
sLockObjMap.put(queueName, lockObj);
|
||||
S_LOCK_OBJ_MAP.put(queueName, lockObj);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -76,6 +76,7 @@ public class QueryTokenForMnsQueueRequest
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<QueryTokenForMnsQueueResponse> getResponseClass() {
|
||||
return QueryTokenForMnsQueueResponse.class;
|
||||
}
|
||||
|
@@ -60,6 +60,7 @@ public class QueryTokenForMnsQueueResponse extends AcsResponse {
|
||||
this.messageTokenDTO = messageTokenDTO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryTokenForMnsQueueResponse getInstance(UnmarshallerContext context) {
|
||||
return QueryTokenForMnsQueueResponseUnmarshaller.unmarshall(this, context);
|
||||
}
|
||||
|
@@ -50,7 +50,7 @@ public class TokenGetterForAlicom {
|
||||
private String domainForPop;
|
||||
private IAcsClient iAcsClient;
|
||||
private Long ownerId;
|
||||
private final static String productName = "Dybaseapi";
|
||||
private final static String PRODUCT_NAME = "Dybaseapi";
|
||||
private long bufferTime = 1000 * 60 * 2;// 过期时间小于2分钟则重新获取,防止服务器时间误差
|
||||
private final Object lock = new Object();
|
||||
private ConcurrentMap<String, TokenForAlicom> tokenMap = new ConcurrentHashMap<String, TokenForAlicom>();
|
||||
@@ -68,7 +68,7 @@ public class TokenGetterForAlicom {
|
||||
}
|
||||
|
||||
private void init() throws ClientException {
|
||||
DefaultProfile.addEndpoint(endpointNameForPop, regionIdForPop, productName,
|
||||
DefaultProfile.addEndpoint(endpointNameForPop, regionIdForPop, PRODUCT_NAME,
|
||||
domainForPop);
|
||||
IClientProfile profile = DefaultProfile.getProfile(regionIdForPop, accessKeyId,
|
||||
accessKeySecret);
|
||||
|
Reference in New Issue
Block a user