Skip to content

MNG-7401 - Make MavenSession#getCurrentProject() using a thread local#666

Closed
laeubi wants to merge 2 commits intoapache:masterfrom
laeubi:MNG-7401
Closed

MNG-7401 - Make MavenSession#getCurrentProject() using a thread local#666
laeubi wants to merge 2 commits intoapache:masterfrom
laeubi:MNG-7401

Conversation

@laeubi
Copy link
Copy Markdown
Contributor

@laeubi laeubi commented Jan 29, 2022

This allows multiple threads to set/get the current project on the same session object while still having clones maintain there own state.

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 [MNG-XXX] SUMMARY, where you replace MNG-XXX
    and SUMMARY 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 Core IT successfully.

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.

@michael-o
Copy link
Copy Markdown
Member

We previously has serious regressions with thread locals, I don't know whether this is a good idea. @gnodet

@michael-o michael-o requested a review from gnodet January 29, 2022 11:13
@michael-o
Copy link
Copy Markdown
Member

@famod

@laeubi
Copy link
Copy Markdown
Contributor Author

laeubi commented Jan 29, 2022

We previously has serious regressions with thread locals, I don't know whether this is a good idea. @gnodet

I have found some places where the active data was not reset and that might be the cause for such issues. I think I'll update the PR to create a new thread local, than this would be backward compatible and one could change the code accordingly afterwards.

@rmannibucau
Copy link
Copy Markdown
Contributor

+1 to fix instance lifecycle and not use any threadlocal which got proven brekaing plugins too much

@laeubi
Copy link
Copy Markdown
Contributor Author

laeubi commented Jan 29, 2022

+1 to fix instance lifecycle and not use any threadlocal which got proven brekaing plugins too much

What do you mean here in particular? I think it is quite clear to me now what would be the issue with my inital approach thanks to @michael-o and I'm about to fix that. Passing the Session all along seems to break the idea of DI...

This allows multiple threads to set/get the current project on the same
session object while still having clones maintain there own state.
@laeubi
Copy link
Copy Markdown
Contributor Author

laeubi commented Jan 29, 2022

I have adjusted the PR let me know what you think.

@laeubi
Copy link
Copy Markdown
Contributor Author

laeubi commented Jan 29, 2022

The only issue that can arise now is that I set the current project and pass the session to another thread without cloning it, but that should be illegal/broken already before isn't it?

@laeubi
Copy link
Copy Markdown
Contributor Author

laeubi commented Jan 29, 2022

One workaround seems to use the LegacySupport class to access the session instead of injecting it...

@jira-importer
Copy link
Copy Markdown

Resolve #9168

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

Successfully merging this pull request may close these issues.

4 participants