Skip to content

Commit

Permalink
optimize:optimize partial code handling (apache#4251)
Browse files Browse the repository at this point in the history
  • Loading branch information
pengten committed Jan 3, 2022
1 parent b03abc8 commit 631ed7f
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 20 deletions.
2 changes: 1 addition & 1 deletion changes/1.5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ Seata 是一款开源的分布式事务解决方案,提供高性能和简单
- [[#4191](https://github.com/seata/seata/pull/4191)] RPC请求超时时间支持配置化
- [[#4212](https://github.com/seata/seata/pull/4212)] 控制台接口合并优化
- [[#4216](https://github.com/seata/seata/pull/4216)] 非AT用户无须清理undolog表

- [[#4251](https://github.com/seata/seata/pull/4251)] 优化部分代码处理


### test:
Expand Down
2 changes: 1 addition & 1 deletion changes/en-us/1.5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
- [[#4191](https://github.com/seata/seata/pull/4191)] support rpc timeout can be customized.
- [[#4212](https://github.com/seata/seata/pull/4212)] optimize the interface of the console
- [[#4216](https://github.com/seata/seata/pull/4216)] no more attempt to clean undolog for none AT user

- [[#4251](https://github.com/seata/seata/pull/4251)] optimize partial code handling


### test:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
package io.seata.spring.boot.autoconfigure.properties;

import io.seata.spring.boot.autoconfigure.StarterConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.ApplicationContext;
Expand All @@ -35,9 +33,7 @@
@ConfigurationProperties(prefix = StarterConstants.SEATA_SPRING_CLOUD_ALIBABA_PREFIX)
public class SpringCloudAlibabaConfiguration implements ApplicationContextAware {

private static final Logger LOGGER = LoggerFactory.getLogger(SpringCloudAlibabaConfiguration.class);
private static final String SPRING_APPLICATION_NAME_KEY = "spring.application.name";
private static final String DEFAULT_SPRING_CLOUD_SERVICE_GROUP_POSTFIX = "-seata-service-group";
private String applicationId;
private String txServiceGroup;
private ApplicationContext applicationContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public Object intercept(Object proxy, Method method, Object[] args, MethodProxy
} else if (args.length == 2) {
result = get(convertDataId(rawDataId), args[1]);
} else if (args.length == 3) {
result = get(convertDataId(rawDataId), args[1], (Long) args[2]);
result = get(convertDataId(rawDataId), args[1]);
}
if (result != null) {
//If the return type is String,need to convert the object to string
Expand All @@ -76,11 +76,6 @@ public Object intercept(Object proxy, Method method, Object[] args, MethodProxy
});
}

private Object get(String dataId, Object defaultValue, long timeoutMills) throws IllegalAccessException, InstantiationException {
return get(dataId, defaultValue);

}

private Object get(String dataId, Object defaultValue) throws IllegalAccessException, InstantiationException {
Object result = get(dataId);
if (result == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ protected List<RowLock> collectRowLocks(String lockKey, String resourceId, Strin
*/
protected List<RowLock> collectRowLocks(String lockKey, String resourceId, String xid, Long transactionId,
Long branchID) {
List<RowLock> locks = new ArrayList<RowLock>();
List<RowLock> locks = new ArrayList<>();

String[] tableGroupedLockKeys = lockKey.split(";");
for (String tableGroupedLockKey : tableGroupedLockKeys) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ public AbstractSessionManager(String name) {
@Override
public void addGlobalSession(GlobalSession session) throws TransactionException {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("MANAGER[" + name + "] SESSION[" + session + "] " + LogOperation.GLOBAL_ADD);
LOGGER.debug("MANAGER[{}] SESSION[{}] {}", name, session, LogOperation.GLOBAL_ADD);
}
writeSession(LogOperation.GLOBAL_ADD, session);
}

@Override
public void updateGlobalSessionStatus(GlobalSession session, GlobalStatus status) throws TransactionException {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("MANAGER[" + name + "] SESSION[" + session + "] " + LogOperation.GLOBAL_UPDATE);
LOGGER.debug("MANAGER[{}] SESSION[{}] {}", name, session, LogOperation.GLOBAL_UPDATE);
}
if (GlobalStatus.Rollbacking == status) {
session.getBranchSessions().forEach(i -> i.setLockStatus(LockStatus.Rollbacking));
Expand All @@ -85,15 +85,15 @@ public void updateGlobalSessionStatus(GlobalSession session, GlobalStatus status
@Override
public void removeGlobalSession(GlobalSession session) throws TransactionException {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("MANAGER[" + name + "] SESSION[" + session + "] " + LogOperation.GLOBAL_REMOVE);
LOGGER.debug("MANAGER[{}] SESSION[{}] {}", name, session, LogOperation.GLOBAL_REMOVE);
}
writeSession(LogOperation.GLOBAL_REMOVE, session);
}

@Override
public void addBranchSession(GlobalSession session, BranchSession branchSession) throws TransactionException {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("MANAGER[" + name + "] SESSION[" + branchSession + "] " + LogOperation.BRANCH_ADD);
LOGGER.debug("MANAGER[{}] SESSION[{}] {}", name, branchSession, LogOperation.BRANCH_ADD);
}
writeSession(LogOperation.BRANCH_ADD, branchSession);
}
Expand All @@ -102,7 +102,7 @@ public void addBranchSession(GlobalSession session, BranchSession branchSession)
public void updateBranchSessionStatus(BranchSession branchSession, BranchStatus status)
throws TransactionException {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("MANAGER[" + name + "] SESSION[" + branchSession + "] " + LogOperation.BRANCH_UPDATE);
LOGGER.debug("MANAGER[{}] SESSION[{}] {}", name, branchSession, LogOperation.BRANCH_UPDATE);
}
writeSession(LogOperation.BRANCH_UPDATE, branchSession);
}
Expand All @@ -111,7 +111,7 @@ public void updateBranchSessionStatus(BranchSession branchSession, BranchStatus
public void removeBranchSession(GlobalSession globalSession, BranchSession branchSession)
throws TransactionException {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("MANAGER[" + name + "] SESSION[" + branchSession + "] " + LogOperation.BRANCH_REMOVE);
LOGGER.debug("MANAGER[{}] SESSION[{}] {}", name, branchSession, LogOperation.BRANCH_REMOVE);
}
writeSession(LogOperation.BRANCH_REMOVE, branchSession);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ protected void branchSessionLock(GlobalSession globalSession, BranchSession bran
}
} catch (StoreException e) {
if (e.getCause() instanceof BranchTransactionException) {
throw new BranchTransactionException((((BranchTransactionException)e.getCause())).getCode(),
throw new BranchTransactionException(((BranchTransactionException)e.getCause()).getCode(),
String.format("Global lock acquire failed xid = %s branchId = %s", globalSession.getXid(),
branchSession.getBranchId()));
}
Expand Down

0 comments on commit 631ed7f

Please sign in to comment.