Skip to content

[common] Fix line boundaries in DataInputDeserializer - #10911

Closed
skyyyy955 wants to merge 1 commit into
apache:masterfrom
skyyyy955:fix/data-input-read-line-contract-20261031
Closed

skyyyy955 wants to merge 1 commit into
apache:masterfrom
skyyyy955:fix/data-input-read-line-contract-20261031

Conversation

@skyyyy955

Copy link
Copy Markdown
Contributor

Purpose

DataInputDeserializer.readLine() drops the final byte of an unterminated line: reading "ab" returns "a". It also continues past a lone carriage return, consuming the following line or binary payload.

Read each byte before checking for the next one, recognize LF, CR and CRLF, and keep CRLF lookahead within the configured buffer slice. This updates the existing implementation to follow the JDK 8 DataInput contract. Other deserialization methods and serialized formats are unchanged.

Tests

mvn -o -B -ntp -pl paimon-common -am -DwildcardSuites=none -DfailIfNoTests=false -Dtest=DataInputDeserializerTest,DataOutputSerializerTest test

Windows 11, JDK 8u451, Maven 3.8.9, baseline 1902379: 22 tests, 9 failures before the fix; the same 22 tests pass after it. No fast-build profile was used.

The regression tests compare returned lines, remaining bytes and cursor positions with JDK DataInputStream, including bounded slices and unsigned bytes. Mixed line/binary tests read int, long and UTF values written by JDK DataOutputStream. The existing DataOutputSerializerTest also passes.

Spotless and Enforcer passed. Both changed files passed Checkstyle 8.14 with the project configuration in a separate directory outside the target-path suppression. Local verification did not include Linux, full-module or Flink/Spark suites, or the verify-phase RAT check.

The publication branch is based on 0369648. Its selected parent/API/test-utils/common build inputs and reviewed files match the tested baseline above, and the patch is unchanged. Local tests were not rerun for this base change.

Preserve the final byte of unterminated lines and recognize CR, LF and
CRLF without reading beyond the configured buffer slice.

Add JDK-backed regression tests for line contents, cursor positions and
subsequent binary reads.
@JingsongLi

Copy link
Copy Markdown
Contributor

The low-level DataInput.readLine defect is real, and the implementation handles the final byte, CR/LF/CRLF, unsigned bytes and bounded slices consistently. I ran DataInputDeserializerTest and DataOutputSerializerTest on JDK 8 with normal Maven verify: all 22 cases pass, as do Checkstyle, Spotless, Enforcer and RAT. The PR's CI is green.

However, I could not connect this change to an end-to-end Paimon workload. Repository-wide caller tracing found no production caller of DataInputDeserializer.readLine(). The text-format path uses TextLineReader/StandardLineReader, and FileIO.readFileUtf8, IOUtils.readUTF8Fully, version loading and benchmark line reads use other reader implementations. The new tests establish the standalone JDK contract, but do not demonstrate a table read/write, engine job or recovery path affected by this implementation.

Closing for now because the current contribution lacks demonstrated end-to-end impact. This is not an implementation-correctness objection. Please provide an actual affected Paimon caller/workload and a regression at that boundary if there is one, and we can revisit the change.

@JingsongLi JingsongLi closed this Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants