Issue 1:
java.lang.NullPointerException: null

at org.apache.shardingsphere.core.execute.sql.execute.result.MemoryQueryResult.getRowValue(MemoryQueryResult.java:88) ~[sharding-core-execute-4.0.0.jar:4.0.0]

at org.apache.shardingsphere.core.execute.sql.execute.result.MemoryQueryResult.getRows(MemoryQueryResult.java:63) ~[sharding-core-execute-4.0.0.jar:4.0.0]

at org.apache.shardingsphere.core.execute.sql.execute.result.MemoryQueryResult.(MemoryQueryResult.java:55) ~[sharding-core-execute-4.0.0.jar:4.0.0]

at org.apache.shardingsphere.shardingjdbc.executor.PreparedStatementExecutor.getQueryResult(PreparedStatementExecutor.java:116) ~[sharding-jdbc-core-4.0.0.jar:4.0.0]

at org.apache.shardingsphere.shardingjdbc.executor.PreparedStatementExecutor.access$200(PreparedStatementExecutor.java:50) ~[sharding-jdbc-core-4.0.0.jar:4.0.0]

at org.apache.shardingsphere.shardingjdbc.executor.PreparedStatementExecutor$2.executeSQL(PreparedStatementExecutor.java:106) ~[sharding-jdbc-core-4.0.0.jar:4.0.0]

at org.apache.shardingsphere.shardingjdbc.executor.PreparedStatementExecutor$2.executeSQL(PreparedStatementExecutor.java:102) ~[sharding-jdbc-core-4.0.0.jar:4.0.0]

at org.apache.shardingsphere.core.execute.sql.execute.SQLExecuteCallback.execute0(SQLExecuteCallback.java:79) ~[sharding-core-execute-4.0.0.jar:4.0.0]

at org.apache.shardingsphere.core.execute.sql.execute.SQLExecuteCallback.execute(SQLExecuteCallback.java:61) ~[sharding-core-execute-4.0.0.jar:4.0.0]

at org.apache.shardingsphere.core.execute.engine.ShardingExecuteEngine.syncGroupExecute(ShardingExecuteEngine.java:125) ~[sharding-core-execute-4.0.0.jar:4.0.0]

at org.apache.shardingsphere.core.execute.engine.ShardingExecuteEngine.parallelExecute(ShardingExecuteEngine.java:102) ~[sharding-core-execute-4.0.0.jar:4.0.0]

at org.apache.shardingsphere.core.execute.engine.ShardingExecuteEngine.groupExecute(ShardingExecuteEngine.java:83) ~[sharding-core-execute-4.0.0.jar:4.0.0]

at org.apache.shardingsphere.core.execute.sql.execute.SQLExecuteTemplate.executeGroup(SQLExecuteTemplate.java:73) ~[sharding-core-execute-4.0.0.jar:4.0.0]

at org.apache.shardingsphere.core.execute.sql.execute.SQLExecuteTemplate.executeGroup(SQLExecuteTemplate.java:56) ~[sharding-core-execute-4.0.0.jar:4.0.0]

at org.apache.shardingsphere.shardingjdbc.executor.AbstractStatementExecutor.executeCallback(AbstractStatementExecutor.java:140) ~[sharding-jdbc-core-4.0.0.jar:4.0.0]

at org.apache.shardingsphere.shardingjdbc.executor.PreparedStatementExecutor.executeQuery(PreparedStatementExecutor.java:109) ~[sharding-jdbc-core-4.0.0.jar:4.0.0]

at org.apache.shardingsphere.shardingjdbc.jdbc.core.statement.ShardingPreparedStatement.executeQuery(ShardingPreparedStatement.java:123) ~[sharding-jdbc-core-4.0.0.jar:4.0.0]

Issue 2:
version : 3.0.0.M1

project : sharding-jdbc

Expected behavior : when table rule not define , sharding-jdbc create it and put it into cache

Actual behavior : when logicTableName not found in tableRules, sharding-jdbc will create table rule and not put it into cache , It will run groovy script . If this sql run many times , will create many groovy classlaoder. After that will got "java.lang.OutOfMemoryError:Permgen space" error.

Reason :

I debug and found this code.

// class io.shardingsphrer.cor.rule.ShardingRule

public Optional<TableRule> tryFindTableRuleByActualTable(final String actualTableName) {
for (TableRule each : tableRules) {
if (each.isExisted(actualTableName)) {
return Optional.of(each);
}
}
return Optional.absent();
}

public TableRule getTableRuleByLogicTableName(final String logicTableName) {
Optional<TableRule> tableRule = tryFindTableRuleByLogicTable(logicTableName.toLowerCase());
if (tableRule.isPresent()) {
return tableRule.get();
}
if (!Strings.isNullOrEmpty(shardingDataSourceNames.getDefaultDataSourceName())) {
return new TableRule(shardingDataSourceNames.getDefaultDataSourceName(), logicTableName);
}
throw new ShardingConfigurationException("Cannot find table rule and default data source with logic table: '%s'", logicTableName);
}

tableRule isPresent and create new one . Cache it into tableRules than everytime create it .

When someone make a mistake and publish to production env , will be a disaster.This is not friendly for developers.