Skip to content

Commit

Permalink
optimize: clarify if conditions (#6442)
Browse files Browse the repository at this point in the history
  • Loading branch information
YeonCheolGit authored Apr 8, 2024
1 parent a24a43e commit 77bcaa2
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 4 deletions.
5 changes: 5 additions & 0 deletions changes/en-us/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ Add changes here for all PR submitted to the 2.x branch.
retry mechanism
- [[#6387](https://github.com/apache/incubator-seata/pull/6387)] optimize tcc use compatible
- [[#6402](https://github.com/apache/incubator-seata/pull/6402)] optimize rm-datasource use compatible
- [[#6419](https://github.com/apache/incubator-seata/pull/6419)] optimize integration-tx-api compatibl
- [[#6442](https://github.com/apache/incubator-seata/pull/6442)] clarify if conditions

### refactor:
- [[#6269](https://github.com/apache/incubator-seata/pull/6269)] standardize Seata Exception
- [[#6419](https://github.com/apache/incubator-seata/pull/6419)] optimize integration-tx-api compatible
- [[#6405](https://github.com/apache/incubator-seata/pull/6405)] fix kotlin compile failure
- [[#6412](https://github.com/apache/incubator-seata/pull/6412)] optimize core compatible module
Expand Down
5 changes: 5 additions & 0 deletions changes/zh-cn/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@
- [[#6387](https://github.com/apache/incubator-seata/pull/6387)] 优化tcc使用兼容
- [[#6402](https://github.com/apache/incubator-seata/pull/6402)] 优化rm-datasource向下兼容
- [[#6419](https://github.com/apache/incubator-seata/pull/6419)] 优化integration-tx-api向下兼容
- [[#6442](https://github.com/apache/incubator-seata/pull/6442)] 阐明 if


### refactor:
- [[#6269](https://github.com/apache/incubator-seata/pull/6269)] 统一Seata异常规范
- [[#6405](https://github.com/apache/incubator-seata/pull/6405)] 修复 kotlin 编译失败
- [[#6412](https://github.com/apache/incubator-seata/pull/6412)] 优化 core 兼容模块
- [[#6429](https://github.com/apache/incubator-seata/pull/6429)] 移除重复注释
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,10 @@ public void undo(DataSourceProxy dataSourceProxy, String xid, long branchId) thr
try {
connectionProxy = dataSourceProxy.getConnection();
conn = connectionProxy.getTargetConnection();
originalAutoCommit = conn.getAutoCommit();

// The entire undo process should run in a local transaction.
if (originalAutoCommit = conn.getAutoCommit()) {
if (originalAutoCommit) {
conn.setAutoCommit(false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,8 @@ public static boolean releaseDistributedLock(String lockKey) {
public static boolean distributedLockAndExecute(String key, NoArgsFunc func) {
boolean lock = false;
try {
if (lock = acquireDistributedLock(key)) {
lock = acquireDistributedLock(key);
if (lock) {
func.call();
}
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ public boolean acquireLock(List<LockDO> lockDOs, boolean autoCommit, boolean ski
}
try {
conn = lockStoreDataSource.getConnection();
if (originalAutoCommit = conn.getAutoCommit()) {
originalAutoCommit = conn.getAutoCommit();
if (originalAutoCommit) {
conn.setAutoCommit(false);
}
List<LockDO> unrepeatedLockDOs = lockDOs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class RedisDistributedLocker implements DistributedLocker {
@Override
public boolean acquireLock(DistributedLockDO distributedLockDO) {
try (Jedis jedis = JedisPooledFactory.getJedisInstance()) {
//Don't need retry,if can't acquire the lock,let the other get the lock
//Don't need to retry, if you can't acquire the lock,let the other get the lock
String result = jedis.set(distributedLockDO.getLockKey(), distributedLockDO.getLockValue(), SetParams.setParams().nx().px(distributedLockDO.getExpireTime()));
return SUCCESS.equalsIgnoreCase(result);
} catch (Exception ex) {
Expand Down

0 comments on commit 77bcaa2

Please sign in to comment.