Skip to content

Prevent infinite loop in ManifestResourceTransformer.relocate#789

Merged
kwin merged 1 commit intomasterfrom
bugfix/prevent-infinite-loop-in-ManifestResourceTransformer
Mar 5, 2026
Merged

Prevent infinite loop in ManifestResourceTransformer.relocate#789
kwin merged 1 commit intomasterfrom
bugfix/prevent-infinite-loop-in-ManifestResourceTransformer

Conversation

@kwin
Copy link
Copy Markdown
Member

@kwin kwin commented Mar 4, 2026

Introduce Relocator.relocateAllClasses() to replace all patterns in a given string instead of only the first one and use that. Otherwise recursively using Relocator.relocateClass() on already relocated string over and over again leads to endless loop when pattern is a prefix of the shaded pattern.

This closes #478

Following this checklist to help us incorporate your
contribution quickly and easily:

  • Make sure there is a JIRA issue filed
    for the change (usually before you start working on it). Trivial changes like typos do not
    require a JIRA issue. Your pull request should address just this issue, without
    pulling in other changes.
  • Each commit in the pull request should have a meaningful subject line and body.
  • Format the pull request title like [MSHADE-XXX] - Fixes bug in ApproximateQuantiles,
    where you replace MSHADE-XXX with the appropriate JIRA issue. Best practice
    is to use the JIRA issue title in the pull request title and in the first line of the
    commit message.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Run mvn clean verify to make sure basic checks pass. A more thorough check will
    be performed on your pull request automatically.
  • You have run the integration tests successfully (mvn -Prun-its clean verify).

If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.

To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

@kwin kwin requested a review from cstamas March 4, 2026 19:15
@kwin kwin force-pushed the bugfix/prevent-infinite-loop-in-ManifestResourceTransformer branch from c10aa07 to f1f3d5e Compare March 4, 2026 19:17
Introduce Relocator.relocateAllClasses() to replace all patterns in a
given string instead of only the first one and use that.
Otherwise recursively using Relocator.relocateClass() on already
relocated string over and over again leads to endless loop when pattern
is a prefix of the shaded pattern.

This closes #478
@kwin kwin force-pushed the bugfix/prevent-infinite-loop-in-ManifestResourceTransformer branch from f1f3d5e to 40959b3 Compare March 4, 2026 19:42
@kwin kwin added the bug Something isn't working label Mar 5, 2026
@kwin kwin merged commit fd5dde5 into master Mar 5, 2026
30 checks passed
@kwin kwin deleted the bugfix/prevent-infinite-loop-in-ManifestResourceTransformer branch March 5, 2026 09:32
@github-actions github-actions Bot added this to the 3.6.3 milestone Mar 5, 2026
@cstamas
Copy link
Copy Markdown
Member

cstamas commented Mar 5, 2026

Are you sure killing off the loop is okay? Maybe just detect cycle/loops instead?

@kwin
Copy link
Copy Markdown
Member Author

kwin commented Mar 5, 2026

It is not only about killing the loop. The main fix is using String.replaceAll instead of using String.replaceFirst!

@cstamas
Copy link
Copy Markdown
Member

cstamas commented Mar 5, 2026

Ok, missed that, thanks

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[MSHADE-453] Relocation hangs indefinitely in all releases > 3.2.2 with ManifestResourceTransformer

2 participants