Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
1 change: 1 addition & 0 deletions changes/en-us/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Add changes here for all PR submitted to the 2.x branch.
- [[#7261](https://github.com/apache/incubator-seata/pull/7261)] enforce account initialization and disable default credentials
- [[#7451](https://github.com/apache/incubator-seata/pull/7451)] seata-server supports the HTTP/2 protocol
- [[#7496](https://github.com/apache/incubator-seata/pull/7496)] add oceanbase oracle support
- [[#7509](https://github.com/apache/incubator-seata/pull/7509)] Reuse connection to merge branch transactions


### bugfix:
Expand Down
1 change: 1 addition & 0 deletions changes/zh-cn/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
- [[#7261](https://github.com/apache/incubator-seata/pull/7261)] 强制进行账户初始化并禁用默认凭据
- [[#7451](https://github.com/apache/incubator-seata/pull/7451)] seata-server支持HTTP/2协议
- [[#7496](https://github.com/apache/incubator-seata/pull/7496)] 添加对oceanbase数据库oracle模式的支持
- [[#7509](https://github.com/apache/incubator-seata/pull/7509)] 复用连接合并分支事务


### bugfix:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ public static boolean inSagaBranch() {
return BranchType.SAGA == getBranchType();
}

public static boolean inXABranch() {
return BranchType.XA == getBranchType();
}

/**
* get the branch type
*
Expand Down
9 changes: 8 additions & 1 deletion integration-tx-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,14 @@
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should not rely on Spring, but instead refer to the existing proxy approach and use byte-buddy for proxying.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* 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.integration.tx.api.combine;

import org.apache.seata.core.context.RootContext;
import org.apache.seata.rm.datasource.combine.CombineConnectionHolder;
import org.apache.seata.rm.datasource.combine.CombineContext;
import org.apache.seata.rm.datasource.xa.ConnectionProxyXA;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class CombineAspect {
private static final Logger LOGGER = LoggerFactory.getLogger(CombineAspect.class);

Check warning on line 33 in integration-tx-api/src/main/java/org/apache/seata/integration/tx/api/combine/CombineAspect.java

View check run for this annotation

Codecov / codecov/patch

integration-tx-api/src/main/java/org/apache/seata/integration/tx/api/combine/CombineAspect.java#L32-L33

Added lines #L32 - L33 were not covered by tests

@Around("@annotation(org.apache.seata.spring.annotation.CombineTransactional)")
public Object handleCombine(ProceedingJoinPoint joinPoint) throws Throwable {
if (!RootContext.inGlobalTransaction() || !RootContext.inXABranch()) {
// not in transaction, or this interceptor is disabled
return joinPoint.proceed();

Check warning on line 39 in integration-tx-api/src/main/java/org/apache/seata/integration/tx/api/combine/CombineAspect.java

View check run for this annotation

Codecov / codecov/patch

integration-tx-api/src/main/java/org/apache/seata/integration/tx/api/combine/CombineAspect.java#L39

Added line #L39 was not covered by tests
}

if (!CombineContext.set()) {
// The same global transaction, the aspect does not need to enter
return joinPoint.proceed();

Check warning on line 44 in integration-tx-api/src/main/java/org/apache/seata/integration/tx/api/combine/CombineAspect.java

View check run for this annotation

Codecov / codecov/patch

integration-tx-api/src/main/java/org/apache/seata/integration/tx/api/combine/CombineAspect.java#L44

Added line #L44 was not covered by tests
}

try {
// First cut entry
Object result = joinPoint.proceed();

Check warning on line 49 in integration-tx-api/src/main/java/org/apache/seata/integration/tx/api/combine/CombineAspect.java

View check run for this annotation

Codecov / codecov/patch

integration-tx-api/src/main/java/org/apache/seata/integration/tx/api/combine/CombineAspect.java#L49

Added line #L49 was not covered by tests

// doCleanupAfterCompletion marks the end of the transaction, resets and closes the connection
CombineContext.clear();

Check warning on line 52 in integration-tx-api/src/main/java/org/apache/seata/integration/tx/api/combine/CombineAspect.java

View check run for this annotation

Codecov / codecov/patch

integration-tx-api/src/main/java/org/apache/seata/integration/tx/api/combine/CombineAspect.java#L52

Added line #L52 was not covered by tests
// doCommit
for (ConnectionProxyXA conn : CombineConnectionHolder.getDsConn()) {
conn.commit();
}
return result;
} catch (Exception e) {
LOGGER.error(
String.format("Failed to handle,xid: %s occur exp msg: %s", RootContext.getXID(), e.getMessage()),

Check warning on line 60 in integration-tx-api/src/main/java/org/apache/seata/integration/tx/api/combine/CombineAspect.java

View check run for this annotation

Codecov / codecov/patch

integration-tx-api/src/main/java/org/apache/seata/integration/tx/api/combine/CombineAspect.java#L55-L60

Added lines #L55 - L60 were not covered by tests
e);
CombineContext.clear();

Check warning on line 62 in integration-tx-api/src/main/java/org/apache/seata/integration/tx/api/combine/CombineAspect.java

View check run for this annotation

Codecov / codecov/patch

integration-tx-api/src/main/java/org/apache/seata/integration/tx/api/combine/CombineAspect.java#L62

Added line #L62 was not covered by tests
// doRollback
for (ConnectionProxyXA conn : CombineConnectionHolder.getDsConn()) {
conn.rollback();
}
throw e;

Check warning on line 67 in integration-tx-api/src/main/java/org/apache/seata/integration/tx/api/combine/CombineAspect.java

View check run for this annotation

Codecov / codecov/patch

integration-tx-api/src/main/java/org/apache/seata/integration/tx/api/combine/CombineAspect.java#L65-L67

Added lines #L65 - L67 were not covered by tests
} finally {
CombineContext.clear();

Check warning on line 69 in integration-tx-api/src/main/java/org/apache/seata/integration/tx/api/combine/CombineAspect.java

View check run for this annotation

Codecov / codecov/patch

integration-tx-api/src/main/java/org/apache/seata/integration/tx/api/combine/CombineAspect.java#L69

Added line #L69 was not covered by tests
for (ConnectionProxyXA conn : CombineConnectionHolder.getDsConn()) {
try {
// Reset autocommit (if not autocommitting)
if (!conn.getAutoCommit()) {
conn.setAutoCommit(true);

Check warning on line 74 in integration-tx-api/src/main/java/org/apache/seata/integration/tx/api/combine/CombineAspect.java

View check run for this annotation

Codecov / codecov/patch

integration-tx-api/src/main/java/org/apache/seata/integration/tx/api/combine/CombineAspect.java#L74

Added line #L74 was not covered by tests
}
} catch (Throwable t) {

Check warning on line 76 in integration-tx-api/src/main/java/org/apache/seata/integration/tx/api/combine/CombineAspect.java

View check run for this annotation

Codecov / codecov/patch

integration-tx-api/src/main/java/org/apache/seata/integration/tx/api/combine/CombineAspect.java#L76

Added line #L76 was not covered by tests
// Record the exception of resetting the auto-commit, but do not interrupt and continue to try to
// close
LOGGER.error("Failed to reset autoCommit to true for connection: {}", conn, t);
}

Check warning on line 80 in integration-tx-api/src/main/java/org/apache/seata/integration/tx/api/combine/CombineAspect.java

View check run for this annotation

Codecov / codecov/patch

integration-tx-api/src/main/java/org/apache/seata/integration/tx/api/combine/CombineAspect.java#L79-L80

Added lines #L79 - L80 were not covered by tests
try {
if (conn.isClosed()) {
LOGGER.error("Connection is closed: {}", conn);

Check warning on line 83 in integration-tx-api/src/main/java/org/apache/seata/integration/tx/api/combine/CombineAspect.java

View check run for this annotation

Codecov / codecov/patch

integration-tx-api/src/main/java/org/apache/seata/integration/tx/api/combine/CombineAspect.java#L83

Added line #L83 was not covered by tests
}
conn.close();
} catch (Throwable t) {

Check warning on line 86 in integration-tx-api/src/main/java/org/apache/seata/integration/tx/api/combine/CombineAspect.java

View check run for this annotation

Codecov / codecov/patch

integration-tx-api/src/main/java/org/apache/seata/integration/tx/api/combine/CombineAspect.java#L85-L86

Added lines #L85 - L86 were not covered by tests
// Record the exception of closing the connection, but do not interrupt the loop and continue to
// process the next connection
LOGGER.error("Failed to close connection: {}", conn, t);
}
}

Check warning on line 91 in integration-tx-api/src/main/java/org/apache/seata/integration/tx/api/combine/CombineAspect.java

View check run for this annotation

Codecov / codecov/patch

integration-tx-api/src/main/java/org/apache/seata/integration/tx/api/combine/CombineAspect.java#L89-L91

Added lines #L89 - L91 were not covered by tests
// Clean up local cache connections
CombineConnectionHolder.clear();

Check warning on line 93 in integration-tx-api/src/main/java/org/apache/seata/integration/tx/api/combine/CombineAspect.java

View check run for this annotation

Codecov / codecov/patch

integration-tx-api/src/main/java/org/apache/seata/integration/tx/api/combine/CombineAspect.java#L93

Added line #L93 was not covered by tests
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* 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.integration.tx.api.combine;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;

@ComponentScan(basePackages = "org.apache.seata.integration.tx.api.combine")
@Configuration
@EnableAspectJAutoProxy(proxyTargetClass = true)
public class CombineAutoConfiguration {}

Check warning on line 26 in integration-tx-api/src/main/java/org/apache/seata/integration/tx/api/combine/CombineAutoConfiguration.java

View check run for this annotation

Codecov / codecov/patch

integration-tx-api/src/main/java/org/apache/seata/integration/tx/api/combine/CombineAutoConfiguration.java#L26

Added line #L26 was not covered by tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* 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.spring.annotation;

import java.lang.annotation.*;

@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface CombineTransactional {}
19 changes: 19 additions & 0 deletions integration-tx-api/src/main/resources/META-INF/spring.factories
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#
# 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.
#
# Auto Configure
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
org.apache.seata.integration.tx.api.combine.CombineAutoConfiguration
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* 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.rm.datasource.combine;

import org.apache.seata.core.context.RootContext;
import org.apache.seata.rm.datasource.xa.ConnectionProxyXA;

import javax.sql.DataSource;
import java.sql.SQLException;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class CombineConnectionHolder {
private static final ThreadLocal<Map<String, Map<Object, ConnectionProxyXA>>> CONNECTION_HOLDER =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use ConcurrentHashMap? Will there be concurrent situations?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there may be asynchronous or parallel branches.

ThreadLocal.withInitial(ConcurrentHashMap::new);

Check warning on line 31 in rm-datasource/src/main/java/org/apache/seata/rm/datasource/combine/CombineConnectionHolder.java

View check run for this annotation

Codecov / codecov/patch

rm-datasource/src/main/java/org/apache/seata/rm/datasource/combine/CombineConnectionHolder.java#L29-L31

Added lines #L29 - L31 were not covered by tests

public static ConnectionProxyXA get(DataSource dataSource) {
Map<Object, ConnectionProxyXA> connMap = CONNECTION_HOLDER.get().get(RootContext.getXID());

Check warning on line 34 in rm-datasource/src/main/java/org/apache/seata/rm/datasource/combine/CombineConnectionHolder.java

View check run for this annotation

Codecov / codecov/patch

rm-datasource/src/main/java/org/apache/seata/rm/datasource/combine/CombineConnectionHolder.java#L34

Added line #L34 was not covered by tests
if (connMap != null) {
return connMap.get(dataSource);

Check warning on line 36 in rm-datasource/src/main/java/org/apache/seata/rm/datasource/combine/CombineConnectionHolder.java

View check run for this annotation

Codecov / codecov/patch

rm-datasource/src/main/java/org/apache/seata/rm/datasource/combine/CombineConnectionHolder.java#L36

Added line #L36 was not covered by tests
}
return null;

Check warning on line 38 in rm-datasource/src/main/java/org/apache/seata/rm/datasource/combine/CombineConnectionHolder.java

View check run for this annotation

Codecov / codecov/patch

rm-datasource/src/main/java/org/apache/seata/rm/datasource/combine/CombineConnectionHolder.java#L38

Added line #L38 was not covered by tests
}

public static Collection<ConnectionProxyXA> getDsConn() {
Map<Object, ConnectionProxyXA> connectionMap = CONNECTION_HOLDER.get().get(RootContext.getXID());

Check warning on line 42 in rm-datasource/src/main/java/org/apache/seata/rm/datasource/combine/CombineConnectionHolder.java

View check run for this annotation

Codecov / codecov/patch

rm-datasource/src/main/java/org/apache/seata/rm/datasource/combine/CombineConnectionHolder.java#L42

Added line #L42 was not covered by tests
return connectionMap != null ? connectionMap.values() : Collections.emptyList();
}

public static void putConnection(DataSource dataSource, ConnectionProxyXA connection) throws SQLException {
Map<String, Map<Object, ConnectionProxyXA>> concurrentHashMap = CONNECTION_HOLDER.get();
String xid = RootContext.getXID();
Map<Object, ConnectionProxyXA> connectionProxyMap =
concurrentHashMap.computeIfAbsent(xid, k -> new ConcurrentHashMap<>());

Check warning on line 50 in rm-datasource/src/main/java/org/apache/seata/rm/datasource/combine/CombineConnectionHolder.java

View check run for this annotation

Codecov / codecov/patch

rm-datasource/src/main/java/org/apache/seata/rm/datasource/combine/CombineConnectionHolder.java#L47-L50

Added lines #L47 - L50 were not covered by tests

if (connectionProxyMap.putIfAbsent(dataSource, connection) == null) {
connection.setAutoCommit(false);

Check warning on line 53 in rm-datasource/src/main/java/org/apache/seata/rm/datasource/combine/CombineConnectionHolder.java

View check run for this annotation

Codecov / codecov/patch

rm-datasource/src/main/java/org/apache/seata/rm/datasource/combine/CombineConnectionHolder.java#L53

Added line #L53 was not covered by tests
}
}

Check warning on line 55 in rm-datasource/src/main/java/org/apache/seata/rm/datasource/combine/CombineConnectionHolder.java

View check run for this annotation

Codecov / codecov/patch

rm-datasource/src/main/java/org/apache/seata/rm/datasource/combine/CombineConnectionHolder.java#L55

Added line #L55 was not covered by tests

public static void clear() {
CONNECTION_HOLDER.get().remove(RootContext.getXID());
}

Check warning on line 59 in rm-datasource/src/main/java/org/apache/seata/rm/datasource/combine/CombineConnectionHolder.java

View check run for this annotation

Codecov / codecov/patch

rm-datasource/src/main/java/org/apache/seata/rm/datasource/combine/CombineConnectionHolder.java#L58-L59

Added lines #L58 - L59 were not covered by tests
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* 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.rm.datasource.combine;

import org.apache.seata.core.context.RootContext;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class CombineContext {

Check warning on line 24 in rm-datasource/src/main/java/org/apache/seata/rm/datasource/combine/CombineContext.java

View check run for this annotation

Codecov / codecov/patch

rm-datasource/src/main/java/org/apache/seata/rm/datasource/combine/CombineContext.java#L24

Added line #L24 was not covered by tests
private static final ThreadLocal<Map<String, Boolean>> COMBINE_ASPECT =
ThreadLocal.withInitial(ConcurrentHashMap::new);
;

/**
* @return
* false: The specified key already exists (repeatedly enter the aspect)
* true: The specified key does not exist (first time entering the aspect)
*/
public static boolean set() {
String xid = RootContext.getXID();

Check warning on line 35 in rm-datasource/src/main/java/org/apache/seata/rm/datasource/combine/CombineContext.java

View check run for this annotation

Codecov / codecov/patch

rm-datasource/src/main/java/org/apache/seata/rm/datasource/combine/CombineContext.java#L35

Added line #L35 was not covered by tests
if (xid != null) {
return !Boolean.TRUE.equals(COMBINE_ASPECT.get().putIfAbsent(xid, Boolean.TRUE));
}
return false;

Check warning on line 39 in rm-datasource/src/main/java/org/apache/seata/rm/datasource/combine/CombineContext.java

View check run for this annotation

Codecov / codecov/patch

rm-datasource/src/main/java/org/apache/seata/rm/datasource/combine/CombineContext.java#L39

Added line #L39 was not covered by tests
}

public static boolean get() {
String xid = RootContext.getXID();
if (xid == null) {
return false;
}
return Boolean.TRUE.equals(COMBINE_ASPECT.get().get(xid));
}

public static void clear() {
String xid = RootContext.getXID();

Check warning on line 51 in rm-datasource/src/main/java/org/apache/seata/rm/datasource/combine/CombineContext.java

View check run for this annotation

Codecov / codecov/patch

rm-datasource/src/main/java/org/apache/seata/rm/datasource/combine/CombineContext.java#L51

Added line #L51 was not covered by tests
if (xid != null) {
COMBINE_ASPECT.get().remove(xid);

Check warning on line 53 in rm-datasource/src/main/java/org/apache/seata/rm/datasource/combine/CombineContext.java

View check run for this annotation

Codecov / codecov/patch

rm-datasource/src/main/java/org/apache/seata/rm/datasource/combine/CombineContext.java#L53

Added line #L53 was not covered by tests
}
}

Check warning on line 55 in rm-datasource/src/main/java/org/apache/seata/rm/datasource/combine/CombineContext.java

View check run for this annotation

Codecov / codecov/patch

rm-datasource/src/main/java/org/apache/seata/rm/datasource/combine/CombineContext.java#L55

Added line #L55 was not covered by tests
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.seata.core.model.BranchType;
import org.apache.seata.rm.BaseDataSourceResource;
import org.apache.seata.rm.DefaultResourceManager;
import org.apache.seata.rm.datasource.combine.CombineContext;
import org.apache.seata.rm.datasource.util.SeataXAResource;
import org.apache.seata.sqlparser.util.JdbcConstants;
import org.slf4j.Logger;
Expand Down Expand Up @@ -227,6 +228,9 @@
@Override
public void commit() throws SQLException {
try (ResourceLock ignored = resourceLock.obtain()) {
if (CombineContext.get()) {
return;

Check warning on line 232 in rm-datasource/src/main/java/org/apache/seata/rm/datasource/xa/ConnectionProxyXA.java

View check run for this annotation

Codecov / codecov/patch

rm-datasource/src/main/java/org/apache/seata/rm/datasource/xa/ConnectionProxyXA.java#L232

Added line #L232 was not covered by tests
}
if (currentAutoCommitStatus || isReadOnly()) {
// Ignore the committing on an autocommit session and read-only transaction.
return;
Expand All @@ -239,6 +243,9 @@

@Override
public void rollback() throws SQLException {
if (CombineContext.get()) {
return;

Check warning on line 247 in rm-datasource/src/main/java/org/apache/seata/rm/datasource/xa/ConnectionProxyXA.java

View check run for this annotation

Codecov / codecov/patch

rm-datasource/src/main/java/org/apache/seata/rm/datasource/xa/ConnectionProxyXA.java#L247

Added line #L247 was not covered by tests
}
if (currentAutoCommitStatus || isReadOnly()) {
// Ignore the committing on an autocommit session and read-only transaction.
return;
Expand Down Expand Up @@ -312,6 +319,9 @@
@Override
public void close() throws SQLException {
try (ResourceLock ignored = resourceLock.obtain()) {
if (CombineContext.get()) {
return;

Check warning on line 323 in rm-datasource/src/main/java/org/apache/seata/rm/datasource/xa/ConnectionProxyXA.java

View check run for this annotation

Codecov / codecov/patch

rm-datasource/src/main/java/org/apache/seata/rm/datasource/xa/ConnectionProxyXA.java#L323

Added line #L323 was not covered by tests
}
try {
if (xaActive && this.xaBranchXid != null) {
// XA End: Success
Expand Down
Loading
Loading