davsclaus opened a new pull request, #28906: URL: https://github.com/apache/camel/pull/28906
Fixes [CAMEL-26128](https://issues.apache.org/jira/browse/CAMEL-26128). All four bugs of the issue are real and fixed. The new `FlatpackSplitRowsTest` reproduces each one: before the fix 7 of its tests failed (File body: `NoTypeConversionAvailableException`; rows: NPE "currentRecord is null"; List: 1 row of 4; exception: not thrown). ### 1. An exception in the consumer route is lost `FlatpackEndpoint.processDataSet` sent each row on a correlated copy and did not copy back its exception, so the producer exchange completed normally. Now the first exception of a row exchange is set on the original exchange, and the producer stops at that row (the next rows are not sent). This works like a pipeline. The splitter's default (send the remaining rows, then fail) was the other option. But the correlated copy of each next row would carry the exception that is now on the original exchange, so stopping is the simpler and clearer choice. ### 2. With splitRows every row exchange shared one DataSet cursor Every row message got the same parsed `DataSet`. `getBody(List.class)` moved the cursor to the end (only row 0 was sent), and a body read after the next row (as after `seda`) failed with an NPE. Each row message now gets a new `DataSetRow`: a read-only `DataSet` with only that row, from the row's own `Record` (`DataSet.getRecord()`). The body is still a `net.sf.flatpack.DataSet`, so `getBody(DataSet.class)`, bean parameters, `Map`, `Document` and `String` conversions keep working. A `List` conversion now gives that one row. The methods that change a `DataSet` (`setValue`, `remove`, `setUpperCase`, ...) throw `UnsupportedOperationException`, because the row is a snapshot. I did not make the body a `Map` or a `Record`, which were the other options in the issue. Both would break routes that read the body as a `DataSet`. ### 3. getBody(Map) fails with an NPE with splitRows=false or an empty input `FlatpackConverter.toMap` now fails with an `IllegalStateException` ("The DataSet is not on a row ... convert it to a List") when the DataSet is not on a row. A `List` conversion works as before (empty for an empty input). ### 4. A java.io.File or Path body fails Only `File`/`Path` -> `BufferedReader` converters exist, not `-> Reader`. A `File` or `Path` body is now read as a `BufferedReader`. Other bodies are read as before. ### Docs and generated files - `flatpack-component.adoc`: the message body section describes the new row body, `splitRows=false`, File/Path bodies and the exception. - `@BodyTypes` descriptions updated; regenerated `flatpack.json`; copied it and the adoc into `camel-catalog`. - Upgrade guide 4.24: new `camel-flatpack` section (own row per message, read-only, List of one row, the failing row now fails the producer and stops it, IllegalStateException instead of NPE). ### Tests `mvn -o clean install -Psourcecheck` in `components/camel-flatpack`: 53 tests, 0 failures (8 new in `FlatpackSplitRowsTest`). ### For the reviewer - Stop at the failing row vs. the splitter's continue-then-fail: easy to switch if continue is preferred. _Claude Code on behalf of Claus Ibsen (davsclaus)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
