Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion changes/en-us/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Add changes here for all PR submitted to the 2.x branch.
- [[#6534](https://github.com/apache/incubator-seata/pull/6534)] optimize: send async response
- [[#6640](https://github.com/apache/incubator-seata/pull/6640)] modify codecov config
- [[#6640](https://github.com/apache/incubator-seata/pull/6648)] add license header
- [[#6666](https://github.com/apache/incubator-seata/pull/6666)] add ExceptionUtil class for unwarp error msg
- [[#6654](https://github.com/apache/incubator-seata/pull/6654)] add Namingserver package module

### refactor:
Expand Down Expand Up @@ -51,6 +52,6 @@ Thanks to these contributors for their code commits. Please report an unintended
- [xjlgod](https://github.com/xjlgod)
- [xingfudeshi](https://github.com/xingfudeshi)
- [wuwen5](https://github.com/wuwen5)

- [iAmClever(https://github.com/iAmClever)

Also, we receive many valuable issues, questions and advices from our community. Thanks for you all.
3 changes: 2 additions & 1 deletion changes/zh-cn/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
- [[#6566](https://github.com/apache/incubator-seata/pull/6566)] 支持GlobalTransactionScanner类中exposeProxy属性的配置
- [[#6534](https://github.com/apache/incubator-seata/pull/6534)] 优化: 发送异步响应
- [[#6534](https://github.com/apache/incubator-seata/pull/6648)] 增加license header信息
- [[#6666](https://github.com/apache/incubator-seata/pull/6666)] 添加ExceptionUtil工具类用于解包装异常
- [[#6654](https://github.com/apache/incubator-seata/pull/6654)] 增加Namingserver打包功能

### refactor:
Expand Down Expand Up @@ -52,6 +53,6 @@
- [xjlgod](https://github.com/xjlgod)
- [xingfudeshi](https://github.com/xingfudeshi)
- [wuwen5](https://github.com/wuwen5)

- [iAmClever](https://github.com/iAmClever)

同时,我们收到了社区反馈的很多有价值的issue和建议,非常感谢大家。
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.seata.common.exception;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.UndeclaredThrowableException;

public class ExceptionUtil {

private ExceptionUtil() {
}

public static Throwable unwrap(Throwable wrapped) {
Throwable unwrapped = wrapped;
while (true) {
if (unwrapped instanceof InvocationTargetException) {
unwrapped = ((InvocationTargetException) unwrapped).getTargetException();
} else if (unwrapped instanceof UndeclaredThrowableException) {
unwrapped = ((UndeclaredThrowableException) unwrapped).getUndeclaredThrowable();
} else {
return unwrapped;
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import javax.sql.DataSource;

import org.apache.seata.common.exception.ExceptionUtil;
import org.apache.seata.common.exception.FrameworkErrorCode;
import org.apache.seata.common.exception.SkipCallbackWrapperException;
import org.apache.seata.common.executor.Callback;
Expand Down Expand Up @@ -253,21 +254,25 @@ private static boolean insertCommonFenceLog(Connection conn, String xid, Long br
private static boolean updateStatusAndInvokeTargetMethod(Connection conn, Method method, Object targetTCCBean,
String xid, Long branchId, int status,
TransactionStatus transactionStatus,
Object[] args) throws Exception {
Object[] args) throws Throwable {
boolean result = COMMON_FENCE_DAO.updateCommonFenceDO(conn, xid, branchId, status, CommonFenceConstant.STATUS_TRIED);
if (result) {
// invoke two phase method
Object ret = method.invoke(targetTCCBean, args);
if (null != ret) {
if (ret instanceof TwoPhaseResult) {
result = ((TwoPhaseResult) ret).isSuccess();
} else {
result = (boolean) ret;
}
// If the business execution result is false, the transaction will be rolled back
if (!result) {
transactionStatus.setRollbackOnly();
try {
// invoke two phase method
Object ret = method.invoke(targetTCCBean, args);
if (null != ret) {
if (ret instanceof TwoPhaseResult) {
result = ((TwoPhaseResult) ret).isSuccess();
} else {
result = (boolean) ret;
}
// If the business execution result is false, the transaction will be rolled back
if (!result) {
transactionStatus.setRollbackOnly();
}
}
} catch (Exception e) {
throw ExceptionUtil.unwrap(e);
}
}
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.concurrent.ConcurrentHashMap;

import org.apache.seata.common.Constants;
import org.apache.seata.common.exception.ExceptionUtil;
import org.apache.seata.common.exception.RepeatRegistrationException;
import org.apache.seata.common.exception.ShouldNeverHappenException;
import org.apache.seata.common.exception.SkipCallbackWrapperException;
Expand Down Expand Up @@ -143,7 +144,7 @@ public BranchStatus branchCommit(BranchType branchType, String xid, long branchI
return result ? BranchStatus.PhaseTwo_Committed : BranchStatus.PhaseTwo_CommitFailed_Retryable;
} catch (Throwable t) {
String msg = String.format("commit TCC resource error, resourceId: %s, xid: %s.", resourceId, xid);
LOGGER.error(msg, t);
LOGGER.error(msg, ExceptionUtil.unwrap(t));
return BranchStatus.PhaseTwo_CommitFailed_Retryable;
}
}
Expand Down Expand Up @@ -202,7 +203,7 @@ public BranchStatus branchRollback(BranchType branchType, String xid, long branc
return result ? BranchStatus.PhaseTwo_Rollbacked : BranchStatus.PhaseTwo_RollbackFailed_Retryable;
} catch (Throwable t) {
String msg = String.format("rollback TCC resource error, resourceId: %s, xid: %s.", resourceId, xid);
LOGGER.error(msg, t);
LOGGER.error(msg, ExceptionUtil.unwrap(t));
return BranchStatus.PhaseTwo_RollbackFailed_Retryable;
}
}
Expand Down