DataServiceExecutor { public static String calculateTransname( SQL sql, boolean isService ) { StringBuilder sbsql = new StringBuilder( sql.getServiceName() ); sbsql.append( " - " ); if ( isService ) { sbsql.append( "Service" ); } else { sbsql.append( "SQL" ); } sbsql.append( " - " ); sbsql.append( sql.getSqlString().hashCode() ); for ( int i = sbsql.length() - 1; i >= 0; i-- ) { if ( sbsql.charAt( i ) == '\n' || sbsql.charAt( i ) == '\r' ) { sbsql.setCharAt( i, ' ' ); } } return sbsql.toString(); } private  DataServiceExecutor( Builder builder ); static void writeMetadata( DataOutputStream dos, String... metadatas ); DataServiceExecutor executeQuery( final DataOutputStream dos ); DataServiceExecutor executeQuery( Observer<RowMetaAndData> consumer ); DataServiceExecutor executeStreamingQuery( final Observer<List<RowMetaAndData>> streamingConsumer, boolean pollingMode ); String getStreamingGenTransCacheKey(); DataServiceExecutor executeDefaultQuery( final Observer<RowMetaAndData> consumer ); DataServiceExecutor executeQuery(); void executeListeners( ExecutionPoint... stages ); RowProducer addRowProducer(); void waitUntilFinished(); TransMeta getServiceTransMeta(); TransMeta getGenTransMeta(); DataServiceMeta getService(); Trans getServiceTrans(); Trans getGenTrans(); String getServiceName(); Map<String, String> getParameters(); String getId(); Boolean hasErrors(); static String calculateTransname( SQL sql, boolean isService ); void stop( boolean stopTrans ); boolean isStopped(); SQL getSql(); String getResultStepName(); int getRowLimit(); int getServiceRowLimit(); ListMultimap<ExecutionPoint, Runnable> getListenerMap();  }
@Test public void testCalculateTransNameWithNewlines() throws KettleException { String serviceName = "name\nnewline"; SQL sql = new SQL( "select * from \"" + serviceName + "\"" ); sql.setServiceName( serviceName ); Assert.assertEquals( "name newline - SQL - " + sql.getSqlString().hashCode(), DataServiceExecutor.calculateTransname( sql, false ) ); serviceName = "name\rnewline"; sql = new SQL( "select * from \"" + serviceName + "\"" ); sql.setServiceName( serviceName ); Assert.assertEquals( "name newline - SQL - " + sql.getSqlString().hashCode(), DataServiceExecutor.calculateTransname( sql, false ) ); serviceName = "name\r\nnewline"; sql = new SQL( "select * from \"" + serviceName + "\"" ); sql.setServiceName( serviceName ); Assert.assertEquals( "name newline - SQL - " + sql.getSqlString().hashCode(), DataServiceExecutor.calculateTransname( sql, false ) ); }