You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When processing a JAR package, the code fails to correctly handle nested JAR files. Specifically, when the packageURL is a nested JAR URL, the jarFileName is incorrectly decoded, leading to a failure in creating the JarFile object.
Here is the problematic code:
private static void processJarPackage(URL packageURL, String packageName, String pkg, ArrayList<String> names) throws IOException {
String jarFileName = URLDecoder.decode(packageURL.getFile(), "UTF-8");
JarFile jf = null;
// jar: client in repository; nested: client in a fat jar
if (jarFileName.startsWith("jar:") || jarFileName.startsWith("nested:")) {
jf = ((JarURLConnection) packageURL.openConnection()).getJarFile();
}
// file: client is a file in target (unit test)
if (jarFileName.startsWith("file:") ) {
jarFileName = jarFileName.substring(5, jarFileName.indexOf("!"));
jf = new JarFile(jarFileName);
}
if (jf == null) {
logger.error("Loading classes from jar with error packageURL: {}", jarFileName);
return;
}
logger.info("Loading classes from jar {}", jarFileName);
Enumeration<JarEntry> jarEntries = jf.entries();
while (jarEntries.hasMoreElements()) {
processJarEntry(jarEntries.nextElement(), packageName, pkg, names);
}
jf.close();
}
For example, given the following URL:
Url packageURL = new Url("jar:file:/app/app.jar!/BOOT-INF/lib/java-client.jar!/io.kubenrnetes.client.openapi.models.V1Job");
String jarFileName = URLDecoder.decode(packageURL.getFile(), "UTF-8");
The jarFileName will be decoded as:
”file:/app/app.jar!/BOOT-INF/lib/java-client.jar!/io.kubenrnetes.openapi.models.V1Job”
This causes the JarFile to fail to initialize.
Proposed Fix:
Change:
String jarFileName = URLDecoder.decode(packageURL.getFile(), "UTF-8");
to:
String jarFileName = URLDecoder.decode(packageURL.toString(), "UTF-8");
Client Version
Client Version
e.g. 23.0.0
The text was updated successfully, but these errors were encountered:
Describe the bug
When processing a JAR package, the code fails to correctly handle nested JAR files. Specifically, when the packageURL is a nested JAR URL, the jarFileName is incorrectly decoded, leading to a failure in creating the JarFile object.
Here is the problematic code:
For example, given the following URL:
The jarFileName will be decoded as:
”file:/app/app.jar!/BOOT-INF/lib/java-client.jar!/io.kubenrnetes.openapi.models.V1Job”
This causes the JarFile to fail to initialize.
Proposed Fix:
Change:
String jarFileName = URLDecoder.decode(packageURL.getFile(), "UTF-8");
to:
String jarFileName = URLDecoder.decode(packageURL.toString(), "UTF-8");
Client Version
Client Version
e.g.
23.0.0
The text was updated successfully, but these errors were encountered: