Flink CDC Issue Import created FLINK-34831:
----------------------------------------------

             Summary: [FLINK-CDC-BASE] Reorder dependency  flink-table-runtime 
in pom.xml to avoid dependency conflict.
                 Key: FLINK-34831
                 URL: https://issues.apache.org/jira/browse/FLINK-34831
             Project: Flink
          Issue Type: Improvement
          Components: Flink CDC
            Reporter: Flink CDC Issue Import


### Search before asking

- [X] I searched in the 
[issues|https://github.com/ververica/flink-cdc-connectors/issues] and found 
nothing similar.


### Motivation

flink-cdc-base declares flink-table-runtime as its direct dependency. There are 
two transitive dependencies org.codehaus.janino:commons-compiler and 
org.codehaus.janino:janino in the dependency tree as listed below. They are 
introduced by flink-table-planner_2.12.
``` 
[INFO] com.ververica:flink-cdc-base:jar:3.0-SNAPSHOT
[INFO] +- org.apache.flink:flink-table-planner_2.12:jar:1.18.0:test
[INFO] |  +- org.codehaus.janino:commons-compiler:jar:3.1.10:test
[INFO] |  +- org.codehaus.janino:janino:jar:3.1.10:test
[INFO] +- org.apache.flink:flink-table-runtime:jar:1.18.0:test
```

Some duplicate classes in flink-table-planner are also in commons-compiler and 
janino as listed below. 
```
    org.codehaus.commons.compiler.lang.ClassLoaders$SubresourceGetter
    org.codehaus.commons.compiler.Location
    org.codehaus.commons.compiler.util.LineAndColumnTracker$1
    org.codehaus.commons.compiler.AbstractCompilerFactory
    ...

    org.codehaus.janino.util.ClassFile$CodeAttribute
    org.codehaus.janino.Java$ArrayAccessExpression
    org.codehaus.janino.util.ClassFile$AnnotationDefaultAttribute
    org.codehaus.janino.Java$TryStatement$LocalVariab
    ...
```

The problem is that the two transitive dependencies are ahead of 
flink-table-runtime in the dependency tree, thus ahead of flink-table-runtime 
in the classpath. When multiple JAR files contain the same class, the class 
loader will load the first occurrence it finds based on the classpath order. 
This means the classloader will **select classes in the transitive dependencies 
rather than direcly declared flink-table-runtime**.


### Solution

Change the order of flink-table-runtime and flink-table-planner_2.12 so that 
flink-table-runtime appears ahead of flink-table-planner_2.12 in classpath. In 
this way, flink-table-runtime is used as it's meant to be. 

### Alternatives

_No response_

### Anything else?

_No response_

### Are you willing to submit a PR?

- [X] I'm willing to submit a PR!

---------------- Imported from GitHub ----------------
Url: https://github.com/apache/flink-cdc/issues/2753
Created by: [HappyHacker123|https://github.com/HappyHacker123]
Labels: enhancement, 
Created at: Sun Nov 26 17:00:07 CST 2023
State: open




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to