Unverified Commit 7fa870fb authored by luoshangjie's avatar luoshangjie Committed by GitHub

[Fix] Resolving issues where custom classes in user Jars fail to compile during…

[Fix] Resolving issues where custom classes in user Jars fail to compile during the submission of Jar tasks (#3477) Co-authored-by: 's avatarluoshangjie <luoshangjie@yfpharmacy.com>
parent ee5d367b
......@@ -34,6 +34,7 @@ import org.apache.flink.configuration.Configuration;
import org.apache.flink.runtime.jobgraph.SavepointConfigOptions;
import org.apache.flink.runtime.jobgraph.SavepointRestoreSettings;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.graph.StreamGraph;
import org.apache.flink.table.api.TableResult;
import java.io.File;
......@@ -111,6 +112,19 @@ public class ExecuteJarOperation extends AbstractOperation implements ExtendOper
? Convert.toInt(submitParam.getParallelism())
: tEnv.getStreamExecutionEnvironment().getParallelism();
Pipeline pipeline = PackagedProgramUtils.getPipelineFromProgram(program, configuration, parallelism, true);
// When the UserCodeClassLoader is used to obtain the JobGraph in advance,
// the code generated by the StreamGraph is compiled.
// When the JobGraph is obtained again in the future,
// the already compiled code is used directly to prevent the DinkyClassLoader from failing to compile the
// code of the user Jar.
if (pipeline instanceof StreamGraph) {
ClassLoader dinkyClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(program.getUserCodeClassLoader());
((StreamGraph) pipeline).getJobGraph();
Thread.currentThread().setContextClassLoader(dinkyClassLoader);
}
program.close();
return pipeline;
} catch (Exception e) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment