Skip to content

Commit

Permalink
format code
Browse files Browse the repository at this point in the history
  • Loading branch information
shukai committed Jan 11, 2025
1 parent aaa71d8 commit 07611ff
Showing 1 changed file with 27 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,18 +176,18 @@ public void setAutoCommit(boolean autoCommit) throws SQLException {
commit();
}
} else {
int flags;
if(this.xaBranchXid != null && currentAutoCommitStatus) {
flags = XAResource.TMJOIN;
}else {
if (xaActive) {
int flags;
if (this.xaBranchXid != null && currentAutoCommitStatus) {
flags = XAResource.TMJOIN;
} else {
if (xaActive) {
throw new SQLException("should NEVER happen: setAutoCommit from true to false while xa branch is active");
}
if(JdbcConstants.ORACLE.equals(resource.getDbType())) {
flags = SeataXAResource.ORATRANSLOOSE;
}else {
flags = XAResource.TMNOFLAGS;
}
if (JdbcConstants.ORACLE.equals(resource.getDbType())) {
flags = SeataXAResource.ORATRANSLOOSE;
} else {
flags = XAResource.TMNOFLAGS;
}
// Start a XA branch
long branchId;
try {
Expand Down Expand Up @@ -233,12 +233,12 @@ public synchronized void commit() throws SQLException {
throw new SQLException("should NOT commit on an inactive session", SQLSTATE_XA_NOT_END);
}
try {
xaEnd(xaBranchXid, XAResource.TMSUCCESS);
} catch (XAException e) {
throw new SQLException("Failed to end(TMSUCCESS) xa branch on " + xid + "-" + xaBranchXid.getBranchId()
+ " since " + e.getMessage(), e);
} finally {
xaActive = false;
xaEnd(xaBranchXid, XAResource.TMSUCCESS);
} catch (XAException e) {
throw new SQLException("Failed to end(TMSUCCESS) xa branch on " + xid + "-" + xaBranchXid.getBranchId()
+ " since " + e.getMessage(), e);
} finally {
xaActive = false;
}
}

Expand Down Expand Up @@ -308,9 +308,9 @@ private void checkTimeout(Long now) throws XAException {

@Override
public synchronized void close() throws SQLException {
try {
if(xaEnded) {
termination();
try {
if (xaEnded) {
termination();
long now = System.currentTimeMillis();
checkTimeout(now);
setPrepareTime(now);
Expand All @@ -322,24 +322,24 @@ public synchronized void close() throws SQLException {
// Branch Report to TC: RDONLY
reportStatusToTC(BranchStatus.PhaseOne_RDONLY);
}
}
}
} catch (SQLException sqle) {
// Rollback immediately before the XA Branch Context is deleted.
String xaBranchXid = this.xaBranchXid.toString();
rollback();
throw new SQLException("Branch " + xaBranchXid + " was rollbacked on committing since " + sqle.getMessage(), SQLSTATE_XA_NOT_END, sqle);
} catch (XAException xe) {
// Branch Report to TC: Failed
reportStatusToTC(BranchStatus.PhaseOne_Failed);
// Branch Report to TC: Failed
reportStatusToTC(BranchStatus.PhaseOne_Failed);
throw new SQLException(
"Failed to end(TMSUCCESS)/prepare xa branch on " + xid + "-" + xaBranchXid.getBranchId() + " since " + xe
.getMessage(), xe);
"Failed to end(TMSUCCESS)/prepare xa branch on " + xid + "-" + xaBranchXid.getBranchId() + " since " + xe
.getMessage(), xe);
} finally {
rollBacked = false;
rollBacked = false;
if (isHeld() && shouldBeHeld()) {
// if kept by a keeper, just hold the connection.
}else {
cleanXABranchContext();
} else {
cleanXABranchContext();
originalConnection.close();
}
}
Expand Down

0 comments on commit 07611ff

Please sign in to comment.