This is an automated email from the ASF dual-hosted git repository.

Croway pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 7c87ed54d017 CAMEL-27011: camel-jdbc, camel-sql - a StreamList row 
that cannot be mapped to the outputClass keeps the iterator failing, so a 
redelivered split no longer skips it
7c87ed54d017 is described below

commit 7c87ed54d0174531cca9cd3ed41a57757f69beaa
Author: croway <[email protected]>
AuthorDate: Mon Nov 16 10:03:12 2026 +0100

    CAMEL-27011: camel-jdbc, camel-sql - a StreamList row that cannot be mapped 
to the outputClass keeps the iterator failing, so a redelivered split no longer 
skips it
    
    With outputType=StreamList and outputClass, a row whose mapping fails was
    skipped by a redelivered split: camel-support's StreamListIterator takes the
    row from the delegate before mapping it (camel-jdbc, camel-spring-jdbc), and
    camel-sql's ResultSetIterator did not catch a RuntimeException of the row
    mapper, so the iterator closed by the failed split looked finished.
    
    As for a read failure (CAMEL-26996), the iterator now remembers the mapping
    failure and hasNext()/next() throw a RuntimeCamelException with it as cause.
---
 .../apache/camel/catalog/docs/jdbc-component.adoc  |   4 +-
 .../apache/camel/catalog/docs/sql-component.adoc   |   3 +-
 .../camel-jdbc/src/main/docs/jdbc-component.adoc   |   4 +-
 .../JdbcProducerStreamListMappingFailureTest.java  | 117 ++++++++++++++++
 .../camel-sql/src/main/docs/sql-component.adoc     |   3 +-
 .../camel/component/sql/ResultSetIterator.java     |  23 ++-
 .../SqlProducerStreamListMappingFailureTest.java   | 154 +++++++++++++++++++++
 .../apache/camel/support/StreamListIterator.java   |  35 ++++-
 .../camel/support/StreamListIteratorTest.java      |  59 ++++++++
 .../ROOT/pages/camel-4x-upgrade-guide-4_24.adoc    |  13 ++
 10 files changed, 403 insertions(+), 12 deletions(-)

diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/jdbc-component.adoc
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/jdbc-component.adoc
index a5ea7f706a2a..0f0119c047a0 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/jdbc-component.adoc
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/jdbc-component.adoc
@@ -66,7 +66,9 @@ in the `CamelJdbcUpdateCount` header.
 
 When reading a row of a `StreamList` fails (for example, the connection is 
lost), the iterator keeps failing instead
 of ending, so a split that is redelivered over it fails too, rather than 
succeeding with the rows read before the
-failure.
+failure. The same applies when a row cannot be mapped to the `outputClass` 
(for example, a value that does not convert
+to the type of its property): the iterator keeps failing instead of going on 
with the next row, so a redelivered split
+does not skip that row.
 
 *Note:* This component fetches `ResultSetMetaData` to be able to return
 the column name as the key in the `Map`.
diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/sql-component.adoc
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/sql-component.adoc
index 272619d4b03f..e248144f71fe 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/sql-component.adoc
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/sql-component.adoc
@@ -214,7 +214,8 @@ This allows processing the data in a streaming fashion 
which, for example,
 can be used by the Splitter EIP to process each row one at a time, and load 
data from the database as needed.
 The rows can be read once: when reading a row fails (for example, the 
connection is lost), the iterator keeps failing
 instead of ending, so a split that is redelivered over it fails too, rather 
than succeeding with the rows read before
-the failure.
+the failure. The same applies when a row cannot be mapped to the `outputClass` 
(for example, a value that does not
+convert to the type of its property).
 
 [tabs]
 ====
