tuichenchuxin commented on code in PR #20020:
URL: https://github.com/apache/shardingsphere/pull/20020#discussion_r942101059


##########
shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java:
##########
@@ -185,19 +184,22 @@ private static SQLFederationDeciderContext decide(final 
LogicSQL logicSQL, final
         return deciderEngine.decide(logicSQL, database);
     }
     
-    private TrafficContext getTrafficContext(final LogicSQL logicSQL) {
-        TrafficContext result = TrafficContextHolder.get().orElseGet(() -> 
createTrafficContext(logicSQL));
-        if (connection.isHoldTransaction()) {
-            TrafficContextHolder.set(result);
+    private Optional<String> getInstanceIdAndSave(final LogicSQL logicSQL) {
+        Optional<String> trafficInstanceId = 
connection.getSqlSession().getTrafficInstanceId();
+        if (!trafficInstanceId.isPresent()) {
+            trafficInstanceId = getTrafficInstanceId(logicSQL);
         }
-        return result;
+        if (connection.isHoldTransaction() && trafficInstanceId.isPresent()) {
+            
connection.getSqlSession().setTrafficInstanceId(trafficInstanceId.get());
+        }
+        return trafficInstanceId;

Review Comment:
   done.Thanks



-- 
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]

Reply via email to