Skip to content

Fix ModelMapper.processJarPackage breaking on paths containing '+'#4712

Draft
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-modelmapper-jar-package-issue
Draft

Fix ModelMapper.processJarPackage breaking on paths containing '+'#4712
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-modelmapper-jar-package-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 22, 2026

ModelMapper.processJarPackage used URLDecoder.decode to extract the JAR file path from a file: URL. URLDecoder follows application/x-www-form-urlencoded semantics where + → space, corrupting paths with literal + characters. This causes initModelMap() to fail silently, leaving the prebuilt model map empty. Manifests in Bazel 8 environments where canonical repo names use + (e.g., rules_jvm_external++maven+maven/...client-java-api-26.0.0.jar).

Changes

  • Replace URLDecoder.decode with URI.create(...).getPath() for the file: JAR path case. URI.getPath() correctly decodes %XX sequences but treats + as a literal character — correct URL semantics.
  • Remove raw packageURL.getFile() post-processing for jar:/nested: cases — these already went through JarURLConnection and were unaffected.
  • Add guard for missing ! separator in the file: URL before calling substring.
  • Remove now-unused imports URLDecoder and StandardCharsets.
// Before: + in path → converted to space → JarFile(...) fails
String jarFileName = URLDecoder.decode(packageURL.getFile(), StandardCharsets.UTF_8);
jarFileName = jarFileName.substring(5, jarFileName.indexOf("!"));
jf = new JarFile(jarFileName);

// After: + preserved, %20 still decoded correctly
int bangIndex = jarFileName.indexOf("!");
String filePart = jarFileName.substring(0, bangIndex);
jf = new JarFile(URI.create(filePart).getPath());

@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 22, 2026
Copilot AI linked an issue Apr 22, 2026 that may be closed by this pull request
@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Apr 22, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Copilot
Once this PR has been reviewed and has the lgtm label, please ask for approval from brendandburns. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Apr 22, 2026
Copilot AI changed the title [WIP] Fix ModelMapper.processJarPackage to handle '+' in paths Fix ModelMapper.processJarPackage breaking on paths containing '+' Apr 22, 2026
Copilot AI requested a review from brendandburns April 22, 2026 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ModelMapper.processJarPackage breaks on paths containing '+'

3 participants