Skip to content

[FLINK-39426] Add flink-connector-migration bridge module for Sink V2…#28084

Open
negiparas-bridge4 wants to merge 2 commits intoapache:masterfrom
negiparas-bridge4:ParasNegi-FLINK-39426
Open

[FLINK-39426] Add flink-connector-migration bridge module for Sink V2…#28084
negiparas-bridge4 wants to merge 2 commits intoapache:masterfrom
negiparas-bridge4:ParasNegi-FLINK-39426

Conversation

@negiparas-bridge4
Copy link
Copy Markdown

@negiparas-bridge4 negiparas-bridge4 commented May 1, 2026

What is the purpose of the change

In Flink 2.0, the deprecated convenience interfaces StatefulSink and TwoPhaseCommittingSink were removed as part of FLINK-36245. Many existing connectors (e.g., JDBC connector 3.3.0-1.20, Kafka connector 3.x) were compiled against Flink 1.x and still reference these types in their bytecode. When users add such connectors to a Flink 2.x project, they get:

cannot access org.apache.flink.api.connector.sink2.StatefulSink
class file for org.apache.flink.api.connector.sink2.StatefulSink not found

These interfaces were originally deprecated in Flink 1.19 via FLIP-372 and replaced with the mixin pattern (Sink + SupportsWriterState, Sink + SupportsCommitter). However, the removal in 2.0 happened after only ~6 months of deprecation, while the migration umbrella (FLINK-28045) still has open subtasks and major connectors had not yet migrated.

This PR restores both interfaces directly in flink-core as @Deprecated bridges — matching FLIP-372's original backward-compatible design. This requires zero action from users: connectors compiled against Flink 1.x resolve the class names automatically, and the runtime's instanceof SupportsWriterState / instanceof SupportsCommitter checks pass transparently.

Brief change log

  • Restored StatefulSink in flink-core as a deprecated bridge extending Sink + SupportsWriterState, including inner type aliases (StatefulSinkWriter, WithCompatibleState)
  • Restored TwoPhaseCommittingSink in flink-core as a deprecated bridge extending Sink + SupportsCommitter, including inner type alias (PrecommittingSinkWriter) and the createCommitter() no-arg delegation chain for old connectors
  • Added tests verifying the type hierarchy contracts (instanceof checks) that the Flink runtime relies on, including a test for the no-arg createCommitter() delegation path

Verifying this change

This change is already covered by new tests:

  • StatefulSinkBridgeTest — verifies StatefulSink is recognized as Sink and SupportsWriterState, and that inner type aliases extend the correct core interfaces
  • TwoPhaseCommittingSinkBridgeTest — verifies TwoPhaseCommittingSink is recognized as Sink and SupportsCommitter, that PrecommittingSinkWriter extends CommittingSinkWriter, and that the no-arg createCommitter() delegation works for legacy connectors

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): yes — restores @PublicEvolving @Deprecated bridge interfaces in flink-core
  • The serializers: no
  • The runtime per-record code paths (performance sensitive): no
  • Anything that affects deployment or recovery: no
  • The S3 file system connector: no

Documentation

  • Does this pull request introduce a new feature? No — it restores previously removed deprecated interfaces as backward compatibility bridges.
  • These bridges should carry a clear removal target (e.g., Flink 2.2) documented in the Flink 2.x migration guide.

Was generative AI tooling used to co-author this PR?

  • Yes — Claude Code (Claude Opus 4.6) was used to assist with implementation and review.

@flinkbot
Copy link
Copy Markdown
Collaborator

flinkbot commented May 1, 2026

CI report:

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

@negiparas-bridge4 negiparas-bridge4 marked this pull request as ready for review May 2, 2026 03:21
…ttingSink as backward compatibility bridges

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@negiparas-bridge4 negiparas-bridge4 force-pushed the ParasNegi-FLINK-39426 branch from fde62e7 to b1b89f3 Compare May 2, 2026 04:10
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@rmetzger
Copy link
Copy Markdown
Contributor

rmetzger commented May 6, 2026

Thanks for this PR. Why can't we migrate the connectors to use the new interfaces?
The point of Flink 2.x was to get rid of as much deprecated stuff as possible, we don't want to reintroduce deprecated code.

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.

3 participants