flink icon indicating copy to clipboard operation
flink copied to clipboard

[FLINK-38735][connector-file] add restore state check

Open liunaijie opened this issue 3 weeks ago • 4 comments

What is the purpose of the change

bug fix for https://issues.apache.org/jira/browse/FLINK-38735

Brief change log

  • Avoid got NoSuchElementException when restore with empty state

Verifying this change

Add new unit test. I am also write a unit test without fix, https://github.com/liunaijie/flink/blob/943ea91ac6e7a80f123fdefa514df72a01a11d22/flink-connectors/flink-connector-files/src/test/java/org/apache/flink/connector/file/table/stream/PartitionCommitterTest.java#L79

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

liunaijie avatar Nov 26 '25 07:11 liunaijie

CI report:

  • 7d889bd676215545252a084e22e2aa5a0fa325e2 Azure: FAILURE
Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

flinkbot avatar Nov 26 '25 07:11 flinkbot

Thanks for your review and quick response. @davidradl

  1. Please correct the title to include the jira number

Done

  1. I see you indicate htis is covered by existing tests, but the existing tests did not fail, can we add a test to restore with empty state to drive the failing case.

Sure I will try to add a test case to cover this edge case.

liunaijie avatar Nov 26 '25 11:11 liunaijie

I write a test with mockito, the result was as we expected.

Before fix, when restore with empty state, it will throw NoSuchElementException.

image

After fix, the class init will success, and can get empty result. image

As flink does not recommend using mockito to write unit tests, so I need some time to learn how to write this test.

liunaijie avatar Dec 05 '25 09:12 liunaijie

Hi @davidradl , I have added the test case, PTAL when you have time, thanks~

liunaijie avatar Dec 09 '25 10:12 liunaijie