Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2241 fix bug: when running with a fat jar, need to read entries with openConnection #2952

Merged
merged 5 commits into from
Jan 8, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions util/src/main/java/io/kubernetes/client/util/ModelMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import java.io.File;

import java.io.IOException;
import java.net.JarURLConnection;
import java.net.URI;
import java.net.URL;
import java.net.URLDecoder;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Enumeration;
Expand Down Expand Up @@ -484,10 +484,8 @@ private static List<String> getClassNamesFromPackage(ClassLoader classLoader, St
}

private static void processJarPackage(URL packageURL, String packageName, String pkg, ArrayList<String> names) throws IOException {
String jarFileName = URLDecoder.decode(packageURL.getFile(), "UTF-8");
jarFileName = jarFileName.substring(5, jarFileName.indexOf("!"));
logger.info("Loading classes from jar {}", jarFileName);
try (JarFile jf = new JarFile(jarFileName)) {
logger.info("Loading classes from jar {}", packageURL.getFile());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add an explicit check for packageURL.startsWith("jar:") here?

try (JarFile jf = ((JarURLConnection) packageURL.openConnection()).getJarFile()) {
Enumeration<JarEntry> jarEntries = jf.entries();
while (jarEntries.hasMoreElements()) {
processJarEntry(jarEntries.nextElement(), packageName, pkg, names);
Expand Down