TeslaCN commented on a change in pull request #15761:
URL: https://github.com/apache/shardingsphere/pull/15761#discussion_r817758315
##########
File path:
shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java
##########
@@ -225,15 +224,15 @@ private JDBCExecutionUnit
createTrafficExecutionUnit(final TrafficContext traffi
private TrafficContext getTrafficContext(final LogicSQL logicSQL) {
TrafficContext result = TrafficContextHolder.get().orElseGet(() ->
createTrafficContext(logicSQL));
- if (TransactionHolder.isTransaction()) {
+ if (connection.isHoldTransaction()) {
TrafficContextHolder.set(result);
}
return result;
}
private TrafficContext createTrafficContext(final LogicSQL logicSQL) {
Optional<TrafficRule> trafficRule =
metaDataContexts.getGlobalRuleMetaData().findSingleRule(TrafficRule.class);
- return trafficRule.map(optional -> new TrafficEngine(optional,
metaDataContexts).dispatch(logicSQL)).orElse(new TrafficContext());
+ return trafficRule.map(optional -> new TrafficEngine(optional,
metaDataContexts).dispatch(logicSQL,
connection.isHoldTransaction())).orElse(new TrafficContext());
Review comment:
```suggestion
return trafficRule.map(optional -> new TrafficEngine(optional,
metaDataContexts).dispatch(logicSQL,
connection.isHoldTransaction())).orElseGet(TrafficContext::new);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]