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

[MSHADE-252] - Make source shading respect package/class name excludes #88

Merged
merged 2 commits into from May 22, 2021

Conversation

kriegaex
Copy link
Contributor

@kriegaex kriegaex commented Apr 4, 2021

1. Make source shading respect package/class name excludes

Fixes MSHADE-252.

Until now, there was a naive global search + replace for mapping <pattern> to <shadedPattern>, even if the corresponding packages are to be ignored. This works for binary JARs, but was completely broken for source JARs.

See also my related comment in MSHADE-252.

With this fix, on the one hand string replacement in source files works for both "dotty" strings like my.package.name.Foo and "slashy" ones like /my/package/name/resource.properties. On the other hand, source files are now being parsed <pattern> match by match and for each match the excludes list will be checked and replacements only performed if the corresponding matched package name is not on the excludes list. This is of course slower than just a raw replaceAll(..), but it produces correct results.


2. Make relocation ex-/include matching more lenient, accepting .** too

Actually, class patterns are supposed to should just use foo.bar.* ending with a single asterisk, but some users mistake them for path patterns like my/path/**, so let us be a bit more lenient here.

See also my related comment in MSHADE-252.


I have just sent my Contributor License Agreement to the Apache secretary's e-mail address. I hope is shall be processed quickly.


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.

@kriegaex
Copy link
Contributor Author

kriegaex commented Apr 5, 2021

Update on my CLA: I got confirmation from the secretary that it was filed:

This message acknowledges receipt of your ICLA, which has been filed in the Apache Software Foundation records.

With this message, the Maven PMC has been notified that your ICLA has been filed.

…ting '.**' too

Actually, class patterns are supposed to should just use 'foo.bar.*'
ending with a single asterisk, but some users mistake them for path
patterns like 'my/path/**', so let us be a bit more lenient here.

See also my related comment in MSHADE-252:
https://issues.apache.org/jira/browse/MSHADE-252?focusedCommentId=17314393&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-17314393
Fixes MSHADE-252.

Until now, there was a naive global search + replace for mapping
'<pattern>' to '<shadedPattern>', even if the corresponding packages
are to be ignored. This works for binary JARs, but was completely
broken for source JARs.

See also my related comment in MSHADE-252:
https://issues.apache.org/jira/browse/MSHADE-252?focusedCommentId=17314377&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-17314377

With this fix, on the one hand string replacement in source files works
for both "dotty" strings like "my.package.name.Foo" and "slashy" ones
like "/my/package/name/resource.properties". On the other hand, source
files are now being parsed '<pattern>' match by match and for each match
the excludes list will be checked and replacements only performed if the
corresponding matched package name is not on the excludes list. This is
of course slower than just a raw 'replaceAll(..)', but it produces
correct results.
@hboutemy hboutemy merged commit da69608 into apache:master May 22, 2021
@kriegaex kriegaex deleted the MSHADE-252 branch May 23, 2021 01:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants