[FLINK-39226][python] Fix embedded PyIterator class cast after recovery#27849
Open
bowenli86 wants to merge 1 commit intoapache:masterfrom
Open
[FLINK-39226][python] Fix embedded PyIterator class cast after recovery#27849bowenli86 wants to merge 1 commit intoapache:masterfrom
bowenli86 wants to merge 1 commit intoapache:masterfrom
Conversation
Collaborator
f666478 to
393a6a8
Compare
393a6a8 to
f96b414
Compare
featzhang
approved these changes
Mar 30, 2026
| package org.apache.flink.streaming.api.operators.python.embedded; | ||
|
|
||
| /** Test-only iterator that can be loaded through an isolated classloader. */ | ||
| public class ForeignClassLoaderIterator { |
Member
There was a problem hiding this comment.
Added iterator implementation for testing, enabling cross-classloader behavior validation.
Member
Author
|
@featzhang thanks for reviewing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the purpose of the change
This pull request fixes FLINK-39226 by avoiding direct casts to
pemja.core.object.PyIteratorin embedded Python operators. After recovery, the returned iterator object can be loaded by a different user-code classloader, so hard casts can fail withClassCastException. The change introduces a reflective wrapper that can consume iterator-like results without depending on the local PemJa class identity.Brief change log
EmbeddedPythonIteratoras a reflective adapter for embedded Python result iteratorsPyIteratorcasts in embedded one-input, two-input, keyed timer, window, and table operatorsVerifying this change
Please make sure both new and modified tests in this PR follow the conventions for tests defined in our code quality guide.
This change added tests and can be verified as follows:
EmbeddedPythonIteratorTestto cover foreign-classloader iterators and direct-cast failure reproduction./mvnw -pl flink-python -am -Dfast -DskipITs -Dtest=EmbeddedPythonIteratorTest -Dsurefire.failIfNoSpecifiedTests=false testDoes this pull request potentially affect one of the following parts:
@Public(Evolving): noDocumentation