This is an automated email from the ASF dual-hosted git repository.

panjuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 0bee173  Refactor RouteContext's constructor (#7609)
0bee173 is described below

commit 0bee173efd98c0aa38fd2844eaf468037a636225
Author: Liang Zhang <[email protected]>
AuthorDate: Fri Sep 25 18:38:38 2020 +0800

    Refactor RouteContext's constructor (#7609)
---
 .../PrimaryReplicaReplicationRouteDecoratorTest.java    |  6 +++---
 .../shadow/route/engine/ShadowRouteDecoratorTest.java   |  7 +++----
 .../impl/ShardingCreateTableStatementValidatorTest.java |  5 ++---
 .../impl/ShardingDeleteStatementValidatorTest.java      |  3 +--
 .../impl/ShardingInsertStatementValidatorTest.java      | 15 +++++++--------
 .../impl/ShardingUpdateStatementValidatorTest.java      | 17 ++++++++---------
 .../infra/rewrite/SQLRewriteEntryTest.java              |  4 ++--
 .../shardingsphere/infra/route/DataNodeRouter.java      |  9 +++++----
 .../infra/route/context/RouteContext.java               | 12 +++++++++---
 9 files changed, 40 insertions(+), 38 deletions(-)

diff --git 
a/shardingsphere-features/shardingsphere-primary-replica-replication/shardingsphere-primary-replica-replication-route/src/test/java/org/apache/shardingsphere/replication/primaryreplica/route/engine/PrimaryReplicaReplicationRouteDecoratorTest.java
 
b/shardingsphere-features/shardingsphere-primary-replica-replication/shardingsphere-primary-replica-replication-route/src/test/java/org/apache/shardingsphere/replication/primaryreplica/route/engine/PrimaryReplicaReplicationRouteDecorat
 [...]
