Skip to content

ModelMapper.processJarPackage nested JAR files read error #3981

Closed as not planned

Description

@lmxsoft

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

Activity

  1. brendandburns commented on Mar 19, 2025

    @brendandburns
    Contributor

    What is the exception that you are seeing?

  2. lmxsoft commented on Mar 19, 2025

    @lmxsoft
    Author
  3. fulizhe commented on May 20, 2025

    @fulizhe

    “jar:nested:/D:/xxxxxx/backend/target/api.jar/!BOOT-INF/lib/client-java-api-19.0.1.jar!/io/kubernetes/client/openapi/models” will be same problem。

  4. lmxsoft commented on May 20, 2025

    @lmxsoft
    Author
  5. k8s-triage-robot commented on Aug 18, 2025

    @k8s-triage-robot

    The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

    This bot triages un-triaged issues according to the following rules:

    • After 90d of inactivity, lifecycle/stale is applied
    • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
    • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

    You can:

    • Mark this issue as fresh with /remove-lifecycle stale
    • Close this issue with /close
    • Offer to help out with Issue Triage

    Please send feedback to sig-contributor-experience at kubernetes/community.

    /lifecycle stale

  6. added
    lifecycle/stale
    on Aug 18, 2025
  7. lmxsoft commented on Aug 18, 2025

    @lmxsoft
    Author
  8. k8s-triage-robot commented on Sep 17, 2025

    @k8s-triage-robot

    The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

    This bot triages un-triaged issues according to the following rules:

    • After 90d of inactivity, lifecycle/stale is applied
    • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
    • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

    You can:

    • Mark this issue as fresh with /remove-lifecycle rotten
    • Close this issue with /close
    • Offer to help out with Issue Triage

    Please send feedback to sig-contributor-experience at kubernetes/community.

    /lifecycle rotten

  9. added
    lifecycle/rotten
    and removed
    lifecycle/stale
    on Sep 17, 2025
  10. lmxsoft commented on Sep 17, 2025

    @lmxsoft
    Author
  11. k8s-triage-robot commented on Oct 17, 2025

    @k8s-triage-robot

    The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

    This bot triages issues according to the following rules:

    • After 90d of inactivity, lifecycle/stale is applied
    • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
    • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

    You can:

    • Reopen this issue with /reopen
    • Mark this issue as fresh with /remove-lifecycle rotten
    • Offer to help out with Issue Triage

    Please send feedback to sig-contributor-experience at kubernetes/community.

    /close not-planned

  12. k8s-ci-robot commented on Oct 17, 2025

    @k8s-ci-robot
    Contributor

    @k8s-triage-robot: Closing this issue, marking it as "Not Planned".

    Details

    In response to this:

    The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

    This bot triages issues according to the following rules:

    • After 90d of inactivity, lifecycle/stale is applied
    • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
    • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

    You can:

    • Reopen this issue with /reopen
    • Mark this issue as fresh with /remove-lifecycle rotten
    • Offer to help out with Issue Triage

    Please send feedback to sig-contributor-experience at kubernetes/community.

    /close not-planned

    Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

  13. lmxsoft commented on Oct 17, 2025

    @lmxsoft
    Author
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    lifecycle/rotten

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions