[ 
https://issues.apache.org/jira/browse/FLINK-41802?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18154489#comment-18154489
 ] 

YifanWu commented on FLINK-41802:
---------------------------------

Hi [~dianfu], I’d like to work on this issue. I reproduced the failure with the 
released Flink 2.2.1 and 2.3.0 JARs and attached a patch against master. The 
regression test exercises the split class-loader setup and verifies that the 
reader returns ordinary and null fields. All six targeted tests passed.

If the approach looks good, could you assign FLINK-41802 to me (kirakira)? I’ll 
open a PR after assignment. Thanks!

> PyFlink CsvReaderFormat.for_schema fails with IllegalAccessError across class 
> loaders
> -------------------------------------------------------------------------------------
>
>                 Key: FLINK-41802
>                 URL: https://issues.apache.org/jira/browse/FLINK-41802
>             Project: Flink
>          Issue Type: Bug
>          Components: API / Python
>    Affects Versions: 2.3.0, 2.2.1
>            Reporter: YifanWu
>            Priority: Major
>         Attachments: FLINK-41802-pyflink-csv-classloader.patch
>
>
> PyFlink DataStream's CsvReaderFormat.for_schema() fails during reader 
> construction when PythonCsvUtils and CsvReaderFormat are defined by different 
> class loaders. The former calls the latter's package-private constructor, so 
> the JVM raises IllegalAccessError before any CSV file is read.
> Reproduction
> Run PyFlink with flink-csv on the application classpath and flink-python 
> loaded separately by Flink's child-first class loader. The community report 
> below shows this layout with Flink 1.18.1 and the Kubernetes Operator. A 
> minimal call is:
> from pyflink.datastream import StreamExecutionEnvironment
> from pyflink.datastream.formats.csv import CsvReaderFormat, CsvSchema
> from pyflink.table import DataTypes
> StreamExecutionEnvironment.get_execution_environment()
> schema = CsvSchema.builder().add_number_column('id', 
> number_type=DataTypes.INT()).build()
> CsvReaderFormat.for_schema(schema)
> Actual result: java.lang.IllegalAccessError in 
> PythonCsvUtils.createCsvReaderFormat when it calls CsvReaderFormat.<init>. 
> Expected result: the reader is created and reads records with the configured 
> schema. Verified on released Apache Flink 2.3.0 (latest stable) and 2.2.1 
> with the matching JARs from Maven Central and JDK 21.0.10. In both versions, 
> Flink’s ChildFirstClassLoader defined PythonCsvUtils, the application class 
> loader defined CsvReaderFormat, and reader creation failed at 
> PythonCsvUtils.java:48 with IllegalAccessError. The same failure also 
> reproduces on Apache Flink master ea273d29db9.
> Proposed approach
> Route construction through the internal CsvFileFormatFactory in flink-csv. 
> Keep the constructor package-private, preserve row conversion and the 
> existing serialization entry points, and verify reader creation, 
> serialization, ordinary and NULL fields, and EOF with the two distinct class 
> loaders.
> Prior report: https://lists.apache.org/thread/xmrfywn2jq2ordwdm4ko5x9jyn6vxjxm
> Call site: 
> https://github.com/apache/flink/blob/ea273d29db96262cea0955dce7fcb83d7faac046/flink-python/src/main/java/org/apache/flink/formats/csv/PythonCsvUtils.java#L37-L49



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to