diff --git a/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/DriverExecutor.java b/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/DriverExecutor.java index 04a7a4e0108a1..09c30d141a8c7 100644 --- a/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/DriverExecutor.java +++ b/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/DriverExecutor.java @@ -127,12 +127,14 @@ public DriverExecutor(final ShardingSphereConnection connection) { * @return result set * @throws SQLException SQL exception */ + @SuppressWarnings("rawtypes") public ResultSet executeAdvanceQuery(final ShardingSphereMetaData metaData, final ShardingSphereDatabase database, final QueryContext queryContext, final DriverExecutionPrepareEngine prepareEngine, final Statement statement, final Map columnLabelAndIndexMap, final StatementReplayCallback statementReplayCallback) throws SQLException { Optional trafficInstanceId = connection.getTrafficInstanceId(metaData.getGlobalRuleMetaData().getSingleRule(TrafficRule.class), queryContext); if (trafficInstanceId.isPresent()) { - return trafficExecutor.execute(connection.getProcessId(), database.getName(), trafficInstanceId.get(), queryContext, prepareEngine, getTrafficExecutorCallback(prepareEngine)); + return trafficExecutor.execute( + connection.getProcessId(), database.getName(), trafficInstanceId.get(), queryContext, prepareEngine, getTrafficExecuteQueryCallback(prepareEngine.getType())); } if (sqlFederationEngine.decide(queryContext.getSqlStatementContext(), queryContext.getParameters(), database, metaData.getGlobalRuleMetaData())) { return sqlFederationEngine.executeQuery( @@ -141,8 +143,8 @@ public ResultSet executeAdvanceQuery(final ShardingSphereMetaData metaData, fina return doExecuteQuery(metaData, database, queryContext, prepareEngine, statement, columnLabelAndIndexMap, statementReplayCallback); } - private TrafficExecutorCallback getTrafficExecutorCallback(final DriverExecutionPrepareEngine prepareEngine) { - return JDBCDriverType.STATEMENT.equals(prepareEngine.getType()) ? Statement::executeQuery : ((statement, sql) -> ((PreparedStatement) statement).executeQuery()); + private TrafficExecutorCallback getTrafficExecuteQueryCallback(final String jdbcDriverType) { + return JDBCDriverType.STATEMENT.equals(jdbcDriverType) ? Statement::executeQuery : ((statement, sql) -> ((PreparedStatement) statement).executeQuery()); } private ExecuteQueryCallback getExecuteQueryCallback(final ShardingSphereDatabase database, final QueryContext queryContext, final String jdbcDriverType) { @@ -153,6 +155,7 @@ private ExecuteQueryCallback getExecuteQueryCallback(final ShardingSphereDatabas queryContext.getSqlStatementContext().getSqlStatement(), SQLExecutorExceptionHandler.isExceptionThrown()); } + @SuppressWarnings("rawtypes") private ShardingSphereResultSet doExecuteQuery(final ShardingSphereMetaData metaData, final ShardingSphereDatabase database, final QueryContext queryContext, final DriverExecutionPrepareEngine prepareEngine, final Statement statement, final Map columnLabelAndIndexMap, final StatementReplayCallback statementReplayCallback) throws SQLException { @@ -167,6 +170,7 @@ private ShardingSphereResultSet doExecuteQuery(final ShardingSphereMetaData meta : columnLabelAndIndexMap); } + @SuppressWarnings({"rawtypes", "unchecked"}) private List executeQuery0(final ShardingSphereMetaData metaData, final ShardingSphereDatabase database, final QueryContext queryContext, final DriverExecutionPrepareEngine prepareEngine, final StatementReplayCallback statementReplayCallback) throws SQLException {