index 11a4b44..147663b 100644
--- 
a/shardingsphere-features/shardingsphere-primary-replica-replication/shardingsphere-primary-replica-replication-route/src/test/java/org/apache/shardingsphere/replication/primaryreplica/route/engine/PrimaryReplicaReplicationRouteDecoratorTest.java
+++ 
b/shardingsphere-features/shardingsphere-primary-replica-replication/shardingsphere-primary-replica-replication-route/src/test/java/org/apache/shardingsphere/replication/primaryreplica/route/engine/PrimaryReplicaReplicationRouteDecoratorTest.java
@@ -158,7 +158,7 @@ public final class 
PrimaryReplicaReplicationRouteDecoratorTest {
     
     private RouteContext mockSQLRouteContext(final SQLStatement sqlStatement) {
         when(sqlStatementContext.getSqlStatement()).thenReturn(sqlStatement);
-        return new RouteContext(sqlStatementContext, Collections.emptyList(), 
mockRouteResult());
+        return new RouteContext(new RouteContext(sqlStatementContext, 
Collections.emptyList()), mockRouteResult(), null, null);
     }
     
     private RouteResult mockRouteResult() {
@@ -171,11 +171,11 @@ public final class 
PrimaryReplicaReplicationRouteDecoratorTest {
     
     private RouteContext mockSQLRouteContextWithoutRouteUnits(final 
SQLStatement sqlStatement) {
         when(sqlStatementContext.getSqlStatement()).thenReturn(sqlStatement);
-        return new RouteContext(sqlStatementContext, Collections.emptyList(), 
new RouteResult());
+        return new RouteContext(sqlStatementContext, Collections.emptyList());
     }
     
     private RouteContext 
mockSQLRouteContextWithoutRouteUnitsAndWithParameters(final SQLStatement 
sqlStatement) {
         when(sqlStatementContext.getSqlStatement()).thenReturn(sqlStatement);
-        return new RouteContext(sqlStatementContext, 
Collections.singletonList("true"), new RouteResult());
+        return new RouteContext(sqlStatementContext, 
Collections.singletonList("true"));
     }
 }
diff --git 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-route/src/test/java/org/apache/shardingsphere/shadow/route/engine/ShadowRouteDecoratorTest.java
 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-route/src/test/java/org/apache/shardingsphere/shadow/route/engine/ShadowRouteDecoratorTest.java
index feb7871..452a625 100644
--- 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-route/src/test/java/org/apache/shardingsphere/shadow/route/engine/ShadowRouteDecoratorTest.java
+++ 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-route/src/test/java/org/apache/shardingsphere/shadow/route/engine/ShadowRouteDecoratorTest.java
@@ -21,7 +21,6 @@ import 
org.apache.shardingsphere.infra.config.properties.ConfigurationProperties
 import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
 import org.apache.shardingsphere.infra.route.context.RouteContext;
 import org.apache.shardingsphere.infra.route.context.RouteMapper;
-import org.apache.shardingsphere.infra.route.context.RouteResult;
 import org.apache.shardingsphere.infra.route.context.RouteUnit;
 import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
 import org.apache.shardingsphere.shadow.rule.ShadowRule;
@@ -152,17 +151,17 @@ public final class ShadowRouteDecoratorTest {
         InsertValueContext insertValueContext = mock(InsertValueContext.class);
         when(insertValueContext.getValue(0)).thenReturn(true);
         
when(sqlStatementContext.getInsertValueContexts()).thenReturn(Collections.singletonList(insertValueContext));
-        return new RouteContext(sqlStatementContext, Collections.emptyList(), 
new RouteResult());
+        return new RouteContext(sqlStatementContext, Collections.emptyList());
     }
     
     private RouteContext mockSQLRouteContext() {
         
when(sqlStatementContext.getSqlStatement()).thenReturn(insertStatement);
-        return new RouteContext(sqlStatementContext, Collections.emptyList(), 
new RouteResult());
+        return new RouteContext(sqlStatementContext, Collections.emptyList());
     }
     
     private RouteContext mockNonDMLSQLRouteContext() {
         
when(createTableStatementContext.getSqlStatement()).thenReturn(createTableStatement);
-        return new RouteContext(createTableStatementContext, 
Collections.emptyList(), new RouteResult());
+        return new RouteContext(createTableStatementContext, 
Collections.emptyList());
     }
 
     private RouteUnit mockRouteUnit() {
diff --git 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingCreateTableStatementValidatorTest.java
 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingCreateTableStatementValidatorTest.java
index 702a868..71368d7 100644
--- 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingCreateTableStatementValidatorTest.java
+++ 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingCreateTableStatementValidatorTest.java
@@ -20,7 +20,6 @@ package 
org.apache.shardingsphere.sharding.route.engine.validator.impl;
 import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
 import org.apache.shardingsphere.infra.metadata.schema.RuleSchemaMetaData;
 import org.apache.shardingsphere.infra.route.context.RouteContext;
-import org.apache.shardingsphere.infra.route.context.RouteResult;
 import 
org.apache.shardingsphere.sharding.route.engine.exception.TableExistsException;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
 import 
org.apache.shardingsphere.sql.parser.binder.statement.SQLStatementContext;
@@ -85,7 +84,7 @@ public final class ShardingCreateTableStatementValidatorTest {
     
     private void assertValidateCreateTable(final CreateTableStatement 
sqlStatement) {
         SQLStatementContext<CreateTableStatement> sqlStatementContext = new 
CreateTableStatementContext(sqlStatement);
-        RouteContext routeContext = new RouteContext(sqlStatementContext, 
Collections.emptyList(), new RouteResult());
+        RouteContext routeContext = new RouteContext(sqlStatementContext, 
Collections.emptyList());
         ShardingSphereMetaData metaData = mock(ShardingSphereMetaData.class);
         RuleSchemaMetaData ruleSchemaMetaData = mock(RuleSchemaMetaData.class);
         
when(ruleSchemaMetaData.getAllTableNames()).thenReturn(Collections.singleton("t_order"));
@@ -111,7 +110,7 @@ public final class 
ShardingCreateTableStatementValidatorTest {
     
     private void assertValidateCreateTableIfNotExists(final 
CreateTableStatement sqlStatement) {
         SQLStatementContext<CreateTableStatement> sqlStatementContext = new 
CreateTableStatementContext(sqlStatement);
-        RouteContext routeContext = new RouteContext(sqlStatementContext, 
Collections.emptyList(), new RouteResult());
+        RouteContext routeContext = new RouteContext(sqlStatementContext, 
Collections.emptyList());
         ShardingSphereMetaData metaData = mock(ShardingSphereMetaData.class);
         RuleSchemaMetaData ruleSchemaMetaData = mock(RuleSchemaMetaData.class);
         
when(ruleSchemaMetaData.getAllTableNames()).thenReturn(Collections.singleton("t_order"));
diff --git 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingDeleteStatementValidatorTest.java
 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingDeleteStatementValidatorTest.java
index 81b2b40..ae3df1d 100644
--- 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingDeleteStatementValidatorTest.java
+++ 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingDeleteStatementValidatorTest.java
@@ -20,7 +20,6 @@ package 
org.apache.shardingsphere.sharding.route.engine.validator.impl;
 import org.apache.shardingsphere.infra.exception.ShardingSphereException;
 import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
 import org.apache.shardingsphere.infra.route.context.RouteContext;
-import org.apache.shardingsphere.infra.route.context.RouteResult;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
 import 
org.apache.shardingsphere.sql.parser.binder.statement.SQLStatementContext;
 import 
org.apache.shardingsphere.sql.parser.binder.statement.dml.DeleteStatementContext;
@@ -76,7 +75,7 @@ public final class ShardingDeleteStatementValidatorTest {
         tableSegment.getActualDeleteTables().add(new SimpleTableSegment(0, 0, 
new IdentifierValue("order")));
         sqlStatement.setTableSegment(tableSegment);
         SQLStatementContext<DeleteStatement> sqlStatementContext = new 
DeleteStatementContext(sqlStatement);
-        RouteContext routeContext = new RouteContext(sqlStatementContext, 
Collections.emptyList(), new RouteResult());
+        RouteContext routeContext = new RouteContext(sqlStatementContext, 
Collections.emptyList());
         new ShardingDeleteStatementValidator().preValidate(shardingRule, 
routeContext, mock(ShardingSphereMetaData.class));
     }
 }
diff --git 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingInsertStatementValidatorTest.java
 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingInsertStatementValidatorTest.java
index 0eba2b0..e6a6868 100644
--- 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingInsertStatementValidatorTest.java
+++ 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingInsertStatementValidatorTest.java
@@ -20,7 +20,6 @@ package 
org.apache.shardingsphere.sharding.route.engine.validator.impl;
 import org.apache.shardingsphere.infra.exception.ShardingSphereException;
 import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
 import org.apache.shardingsphere.infra.route.context.RouteContext;
-import org.apache.shardingsphere.infra.route.context.RouteResult;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
 import 
org.apache.shardingsphere.sql.parser.binder.metadata.schema.SchemaMetaData;
 import org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext;
@@ -63,7 +62,7 @@ public final class ShardingInsertStatementValidatorTest {
     public void assertValidateInsertModifyMultiTables() {
         SQLStatementContext<InsertStatement> sqlStatementContext = new 
InsertStatementContext(new SchemaMetaData(Collections.emptyMap()), 
Collections.singletonList(1), createInsertStatement());
         
sqlStatementContext.getTablesContext().getTables().addAll(createMultiTablesContext().getTables());
-        RouteContext routeContext = new RouteContext(sqlStatementContext, 
Collections.emptyList(), new RouteResult());
+        RouteContext routeContext = new RouteContext(sqlStatementContext, 
Collections.emptyList());
         new ShardingInsertStatementValidator().preValidate(shardingRule, 
routeContext, mock(ShardingSphereMetaData.class));
     }
 
@@ -71,7 +70,7 @@ public final class ShardingInsertStatementValidatorTest {
     public void assertValidateOnDuplicateKeyWithoutShardingKey() {
         when(shardingRule.isShardingColumn("id", "user")).thenReturn(false);
         SQLStatementContext<InsertStatement> sqlStatementContext = new 
InsertStatementContext(new SchemaMetaData(Collections.emptyMap()), 
Collections.singletonList(1), createInsertStatement());
-        RouteContext routeContext = new RouteContext(sqlStatementContext, 
Collections.emptyList(), new RouteResult());
+        RouteContext routeContext = new RouteContext(sqlStatementContext, 
Collections.emptyList());
         new ShardingInsertStatementValidator().preValidate(shardingRule, 
routeContext, mock(ShardingSphereMetaData.class));
     }
     
@@ -79,7 +78,7 @@ public final class ShardingInsertStatementValidatorTest {
     public void assertValidateOnDuplicateKeyWithShardingKey() {
         when(shardingRule.isShardingColumn("id", "user")).thenReturn(true);
         SQLStatementContext<InsertStatement> sqlStatementContext = new 
InsertStatementContext(new SchemaMetaData(Collections.emptyMap()), 
Collections.singletonList(1), createInsertStatement());
-        RouteContext routeContext = new RouteContext(sqlStatementContext, 
Collections.emptyList(), new RouteResult());
+        RouteContext routeContext = new RouteContext(sqlStatementContext, 
Collections.emptyList());
         new ShardingInsertStatementValidator().preValidate(shardingRule, 
routeContext, mock(ShardingSphereMetaData.class));
     }
     
@@ -89,7 +88,7 @@ public final class ShardingInsertStatementValidatorTest {
         when(shardingRule.isGenerateKeyColumn("id", "user")).thenReturn(false);
         SQLStatementContext<InsertStatement> sqlStatementContext = new 
InsertStatementContext(new SchemaMetaData(Collections.emptyMap()), 
Collections.singletonList(1), createInsertSelectStatement());
         
sqlStatementContext.getTablesContext().getTables().addAll(createSingleTablesContext().getTables());
-        RouteContext routeContext = new RouteContext(sqlStatementContext, 
Collections.emptyList(), new RouteResult());
+        RouteContext routeContext = new RouteContext(sqlStatementContext, 
Collections.emptyList());
         new ShardingInsertStatementValidator().preValidate(shardingRule, 
routeContext, mock(ShardingSphereMetaData.class));
     }
     
@@ -99,7 +98,7 @@ public final class ShardingInsertStatementValidatorTest {
         when(shardingRule.isGenerateKeyColumn("id", "user")).thenReturn(true);
         SQLStatementContext<InsertStatement> sqlStatementContext = new 
InsertStatementContext(new SchemaMetaData(Collections.emptyMap()), 
Collections.singletonList(1), createInsertSelectStatement());
         
sqlStatementContext.getTablesContext().getTables().addAll(createSingleTablesContext().getTables());
-        RouteContext routeContext = new RouteContext(sqlStatementContext, 
Collections.emptyList(), new RouteResult());
+        RouteContext routeContext = new RouteContext(sqlStatementContext, 
Collections.emptyList());
         new ShardingInsertStatementValidator().preValidate(shardingRule, 
routeContext, mock(ShardingSphereMetaData.class));
     }
     
@@ -111,7 +110,7 @@ public final class ShardingInsertStatementValidatorTest {
         
when(shardingRule.isAllBindingTables(multiTablesContext.getTableNames())).thenReturn(false);
         SQLStatementContext<InsertStatement> sqlStatementContext = new 
InsertStatementContext(new SchemaMetaData(Collections.emptyMap()), 
Collections.singletonList(1), createInsertSelectStatement());
         
sqlStatementContext.getTablesContext().getTables().addAll(multiTablesContext.getTables());
-        RouteContext routeContext = new RouteContext(sqlStatementContext, 
Collections.emptyList(), new RouteResult());
+        RouteContext routeContext = new RouteContext(sqlStatementContext, 
Collections.emptyList());
         new ShardingInsertStatementValidator().preValidate(shardingRule, 
routeContext, mock(ShardingSphereMetaData.class));
     }
     
@@ -123,7 +122,7 @@ public final class ShardingInsertStatementValidatorTest {
         
when(shardingRule.isAllBindingTables(multiTablesContext.getTableNames())).thenReturn(true);
         SQLStatementContext<InsertStatement> sqlStatementContext = new 
InsertStatementContext(new SchemaMetaData(Collections.emptyMap()), 
Collections.singletonList(1), createInsertSelectStatement());
         
sqlStatementContext.getTablesContext().getTables().addAll(multiTablesContext.getTables());
-        RouteContext routeContext = new RouteContext(sqlStatementContext, 
Collections.emptyList(), new RouteResult());
+        RouteContext routeContext = new RouteContext(sqlStatementContext, 
Collections.emptyList());
         new ShardingInsertStatementValidator().preValidate(shardingRule, 
routeContext, mock(ShardingSphereMetaData.class));
     }
     
diff --git 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingUpdateStatementValidatorTest.java
 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingUpdateStatementValidatorTest.java
index 961bc4f..f147826 100644
--- 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingUpdateStatementValidatorTest.java
+++ 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingUpdateStatementValidatorTest.java
@@ -20,7 +20,6 @@ package 
org.apache.shardingsphere.sharding.route.engine.validator.impl;
 import org.apache.shardingsphere.infra.exception.ShardingSphereException;
 import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
 import org.apache.shardingsphere.infra.route.context.RouteContext;
-import org.apache.shardingsphere.infra.route.context.RouteResult;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
 import 
org.apache.shardingsphere.sql.parser.binder.statement.SQLStatementContext;
 import 
org.apache.shardingsphere.sql.parser.binder.statement.dml.UpdateStatementContext;
@@ -54,7 +53,7 @@ public final class ShardingUpdateStatementValidatorTest {
     
     @Mock
     private ShardingRule shardingRule;
-
+    
     @Test(expected = ShardingSphereException.class)
     public void assertValidateUpdateModifyMultiTables() {
         SQLStatementContext<UpdateStatement> sqlStatementContext = new 
UpdateStatementContext(createUpdateStatement());
@@ -62,21 +61,21 @@ public final class ShardingUpdateStatementValidatorTest {
         joinTableSegment.setLeft(new SimpleTableSegment(0, 0, new 
IdentifierValue("user")));
         joinTableSegment.setRight(new SimpleTableSegment(0, 0, new 
IdentifierValue("order")));
         
sqlStatementContext.getSqlStatement().setTableSegment(joinTableSegment);
-        RouteContext routeContext = new RouteContext(sqlStatementContext, 
Collections.emptyList(), new RouteResult());
+        RouteContext routeContext = new RouteContext(sqlStatementContext, 
Collections.emptyList());
         new ShardingUpdateStatementValidator().preValidate(shardingRule, 
routeContext, mock(ShardingSphereMetaData.class));
     }
-
+    
     @Test
     public void assertValidateUpdateWithoutShardingKey() {
         when(shardingRule.isShardingColumn("id", "user")).thenReturn(false);
-        RouteContext routeContext = new RouteContext(new 
UpdateStatementContext(createUpdateStatement()), Collections.emptyList(), new 
RouteResult());
+        RouteContext routeContext = new RouteContext(new 
UpdateStatementContext(createUpdateStatement()), Collections.emptyList());
         new ShardingUpdateStatementValidator().preValidate(shardingRule, 
routeContext, mock(ShardingSphereMetaData.class));
     }
     
     @Test(expected = ShardingSphereException.class)
     public void assertValidateUpdateWithShardingKey() {
         when(shardingRule.isShardingColumn("id", "user")).thenReturn(true);
-        RouteContext routeContext = new RouteContext(new 
UpdateStatementContext(createUpdateStatement()), Collections.emptyList(), new 
RouteResult());
+        RouteContext routeContext = new RouteContext(new 
UpdateStatementContext(createUpdateStatement()), Collections.emptyList());
         new ShardingUpdateStatementValidator().preValidate(shardingRule, 
routeContext, mock(ShardingSphereMetaData.class));
     }
     
@@ -84,7 +83,7 @@ public final class ShardingUpdateStatementValidatorTest {
     public void assertValidateUpdateWithoutShardingKeyAndParameters() {
         when(shardingRule.isShardingColumn("id", "user")).thenReturn(false);
         List<Object> parameters = Arrays.asList(1, 1);
-        RouteContext routeContext = new RouteContext(new 
UpdateStatementContext(createUpdateStatement()), parameters, new RouteResult());
+        RouteContext routeContext = new RouteContext(new 
UpdateStatementContext(createUpdateStatement()), parameters);
         new ShardingUpdateStatementValidator().preValidate(shardingRule, 
routeContext, mock(ShardingSphereMetaData.class));
     }
     
@@ -93,7 +92,7 @@ public final class ShardingUpdateStatementValidatorTest {
         when(shardingRule.isShardingColumn("id", "user")).thenReturn(true);
         List<Object> parameters = Arrays.asList(1, 1);
         SQLStatementContext<UpdateStatement> updateStatementContext = new 
UpdateStatementContext(createUpdateStatementAndParameters(1));
-        RouteContext routeContext = new RouteContext(updateStatementContext, 
parameters, new RouteResult());
+        RouteContext routeContext = new RouteContext(updateStatementContext, 
parameters);
         new ShardingUpdateStatementValidator().preValidate(shardingRule, 
routeContext, mock(ShardingSphereMetaData.class));
     }
     
@@ -102,7 +101,7 @@ public final class ShardingUpdateStatementValidatorTest {
         when(shardingRule.isShardingColumn("id", "user")).thenReturn(true);
         List<Object> parameters = Arrays.asList(1, 1);
         SQLStatementContext<UpdateStatement> updateStatementContext = new 
UpdateStatementContext(createUpdateStatementAndParameters(2));
-        RouteContext routeContext = new RouteContext(updateStatementContext, 
parameters, new RouteResult());
+        RouteContext routeContext = new RouteContext(updateStatementContext, 
parameters);
         new ShardingUpdateStatementValidator().preValidate(shardingRule, 
routeContext, mock(ShardingSphereMetaData.class));
     }
     
diff --git 
a/shardingsphere-infra/shardingsphere-infra-rewrite/shardingsphere-infra-rewrite-engine/src/test/java/org/apache/shardingsphere/infra/rewrite/SQLRewriteEntryTest.java
 
b/shardingsphere-infra/shardingsphere-infra-rewrite/shardingsphere-infra-rewrite-engine/src/test/java/org/apache/shardingsphere/infra/rewrite/SQLRewriteEntryTest.java
index dbce89b..0b2dcc7 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-rewrite/shardingsphere-infra-rewrite-engine/src/test/java/org/apache/shardingsphere/infra/rewrite/SQLRewriteEntryTest.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-rewrite/shardingsphere-infra-rewrite-engine/src/test/java/org/apache/shardingsphere/infra/rewrite/SQLRewriteEntryTest.java
@@ -49,7 +49,7 @@ public final class SQLRewriteEntryTest {
     @Test
     public void assertRewriteForGenericSQLRewriteResult() {
         SQLRewriteEntry sqlRewriteEntry = new SQLRewriteEntry(metaData, props, 
Collections.emptyList());
-        RouteContext routeContext = new 
RouteContext(mock(SQLStatementContext.class), Collections.singletonList(1), 
mock(RouteResult.class));
+        RouteContext routeContext = new 
RouteContext(mock(SQLStatementContext.class), Collections.singletonList(1));
         GenericSQLRewriteResult sqlRewriteResult = (GenericSQLRewriteResult) 
sqlRewriteEntry.rewrite("SELECT ?", Collections.singletonList(1), routeContext);
         assertThat(sqlRewriteResult.getSqlRewriteUnit().getSql(), is("SELECT 
?"));
         assertThat(sqlRewriteResult.getSqlRewriteUnit().getParameters(), 
is(Collections.singletonList(1)));
@@ -60,7 +60,7 @@ public final class SQLRewriteEntryTest {
         SQLRewriteEntry sqlRewriteEntry = new SQLRewriteEntry(metaData, props, 
Collections.emptyList());
         RouteResult routeResult = new RouteResult();
         
routeResult.getRouteUnits().addAll(Arrays.asList(mock(RouteUnit.class), 
mock(RouteUnit.class)));
-        RouteContext routeContext = new 
RouteContext(mock(SQLStatementContext.class), Collections.singletonList(1), 
routeResult);
+        RouteContext routeContext = new RouteContext(new 
RouteContext(mock(SQLStatementContext.class), Collections.singletonList(1)), 
routeResult, null, null);
         RouteSQLRewriteResult sqlRewriteResult = (RouteSQLRewriteResult) 
sqlRewriteEntry.rewrite("SELECT ?", Collections.singletonList(1), routeContext);
         assertThat(sqlRewriteResult.getSqlRewriteUnits().size(), is(2));
     }
diff --git 
a/shardingsphere-infra/shardingsphere-infra-route/src/main/java/org/apache/shardingsphere/infra/route/DataNodeRouter.java
 
b/shardingsphere-infra/shardingsphere-infra-route/src/main/java/org/apache/shardingsphere/infra/route/DataNodeRouter.java
index 72146d2..7fb3901 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-route/src/main/java/org/apache/shardingsphere/infra/route/DataNodeRouter.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-route/src/main/java/org/apache/shardingsphere/infra/route/DataNodeRouter.java
@@ -20,7 +20,6 @@ package org.apache.shardingsphere.infra.route;
 import 
org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
 import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
 import org.apache.shardingsphere.infra.route.context.RouteContext;
-import org.apache.shardingsphere.infra.route.context.RouteResult;
 import org.apache.shardingsphere.infra.route.decorator.RouteDecorator;
 import 
org.apache.shardingsphere.infra.route.decorator.UnconfiguredSchemaRouteDecorator;
 import org.apache.shardingsphere.infra.route.hook.SPIRoutingHook;
@@ -28,6 +27,7 @@ import 
org.apache.shardingsphere.infra.rule.ShardingSphereRule;
 import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
 import org.apache.shardingsphere.infra.spi.order.OrderedSPIRegistry;
 import org.apache.shardingsphere.sql.parser.binder.SQLStatementContextFactory;
+import 
org.apache.shardingsphere.sql.parser.binder.statement.SQLStatementContext;
 import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
 
 import java.util.Collection;
@@ -71,7 +71,7 @@ public final class DataNodeRouter {
     public RouteContext route(final SQLStatement sqlStatement, final String 
sql, final List<Object> parameters) {
         routingHook.start(sql);
         try {
-            RouteContext result = executeRoute(sqlStatement, parameters);
+            RouteContext result = doRoute(sqlStatement, parameters);
             routingHook.finishSuccess(result, 
metaData.getRuleSchemaMetaData().getConfiguredSchemaMetaData());
             return result;
             // CHECKSTYLE:OFF
@@ -83,8 +83,9 @@ public final class DataNodeRouter {
     }
     
     @SuppressWarnings({"unchecked", "rawtypes"})
-    private RouteContext executeRoute(final SQLStatement sqlStatement, final 
List<Object> parameters) {
-        RouteContext result = new 
RouteContext(SQLStatementContextFactory.newInstance(metaData.getRuleSchemaMetaData().getSchemaMetaData(),
 parameters, sqlStatement), parameters, new RouteResult());
+    private RouteContext doRoute(final SQLStatement sqlStatement, final 
List<Object> parameters) {
+        SQLStatementContext<?> sqlStatementContext = 
SQLStatementContextFactory.newInstance(metaData.getRuleSchemaMetaData().getSchemaMetaData(),
 parameters, sqlStatement);
+        RouteContext result = new RouteContext(sqlStatementContext, 
parameters);
         for (Entry<ShardingSphereRule, RouteDecorator> entry : 
decorators.entrySet()) {
             result = entry.getValue().decorate(result, metaData, 
entry.getKey(), props);
         }
diff --git 
a/shardingsphere-infra/shardingsphere-infra-route/src/main/java/org/apache/shardingsphere/infra/route/context/RouteContext.java
 
b/shardingsphere-infra/shardingsphere-infra-route/src/main/java/org/apache/shardingsphere/infra/route/context/RouteContext.java
index 9e00efe..d30e72b 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-route/src/main/java/org/apache/shardingsphere/infra/route/context/RouteContext.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-route/src/main/java/org/apache/shardingsphere/infra/route/context/RouteContext.java
@@ -18,7 +18,6 @@
 package org.apache.shardingsphere.infra.route.context;
 
 import lombok.Getter;
-import lombok.RequiredArgsConstructor;
 import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
 import 
org.apache.shardingsphere.sql.parser.binder.statement.SQLStatementContext;
 
@@ -29,7 +28,6 @@ import java.util.Map;
 /**
  * Route context.
  */
-@RequiredArgsConstructor
 @Getter
 public final class RouteContext {
     
@@ -41,8 +39,16 @@ public final class RouteContext {
     
     private final Map<Class<? extends ShardingSphereRule>, RouteStageContext> 
routeStageContexts = new LinkedHashMap<>();
     
+    public RouteContext(final SQLStatementContext<?> sqlStatementContext, 
final List<Object> parameters) {
+        this.sqlStatementContext = sqlStatementContext;
+        this.parameters = parameters;
+        routeResult = new RouteResult();
+    }
+    
     public RouteContext(final RouteContext parent, final RouteResult 
routeResult, final RouteStageContext nextRouteStageContext, final Class<? 
extends ShardingSphereRule> ruleType) {
-        this(parent.sqlStatementContext, parent.parameters, routeResult);
+        sqlStatementContext = parent.sqlStatementContext;
+        parameters = parent.parameters;
+        this.routeResult = routeResult;
         addBeforeRouteStageContexts(parent.routeStageContexts);
         addNextRouteStageContext(ruleType, nextRouteStageContext);
     }

Reply via email to