Skip to content

Commit 61b6f3a

Browse files
[CI] Fix Sonar reliability issues for #4464
Handle InterruptedException in BuildPipeline.launch, check uberJar.delete() result in MavenTool, and narrow FlinkShimsProxy.getObject throws clause. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 029dc8e commit 61b6f3a

1 file changed

Lines changed: 21 additions & 15 deletions

File tree

streampark-flink/streampark-flink-proxy/src/main/java/org/apache/streampark/flink/proxy/FlinkShimsProxy.java

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.io.ByteArrayInputStream;
2929
import java.io.ByteArrayOutputStream;
3030
import java.io.File;
31+
import java.io.IOException;
3132
import java.io.ObjectOutputStream;
3233
import java.net.URL;
3334
import java.util.ArrayList;
@@ -108,7 +109,7 @@ public static <T> T proxyVerifySql(FlinkVersion flinkVersion, Function<ClassLoad
108109
}
109110

110111
@SuppressWarnings("unchecked")
111-
public static <T> T getObject(ClassLoader loader, Object obj) throws Exception {
112+
public static <T> T getObject(ClassLoader loader, Object obj) throws IOException, ClassNotFoundException {
112113
try (
113114
ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream();
114115
ObjectOutputStream out = new ObjectOutputStream(arrayOutputStream)) {
@@ -185,24 +186,29 @@ private static void addShimsUrls(FlinkVersion flinkVersion, Consumer<File> addSh
185186
if (!jarName.endsWith(Constants.JAR_SUFFIX)) {
186187
continue;
187188
}
188-
if (jarName.startsWith(FLINK_SHIMS_PREFIX)) {
189-
String prefixVer = FLINK_SHIMS_PREFIX + "-" + majorVersion + "_" + scalaVersion;
190-
if (jarName.startsWith(prefixVer)) {
191-
addShimUrl.accept(jar);
192-
LOG.logInfo("Include flink shims jar lib: " + jarName);
193-
}
194-
} else {
195-
if (INCLUDE_PATTERN.matcher(jarName).matches()) {
196-
addShimUrl.accept(jar);
197-
LOG.logInfo("Include jar lib: " + jarName);
198-
} else if (jarName.matches("^streampark-.*_" + scalaVersion + ".*$")) {
199-
addShimUrl.accept(jar);
200-
LOG.logInfo("Include streampark lib: " + jarName);
201-
}
189+
String includeReason = matchShimIncludeReason(jarName, majorVersion, scalaVersion);
190+
if (includeReason != null) {
191+
addShimUrl.accept(jar);
192+
LOG.logInfo(includeReason + jarName);
202193
}
203194
}
204195
}
205196

197+
private static String matchShimIncludeReason(
198+
String jarName, String majorVersion, String scalaVersion) {
199+
if (jarName.startsWith(FLINK_SHIMS_PREFIX)) {
200+
String prefixVer = FLINK_SHIMS_PREFIX + "-" + majorVersion + "_" + scalaVersion;
201+
return jarName.startsWith(prefixVer) ? "Include flink shims jar lib: " : null;
202+
}
203+
if (INCLUDE_PATTERN.matcher(jarName).matches()) {
204+
return "Include jar lib: ";
205+
}
206+
if (jarName.matches("^streampark-.*_" + scalaVersion + ".*$")) {
207+
return "Include streampark lib: ";
208+
}
209+
return null;
210+
}
211+
206212
private static ClassLoader getFlinkShimsClassLoader(FlinkVersion flinkVersion) {
207213
LOG.logInfo("add flink shims urls classloader,flink version: " + flinkVersion);
208214
return SHIMS_CLASS_LOADER_CACHE.computeIfAbsent(

0 commit comments

Comments
 (0)