Source:
<code>protected void processStreamList(Exchange exchange, PreparedStatementCreator statementCreator, String sql, String preparedQuery) throws Exception { log.trace("processStreamList: {}", preparedQuery); Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { con = jdbcTemplate.getDataSource().getConnection(); ps = statementCreator.createPreparedStatement(con); int expected = parametersCount > 0 ? parametersCount : ps.getParameterMetaData().getParameterCount(); if (alwaysPopulateStatement || expected > 0) { if (batch) { Iterator<?> iterator; if (useMessageBodyForSql) { iterator = exchange.getIn().getHeader(SqlConstants.SQL_PARAMETERS, Iterator.class); } else { iterator = exchange.getIn().getBody(Iterator.class); } while (iterator != null && iterator.hasNext()) { Object value = iterator.next(); Iterator<?> i = sqlPrepareStatementStrategy.createPopulateIterator(sql, preparedQuery, expected, exchange, value); sqlPrepareStatementStrategy.populateStatement(ps, i, expected); ps.addBatch(); } } else { Object value; if (useMessageBodyForSql) { value = exchange.getIn().getHeader(SqlConstants.SQL_PARAMETERS); } else { value = exchange.getIn().getBody(); } Iterator<?> i = sqlPrepareStatementStrategy.createPopulateIterator(sql, preparedQuery, expected, exchange, value); sqlPrepareStatementStrategy.populateStatement(ps, i, expected); } } boolean isResultSet = ps.execute(); <START> exchange.getOut().getHeaders().putAll(exchange.getIn().getHeaders()); <END> if (isResultSet) { rs = ps.getResultSet(); ResultSetIterator iterator = getEndpoint().queryForStreamList(con, ps, rs); if (getEndpoint().isNoop()) { exchange.getOut().setBody(exchange.getIn().getBody()); } else if (getEndpoint().getOutputHeader() != null) { exchange.getOut().setBody(exchange.getIn().getBody()); exchange.getOut().setHeader(getEndpoint().getOutputHeader(), iterator); } else { exchange.getOut().setBody(iterator); } exchange.addOnCompletion(new ResultSetIteratorCompletion(iterator)); } } catch (Exception e) { closeConnection(con); closeStatement(ps); closeResultSet(rs); throw e; } }</code><technical_language>move this code if (isResultSet) headers is pass if set some data a result set</technical_language>

Target:
protected void processStreamList(Exchange exchange, PreparedStatementCreator statementCreator, String sql, String preparedQuery) throws Exception { log.trace("processStreamList: {}", preparedQuery); Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { con = jdbcTemplate.getDataSource().getConnection(); ps = statementCreator.createPreparedStatement(con); int expected = parametersCount > 0 ? parametersCount : ps.getParameterMetaData().getParameterCount(); if (alwaysPopulateStatement || expected > 0) { if (batch) { Iterator<?> iterator; if (useMessageBodyForSql) { iterator = exchange.getIn().getHeader(SqlConstants.SQL_PARAMETERS, Iterator.class); } else { iterator = exchange.getIn().getBody(Iterator.class); } while (iterator != null && iterator.hasNext()) { Object value = iterator.next(); Iterator<?> i = sqlPrepareStatementStrategy.createPopulateIterator(sql, preparedQuery, expected, exchange, value); sqlPrepareStatementStrategy.populateStatement(ps, i, expected); ps.addBatch(); } } else { Object value; if (useMessageBodyForSql) { value = exchange.getIn().getHeader(SqlConstants.SQL_PARAMETERS); } else { value = exchange.getIn().getBody(); } Iterator<?> i = sqlPrepareStatementStrategy.createPopulateIterator(sql, preparedQuery, expected, exchange, value); sqlPrepareStatementStrategy.populateStatement(ps, i, expected); } } boolean isResultSet = ps.execute(); if (isResultSet) { rs = ps.getResultSet(); ResultSetIterator iterator = getEndpoint().queryForStreamList(con, ps, rs); exchange.getOut().getHeaders().putAll(exchange.getIn().getHeaders()); if (getEndpoint().isNoop()) { exchange.getOut().setBody(exchange.getIn().getBody()); } else if (getEndpoint().getOutputHeader() != null) { exchange.getOut().setBody(exchange.getIn().getBody()); exchange.getOut().setHeader(getEndpoint().getOutputHeader(), iterator); } else { exchange.getOut().setBody(iterator); } exchange.addOnCompletion(new ResultSetIteratorCompletion(iterator)); } } catch (Exception e) { closeConnection(con); closeStatement(ps); closeResultSet(rs); throw e; } }