Skip to content

Commit 2c784e6

Browse files
committed
jar exist check
1 parent 8e4fa1b commit 2c784e6

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

core/src/main/java/com/dtstack/flink/sql/util/PluginUtil.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,15 @@ public static URL getRemoteJarFilePath(String pluginType, String tableType, Stri
111111
String dirName = pluginType + tableType.toLowerCase();
112112
String prefix = String.format("%s-%s", pluginType, tableType.toLowerCase());
113113
String jarPath = remoteSqlRootDir + SP + dirName;
114-
String jarName = getCoreJarFileName(jarPath, prefix);
114+
String jarName = getCoreJarFileName(jarPath, prefix, false);
115115
return new URL("file:" + remoteSqlRootDir + SP + dirName + SP + jarName);
116116
}
117117

118118
public static URL getRemoteSideJarFilePath(String pluginType, String sideOperator, String tableType, String remoteSqlRootDir) throws Exception {
119119
String dirName = pluginType + sideOperator + tableType.toLowerCase();
120120
String prefix = String.format("%s-%s-%s", pluginType, sideOperator, tableType.toLowerCase());
121121
String jarPath = remoteSqlRootDir + SP + dirName;
122-
String jarName = getCoreJarFileName(jarPath, prefix);
122+
String jarName = getCoreJarFileName(jarPath, prefix, false);
123123
return new URL("file:" + remoteSqlRootDir + SP + dirName + SP + jarName);
124124
}
125125

@@ -144,7 +144,11 @@ public static void addPluginJar(String pluginDir, DtClassLoader classLoader) thr
144144
}
145145
}
146146

147-
public static String getCoreJarFileName (String path, String prefix) throws Exception {
147+
public static String getCoreJarFileName (String path, String prefix, boolean existCheck) throws Exception {
148+
if (!existCheck) {
149+
return prefix.toLowerCase() + ".jar";
150+
}
151+
148152
String coreJarFileName = null;
149153
File pluginDir = new File(path);
150154
if (pluginDir.exists() && pluginDir.isDirectory()){
@@ -158,10 +162,11 @@ public boolean accept(File dir, String name) {
158162
if (jarFiles != null && jarFiles.length > 0){
159163
coreJarFileName = jarFiles[0].getName();
160164
}
161-
}else {
162-
coreJarFileName = prefix.toLowerCase() + ".jar";
163165
}
164166

167+
if (StringUtils.isEmpty(coreJarFileName)){
168+
throw new Exception("Can not find core jar file in path:" + path);
169+
}
165170

166171
return coreJarFileName;
167172
}

launcher/src/main/java/com/dtstack/flink/sql/launcher/LauncherMain.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public class LauncherMain {
5959

6060

6161
private static String getLocalCoreJarPath(String localSqlRootJar) throws Exception {
62-
String jarPath = PluginUtil.getCoreJarFileName(localSqlRootJar, CORE_JAR);
62+
String jarPath = PluginUtil.getCoreJarFileName(localSqlRootJar, CORE_JAR, true);
6363
String corePath = localSqlRootJar + SP + jarPath;
6464
return corePath;
6565
}

0 commit comments

Comments
 (0)