diff --git a/components/camel-jdbc/src/main/docs/jdbc-component.adoc 
b/components/camel-jdbc/src/main/docs/jdbc-component.adoc
index a5ea7f706a2a..0f0119c047a0 100644
--- a/components/camel-jdbc/src/main/docs/jdbc-component.adoc
+++ b/components/camel-jdbc/src/main/docs/jdbc-component.adoc
@@ -66,7 +66,9 @@ in the `CamelJdbcUpdateCount` header.
 
 When reading a row of a `StreamList` fails (for example, the connection is 
lost), the iterator keeps failing instead
 of ending, so a split that is redelivered over it fails too, rather than 
succeeding with the rows read before the
-failure.
+failure. The same applies when a row cannot be mapped to the `outputClass` 
(for example, a value that does not convert
+to the type of its property): the iterator keeps failing instead of going on 
with the next row, so a redelivered split
+does not skip that row.
 
 *Note:* This component fetches `ResultSetMetaData` to be able to return
 the column name as the key in the `Map`.
diff --git 
a/components/camel-jdbc/src/test/java/org/apache/camel/component/jdbc/JdbcProducerStreamListMappingFailureTest.java
 
b/components/camel-jdbc/src/test/java/org/apache/camel/component/jdbc/JdbcProducerStreamListMappingFailureTest.java
new file mode 100644
index 000000000000..d5029388ad44
--- /dev/null
+++ 
b/components/camel-jdbc/src/test/java/org/apache/camel/component/jdbc/JdbcProducerStreamListMappingFailureTest.java
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.jdbc;
+
+import java.sql.SQLException;
+import java.util.List;
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Exchange;
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.jupiter.api.Test;
+import org.springframework.jdbc.core.JdbcTemplate;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * With {@code outputType=StreamList} and {@code outputClass}, each row is 
mapped to the output class when the route
+ * reads it. A row that cannot be mapped has already been read from the result 
set, so the iterator must not go on with
+ * the next row: a split that is redelivered over it must fail again, not 
succeed without that row.
+ */
+public class JdbcProducerStreamListMappingFailureTest extends 
AbstractJdbcTestSupport {
+
+    private static final String QUERY = "select * from item order by id";
+
+    @EndpointInject("mock:row")
+    private MockEndpoint row;
+
+    @Override
+    public void setupResources() {
+        super.setupResources();
+        JdbcTemplate jdbc = new JdbcTemplate(db);
+        jdbc.execute("create table item (id integer, status varchar(10))");
+        // the status of the second row is not a constant of Status, so that 
row cannot be mapped to Item
+        jdbc.execute("insert into item values (1, 'NEW'), (2, 'LOST'), (3, 
'DONE')");
+    }
+
+    @Test
+    public void 
rowThatCannotBeMappedFailsTheExchangeWhenTheSplitIsRedelivered() throws 
Exception {
+        row.expectedMessageCount(1);
+
+        Exchange out = template.send("direct:splitWithRedelivery", e -> 
e.getMessage().setBody(QUERY));
+
+        // each redelivery of the split fails too, instead of going on with 
the row after the one that failed
+        assertNotNull(out.getException(), () -> "the exchange succeeded with 
the rows " + routedIds());
+        RuntimeCamelException failure = 
assertInstanceOf(RuntimeCamelException.class, out.getException());
+        SQLException mapping = assertInstanceOf(SQLException.class, 
failure.getCause().getCause());
+        assertTrue(mapping.getMessage().startsWith("Error setting properties 
on output class"), mapping.getMessage());
+        assertEquals(2, 
out.getMessage().getHeader(Exchange.REDELIVERY_COUNTER, Integer.class));
+        MockEndpoint.assertIsSatisfied(context);
+        assertEquals(List.of(1), routedIds());
+    }
+
+    private List<Integer> routedIds() {
+        return row.getReceivedExchanges().stream().map(e -> 
e.getMessage().getBody(Item.class).getId()).toList();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("direct:splitWithRedelivery")
+                        
.errorHandler(defaultErrorHandler().maximumRedeliveries(2).redeliveryDelay(0))
+                        .to("jdbc:testdb?outputType=StreamList&outputClass=" + 
Item.class.getName())
+                        .split(body()).streaming()
+                            .to("mock:row")
+                        .end();
+            }
+        };
+    }
+
+    public enum Status {
+        NEW,
+        DONE
+    }
+
+    public static class Item {
+
+        private int id;
+        private Status status;
+
+        public int getId() {
+            return id;
+        }
+
+        public void setId(int id) {
+            this.id = id;
+        }
+
+        public Status getStatus() {
+            return status;
+        }
+
+        public void setStatus(Status status) {
+            this.status = status;
+        }
+    }
+}
diff --git a/components/camel-sql/src/main/docs/sql-component.adoc 
b/components/camel-sql/src/main/docs/sql-component.adoc
index 272619d4b03f..e248144f71fe 100644
--- a/components/camel-sql/src/main/docs/sql-component.adoc
+++ b/components/camel-sql/src/main/docs/sql-component.adoc
@@ -214,7 +214,8 @@ This allows processing the data in a streaming fashion 
which, for example,
 can be used by the Splitter EIP to process each row one at a time, and load 
data from the database as needed.
 The rows can be read once: when reading a row fails (for example, the 
connection is lost), the iterator keeps failing
 instead of ending, so a split that is redelivered over it fails too, rather 
than succeeding with the rows read before
-the failure.
+the failure. The same applies when a row cannot be mapped to the `outputClass` 
(for example, a value that does not
+convert to the type of its property).
 
 [tabs]
 ====
diff --git 
a/components/camel-sql/src/main/java/org/apache/camel/component/sql/ResultSetIterator.java
 
b/components/camel-sql/src/main/java/org/apache/camel/component/sql/ResultSetIterator.java
index 5ae7fa6ed6ee..e9aa23a94953 100644
--- 
a/components/camel-sql/src/main/java/org/apache/camel/component/sql/ResultSetIterator.java
+++ 
b/components/camel-sql/src/main/java/org/apache/camel/component/sql/ResultSetIterator.java
@@ -44,8 +44,9 @@ public class ResultSetIterator implements Iterator<Object>, 
Closeable {
     private final RowMapper<?> rowMapper;
     private final AtomicBoolean closed = new AtomicBoolean();
     private int rowNum;
-    // set when reading a row has failed: the rest of the result cannot be 
read, so the iterator must not look finished
-    private volatile SQLException failure;
+    // set when reading or mapping a row has failed: the rest of the result 
cannot be read, so the iterator must not
+    // look finished (an SQLException, or the RuntimeException of the row 
mapper)
+    private volatile Exception failure;
 
     public ResultSetIterator(Connection connection, Statement statement, 
ResultSet resultSet,
                              RowMapper<?> rowMapper) throws SQLException {
@@ -71,15 +72,16 @@ public class ResultSetIterator implements Iterator<Object>, 
Closeable {
     /**
      * Whether there are more rows.
      *
-     * @throws RuntimeCamelException when reading a row has failed before, as 
whether there are more rows is then
-     *                               unknown (whoever reads the iterator 
again, such as a redelivered split, gets an
-     *                               error and not the end of the rows)
+     * @throws RuntimeCamelException when reading or mapping a row has failed 
before, as whether there are more rows is
+     *                               then unknown (whoever reads the iterator 
again, such as a redelivered split, gets
+     *                               an error and not the end of the rows)
      */
     @Override
     public boolean hasNext() {
-        SQLException cause = failure;
+        Exception cause = failure;
         if (cause != null) {
-            throw new RuntimeCamelException("Cannot process result: reading a 
row failed before", cause);
+            String step = cause instanceof SQLException ? "reading" : 
"mapping";
+            throw new RuntimeCamelException("Cannot process result: " + step + 
" a row failed before", cause);
         }
         return !closed.get();
     }
@@ -98,6 +100,13 @@ public class ResultSetIterator implements Iterator<Object>, 
Closeable {
             failure = e;
             close();
             throw new RuntimeCamelException("Cannot process result", e);
+        } catch (RuntimeException e) {
+            // the row mapper failed (such as a value that does not convert to 
a property of the outputClass): keep
+            // failing, as a closed iterator looks finished (the splitter 
closes it when the split fails), and whoever
+            // reads it again, such as a redelivered split, must not skip the 
rest of the rows
+            failure = e;
+            close();
+            throw e;
         }
     }
 
diff --git 
a/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlProducerStreamListMappingFailureTest.java
 
b/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlProducerStreamListMappingFailureTest.java
new file mode 100644
index 000000000000..c393e38787d7
--- /dev/null
+++ 
b/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlProducerStreamListMappingFailureTest.java
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.sql;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.util.List;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.TypeMismatchException;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+/**
+ * With {@code outputType=StreamList} and {@code outputClass}, each row is 
mapped to the output class when the route
+ * reads it. When a row cannot be mapped, the iterator must not look finished: 
a split that is redelivered over it must
+ * fail again, not succeed without that row and the rows after it.
+ */
+public class SqlProducerStreamListMappingFailureTest extends CamelTestSupport {
+
+    private static final String QUERY = "select * from item order by id";
+
+    private EmbeddedDatabase db;
+
+    @Override
+    public void doPreSetup() throws Exception {
+        db = new EmbeddedDatabaseBuilder()
+                .setName(getClass().getSimpleName())
+                .setType(EmbeddedDatabaseType.H2)
+                .build();
+        JdbcTemplate jdbc = new JdbcTemplate(db);
+        jdbc.execute("create table item (id integer, status varchar(10))");
+        // the status of the second row is not a constant of Status, so that 
row cannot be mapped to Item
+        jdbc.execute("insert into item values (1, 'NEW'), (2, 'LOST'), (3, 
'DONE')");
+    }
+
+    @Override
+    public void doPostTearDown() throws Exception {
+        if (db != null) {
+            db.shutdown();
+        }
+    }
+
+    @Test
+    public void 
rowThatCannotBeMappedFailsTheExchangeWhenTheSplitIsRedelivered() throws 
Exception {
+        MockEndpoint row = getMockEndpoint("mock:row");
+        row.expectedMessageCount(1);
+
+        Exchange out = template.send("direct:splitWithRedelivery", e -> 
e.getMessage().setBody("go"));
+
+        // each redelivery of the split fails too, instead of finding no more 
rows
+        assertNotNull(out.getException(), () -> "the exchange succeeded with 
the rows " + routedIds(row));
+        RuntimeCamelException failure = 
assertInstanceOf(RuntimeCamelException.class, out.getException());
+        assertInstanceOf(TypeMismatchException.class, failure.getCause());
+        assertEquals(2, 
out.getMessage().getHeader(Exchange.REDELIVERY_COUNTER, Integer.class));
+        MockEndpoint.assertIsSatisfied(context);
+        assertEquals(List.of(1), routedIds(row));
+    }
+
+    private static List<Integer> routedIds(MockEndpoint row) {
+        return row.getReceivedExchanges().stream().map(e -> 
e.getMessage().getBody(Item.class).getId()).toList();
+    }
+
+    @Test
+    public void iteratorKeepsFailingOnceMappingARowHasFailed() throws 
Exception {
+        try (Connection conn = db.getConnection(); Statement stmt = 
conn.createStatement()) {
+            ResultSet rs = stmt.executeQuery(QUERY);
+            ResultSetIterator rows = new ResultSetIterator(conn, stmt, rs, new 
BeanPropertyRowMapper<>(Item.class));
+            assertEquals(1, ((Item) rows.next()).getId());
+
+            // the first failure is the one of the row mapper, as before
+            TypeMismatchException failure = 
assertThrows(TypeMismatchException.class, rows::next);
+
+            assertSame(failure, assertThrows(RuntimeCamelException.class, 
rows::hasNext).getCause());
+            assertSame(failure, assertThrows(RuntimeCamelException.class, 
rows::next).getCause());
+            // the splitter closes the iterator when the split fails
+            rows.close();
+            assertSame(failure, assertThrows(RuntimeCamelException.class, 
rows::hasNext).getCause());
+        }
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            @Override
+            public void configure() {
+                getContext().getComponent("sql", 
SqlComponent.class).setDataSource(db);
+
+                from("direct:splitWithRedelivery")
+                        
.errorHandler(defaultErrorHandler().maximumRedeliveries(2).redeliveryDelay(0))
+                        .to("sql:" + QUERY + 
"?outputType=StreamList&outputClass=" + Item.class.getName())
+                        .split(body()).streaming()
+                            .to("mock:row")
+                        .end();
+            }
+        };
+    }
+
+    public enum Status {
+        NEW,
+        DONE
+    }
+
+    public static class Item {
+
+        private int id;
+        private Status status;
+
+        public int getId() {
+            return id;
+        }
+
+        public void setId(int id) {
+            this.id = id;
+        }
+
+        public Status getStatus() {
+            return status;
+        }
+
+        public void setStatus(Status status) {
+            this.status = status;
+        }
+    }
+}
diff --git 
a/core/camel-support/src/main/java/org/apache/camel/support/StreamListIterator.java
 
b/core/camel-support/src/main/java/org/apache/camel/support/StreamListIterator.java
index fca9ad59f944..cbb02bde51d4 100644
--- 
a/core/camel-support/src/main/java/org/apache/camel/support/StreamListIterator.java
+++ 
b/core/camel-support/src/main/java/org/apache/camel/support/StreamListIterator.java
@@ -18,9 +18,15 @@ package org.apache.camel.support;
 
 import java.util.Iterator;
 
+import org.apache.camel.RuntimeCamelException;
+
 /**
  * Iterator that applies a {@link RowMapper} transformation to each element 
lazily. Useful for memory-efficient
  * processing of large result sets from databases or APIs.
+ * <p>
+ * When mapping a row fails, that row has already been taken from the 
delegate, so the iterator keeps failing instead of
+ * going on with the next row (whoever reads the iterator again, such as a 
redelivered split, gets an error and does not
+ * skip the row).
  *
  * @param <T> the input type from the delegate iterator
  * @param <E> the output type after applying the row mapper
@@ -29,21 +35,48 @@ public final class StreamListIterator<T, E> implements 
Iterator<E> {
 
     private final RowMapper<T, E> rowMapper;
     private final Iterator<T> delegate;
+    // set when mapping a row has failed: the row is consumed from the 
delegate, so going on would skip it
+    private volatile RuntimeException failure;
 
     public StreamListIterator(RowMapper<T, E> rowMapper, Iterator<T> delegate) 
{
         this.rowMapper = rowMapper;
         this.delegate = delegate;
     }
 
+    /**
+     * Whether there are more rows.
+     *
+     * @throws RuntimeCamelException when mapping a row has failed before, 
with that failure as cause
+     */
     @Override
     public boolean hasNext() {
+        checkFailure();
         return delegate.hasNext();
     }
 
+    /**
+     * The next row, mapped with the row mapper.
+     *
+     * @throws RuntimeCamelException when mapping a row has failed before, 
with that failure as cause (the first time,
+     *                               the exception of the row mapper is thrown 
as it is)
+     */
     @Override
     public E next() {
+        checkFailure();
         T row = delegate.next();
-        return rowMapper.map(row);
+        try {
+            return rowMapper.map(row);
+        } catch (RuntimeException e) {
+            failure = e;
+            throw e;
+        }
+    }
+
+    private void checkFailure() {
+        RuntimeException cause = failure;
+        if (cause != null) {
+            throw new RuntimeCamelException("Cannot process result: mapping a 
row failed before", cause);
+        }
     }
 
     @Override
diff --git 
a/core/camel-support/src/test/java/org/apache/camel/support/StreamListIteratorTest.java
 
b/core/camel-support/src/test/java/org/apache/camel/support/StreamListIteratorTest.java
new file mode 100644
index 000000000000..c6a3e82e930f
--- /dev/null
+++ 
b/core/camel-support/src/test/java/org/apache/camel/support/StreamListIteratorTest.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.support;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.NoSuchElementException;
+
+import org.apache.camel.RuntimeCamelException;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.assertj.core.api.Assertions.catchThrowable;
+
+class StreamListIteratorTest {
+
+    @Test
+    void mapsEachRow() {
+        StreamListIterator<String, Integer> rows = new 
StreamListIterator<>(Integer::valueOf, List.of("1", "2").iterator());
+
+        List<Integer> mapped = new ArrayList<>();
+        rows.forEachRemaining(mapped::add);
+
+        assertThat(mapped).containsExactly(1, 2);
+        assertThat(rows.hasNext()).isFalse();
+        
assertThatThrownBy(rows::next).isInstanceOf(NoSuchElementException.class);
+    }
+
+    @Test
+    void keepsFailingOnceMappingARowHasFailed() {
+        StreamListIterator<String, Integer> rows
+                = new StreamListIterator<>(Integer::valueOf, List.of("1", 
"two", "3").iterator());
+        assertThat(rows.next()).isEqualTo(1);
+
+        // the first failure is the one of the row mapper
+        Throwable failure = catchThrowable(rows::next);
+        assertThat(failure).isInstanceOf(NumberFormatException.class);
+
+        // the row that failed has been taken from the delegate: going on 
would skip it, so the iterator keeps failing
+        
assertThatThrownBy(rows::hasNext).isInstanceOf(RuntimeCamelException.class).cause().isSameAs(failure);
+        
assertThatThrownBy(rows::next).isInstanceOf(RuntimeCamelException.class).cause().isSameAs(failure);
+        
assertThatThrownBy(rows::hasNext).isInstanceOf(RuntimeCamelException.class).cause().isSameAs(failure);
+    }
+}
diff --git 
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc 
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
index 199ccdb66cf4..a4bd0d7a1650 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
@@ -2179,6 +2179,19 @@ the body no longer looks finished: `hasNext()` and 
`next()` now throw a `Runtime
 redelivered over the same iterator (an error handler with redeliveries) found 
no more rows and the exchange succeeded
 with only the rows read before the failure. It now fails once the redeliveries 
are exhausted.
 
+=== camel-jdbc, camel-spring-jdbc, camel-sql - outputType=StreamList: a row 
that cannot be mapped to the outputClass keeps failing
+
+With `outputType=StreamList` and `outputClass`, once mapping a row to the 
`outputClass` has failed (for example, a value
+that does not convert to the type of its property), `hasNext()` and `next()` 
of the iterator of the body now throw a
+`RuntimeCamelException` with that failure as cause, as after a row that failed 
to read. The first `next()` throws the
+exception of the mapping, as before. Before, a split that was redelivered over 
the same iterator went on with the next
+row (camel-jdbc, camel-spring-jdbc), or found no more rows (camel-sql, when 
the row mapper failed with a
+`RuntimeException`, such as Spring's `TypeMismatchException`), and the 
exchange succeeded without the row that could not
+be mapped (with camel-sql, without the rows after it either). It now fails 
once the redeliveries are exhausted.
+
+With camel-jdbc, code that reads the iterator itself and goes on after a row 
that cannot be mapped now gets this
+exception from `hasNext()`: to skip such rows, read the rows without 
`outputClass` and map them in the route.
+
 === camel-jdbc, camel-spring-jdbc - outputType=StreamList commits when the 
exchange is done
 
 With `outputType=StreamList` and `resetAutoCommit=true` (the default), the 
producer now commits the transaction of the

Reply via email to