jubins opened a new pull request, #29945:
URL: https://github.com/apache/flink/pull/29945

   ## What is the purpose of the change
   
   Adds unit tests for `LinkedOptionalMapSerializer` 
([FLINK-41502](https://issues.apache.org/jira/browse/FLINK-41502)).
   
   `LinkedOptionalMapSerializer` writes the snapshot format that 
`PojoSerializerSnapshotData` and `KryoSerializerSnapshotData` use, so it 
affects savepoint compatibility. No test referenced it: `LinkedOptionalMapTest` 
only covers the map, and the snapshot tests only cover it indirectly. This PR 
adds direct tests for the format. It does not change any production code.
   
   ## Brief change log
   
     - 
`flink-core/src/test/java/org/apache/flink/util/LinkedOptionalMapSerializerTest.java`:
 new test class with 5 tests for `writeOptionalMap` / `readOptionalMap`.
   
   ## Verifying this change
   
   This change added tests and can be verified as follows:
   
     - `roundTripPreservesOrderAndAbsentEntries`: a map with a present entry, 
an absent key, an absent value, and both absent is written and read back. The 
test checks that insertion order is kept and that `absentKeysOrValues()` 
returns the right key names.
     - `roundTripOfEmptyMap`: an empty map is read back as an empty map.
     - `readerThatConsumesOnlyPartOfAFrameDoesNotCorruptLaterEntries`: the key 
writer adds trailing bytes that the key reader never reads. The test checks 
that later values and entries still deserialize, because each key and value is 
length-framed.
     - `readersReceiveKeyNameAndMayReturnNullToMarkEntryAbsent`: the key and 
value readers get each entry's key name in order. A reader that returns `null` 
(for example, a class that can no longer be loaded) marks the entry absent.
     - `corruptedHeaderIsRejected`: a stream with a wrong header fails with 
`IllegalStateException("Corrupted stream received header 42")`.
   
   To check that the tests catch regressions, I temporarily changed 
`LinkedOptionalMapSerializer` in two ways, ran the tests, and then restored the 
file:
     - Removing the header `checkState` made `corruptedHeaderIsRejected` fail 
("Expecting code to raise a throwable").
     - Passing the outer stream to the reader instead of the frame made 
`readerThatConsumesOnlyPartOfAFrameDoesNotCorruptLaterEntries` fail (it read 
`["first=key-1/-255", "=null/422757"]`).
   
   `LinkedOptionalMapSerializerTest` (5 tests) and `LinkedOptionalMapTest` (13 
tests) pass locally on JDK 21.
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): no
     - The public API, i.e., is any changed class annotated with 
`@Public(Evolving)`: no
     - The serializers: no (test-only; the serializer code is unchanged)
     - The runtime per-record code paths (performance sensitive): no
     - Anything that affects deployment or recovery: JobManager (and its 
components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
     - The S3 file system connector: no
   
   ## Documentation
   
     - Does this pull request introduce a new feature? no
     - If yes, how is the feature documented? not applicable
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   <!--
   If generative AI tooling has been used in the process of authoring this PR, 
please
   change the checkbox below to `[X]` and replace the placeholder in the 
"Generated-by"
   line with the tool name and version. Otherwise remove the "Generated-by" 
line.
   See the ASF Generative Tooling Guidance for details:
   https://www.apache.org/legal/generative-tooling.html
   
   You are responsible for the quality and correctness of every change in this 
PR
   regardless of the tooling used. Low-effort AI-generated PRs will be closed. 
See
   AGENTS.md for the full guidance.
   -->
   
   - [X] Yes (please specify the tool below): Claude Code
   
   Generated-by: Claude Code (Claude Opus 5.5)
   


-- 
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]

Reply via email to