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

Loop in CollectingManifestResourceTransformer causes infinite loop with certain relocations #4

Closed
jkebinger opened this issue Jul 31, 2023 · 2 comments

Comments

@jkebinger
Copy link

I originally documented this problem against the Shade plugin itself Issue

For relocations like

<relocation>
  <pattern>com.google.common</pattern>
  <shadedPattern>prefab.shaded.com.google.common</shadedPattern>
</relocation>

where the shaded pattern contains the original pattern, this loop keeps calling the same relocator class until the value stops changing - but it never does because it can keep replacing the first instance of the original pattern in the shaded pattern.

So the string passed to SimpleRelocator just grows and grows and grows!

There's no docs indicating patterns like this are prohibited, in fact the docs have such a pattern as an example.

Why does that code need to apply the same relocator multiple times?

@hgschmie
Copy link
Contributor

(wow, sorry. I did not pay attention to this repo in a long time)

The problem is that the pattern is wrong. It is not anchored (the first value <pattern> is not a string, but a regexp pattern) and the . wildcards are not escaped. This should be

<relocation>
  <pattern>^com\.google\.common</pattern>
  <shadedPattern>prefab.shaded.com.google.common</shadedPattern>
</relocation>

which will then only relocate the pattern once.

I will add some code to limit the loop (and then fail the build).

@jkebinger
Copy link
Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants