hutiefang76 opened a new pull request, #12906: URL: https://github.com/apache/seatunnel/pull/12906
### Purpose of this pull request Yes, contributing this fix to Apache SeaTunnel. Fixes #12903. The public `AvroToRowConverter` reads a BYTES field with `ByteBuffer.array()`. That exposes bytes outside a bounded/sliced buffer's logical region and fails for direct or read-only buffers. A real Avro reader reusing a record for a shorter BYTES value also retains the previous buffer capacity, so the converter returns stale trailing bytes. Read only the remaining region without changing the supplied buffer's position or limit. Preserve the existing full-array fast path to avoid adding per-row allocations to normal decoder reads. The result can still share the backing array for that fast path, as it did previously. ### Does this PR introduce _any_ user-facing change? Yes, for callers of the public converter and reader APIs: valid bounded, sliced, direct and read-only buffers now produce their logical byte values; reused reader records no longer expose the previous value's tail. The current Kafka/Pulsar `AvroDeserializationSchema` path uses `read(null, ...)`, which creates fresh records. It does not take the record-reuse path, and this PR does not claim that normal connector messages currently hit the bug. Configurations, schemas, Avro wire layout, public signatures and serialVersionUID are unchanged. The converter Javadoc explains the buffer-region contract. ### How was this patch tested? On the original source, the 10 executed converter cases had 3 assertion failures (bounded heap, sliced heap and actual Avro reader reuse), 2 errors (direct/read-only buffers) and 5 passes, with no skips. The reuse case serialized and read a 64-byte value, then read a 3-byte value into the prior record; it received 64 bytes before the fix. After the fix, all 17 Avro module tests passed on JDK 17, with no failures, errors or skips. Coverage includes unchanged source positions/limits, empty/null/full-heap controls, an actual serialization/deserialization round trip and the existing tests. No existing assertion or fixture was removed. ```sh ./mvnw -B -pl seatunnel-formats/seatunnel-format-avro -am package ./mvnw spotless:apply ./mvnw -q -DskipTests verify ``` Root formatting and verification passed. No real-broker run is claimed for this public-converter change. It is independent of the nullable ROW and tableId proposals. AI assistance was used for implementation and review. The failures, controls and passing module suite above were actually executed. ### Check list * [x] No new dependency or binary package is added. * [x] The public converter's buffer semantics are documented. * [x] Existing tests are extended and retained. * [x] No connector, configuration or wire-layout change is involved. -- 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]
