Buggy code:
public class DruidSelectParser extends DefaultDruidParser { protected boolean isNeedParseOrderAgg = true ; @ Override public void statementParse ( SchemaConfig schema , RouteResultset rrs , SQLStatement stmt ) { } protected void parseOrderAggGroupMysql ( SchemaConfig schema , SQLStatement stmt , RouteResultset rrs , MySqlSelectQueryBlock mysqlSelectQuery ) { } protected Map < String , String > parseAggGroupCommon ( SchemaConfig schema , SQLStatement stmt , RouteResultset rrs , SQLSelectQueryBlock mysqlSelectQuery ) { } private HavingCols buildGroupByHaving ( SQLExpr having ) { } private boolean isRoutMultiNode ( SchemaConfig schema , RouteResultset rrs ) { } private String getFieldName ( SQLSelectItem item ) { } @ Override public void changeSql ( SchemaConfig schema , RouteResultset rrs , SQLStatement stmt , LayerCachePool cachePool ) throws SQLNonTransientException { } private Map < String , Map < String , Set < ColumnRoutePair > > > getAllConditions ( ) { } private void tryRoute ( SchemaConfig schema , RouteResultset rrs , LayerCachePool cachePool ) throws SQLNonTransientException { if ( rrs . isFinishedRoute ( ) ) { return ; } <START_BUG> if ( ( ( ctx . getTables ( ) ) == null ) || ( ( ctx . getTables ( ) . size ( ) ) == 0 ) ) { <END_BUG> rrs = RouterUtil . routeToSingleNode ( rrs , schema . getRandomDataNode ( ) , ctx . getSql ( ) ) ; rrs . setFinishedRoute ( true ) ; return ; } SortedSet < RouteResultsetNode > nodeSet = new TreeSet < RouteResultsetNode > ( ) ; boolean isAllGlobalTable = RouterUtil . isAllGlobalTable ( ctx , schema ) ; for ( RouteCalculateUnit unit : ctx . getRouteCalculateUnits ( ) ) { RouteResultset rrsTmp = RouterUtil . tryRouteForTables ( schema , ctx , unit , rrs , true , cachePool ) ; if ( rrsTmp != null ) { for ( RouteResultsetNode node : rrsTmp . getNodes ( ) ) { nodeSet . add ( node ) ; } } if ( isAllGlobalTable ) { break ; } } if ( ( nodeSet . size ( ) ) == 0 ) { String msg = "<seq2seq4repair_space>find<seq2seq4repair_space>no<seq2seq4repair_space>Route:" + ( ctx . getSql ( ) ) ; LOGGER . warn ( msg ) ; throw new SQLNonTransientException ( msg ) ; } RouteResultsetNode [ ] nodes = new RouteResultsetNode [ nodeSet . size ( ) ] ; int i = 0 ; for ( Iterator < RouteResultsetNode > iterator = nodeSet . iterator ( ) ; iterator . hasNext ( ) ; ) { nodes [ i ] = ( ( RouteResultsetNode ) ( iterator . next ( ) ) ) ; i ++ ; } rrs . setNodes ( nodes ) ; rrs . setFinishedRoute ( true ) ; } protected String getCurentDbType ( ) { } protected String getSql ( RouteResultset rrs , SQLStatement stmt , boolean isNeedAddLimit ) { } protected boolean isNeedChangeLimit ( RouteResultset rrs ) { } private boolean isNeedCache ( SchemaConfig schema , RouteResultset rrs , MySqlSelectQueryBlock mysqlSelectQuery , Map < String , Map < String , Set < ColumnRoutePair > > > allConditions ) { } private boolean isNeedAddLimit ( SchemaConfig schema , RouteResultset rrs , MySqlSelectQueryBlock mysqlSelectQuery , Map < String , Map < String , Set < ColumnRoutePair > > > allConditions ) { } private String getAliaColumn ( Map < String , String > aliaColumns , String column ) { } private String [ ] buildGroupByCols ( List < SQLExpr > groupByItems , Map < String , String > aliaColumns ) { } protected LinkedHashMap < String , Integer > buildOrderByCols ( List < SQLSelectOrderByItem > orderByItems , Map < String , String > aliaColumns ) { } private boolean isConditionAlwaysTrue ( SQLStatement statement ) { } protected void setLimitIFChange ( SQLStatement stmt , RouteResultset rrs , SchemaConfig schema , SQLBinaryOpExpr one , int firstrownum , int lastrownum ) { } }

Fix:
if ( ( ( ( ctx . getTables ( ) ) == null ) || ( ( ctx . getTables ( ) . size ( ) ) == 0 ) ) && ( ( ( ctx . getTableAliasMap ( ) ) == null ) || ( ctx . getTableAliasMap ( ) . isEmpty ( ) ) ) ) {