[
https://issues.apache.org/jira/browse/MNG-7401?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17539551#comment-17539551
]
ASF GitHub Bot commented on MNG-7401:
-------------------------------------
laeubi commented on PR #743:
URL: https://github.com/apache/maven/pull/743#issuecomment-1131684537
> revert the use of multiple sessions, i.e. use a single session throughout
the whole build, which is what this PR is about. The possible drawback is
breakages of code that would use `MavenSession.getCurrentProject()` from a
different thread
I think this is (at least for the Tycho scope of the problem) the most
noteable thing, and we use `LegacySupport` what effectivly *is* a Threadlocal,
so from what I can tell, in almost all cases `MavenSession.getCurrentProject()`
returning the current project "of the thread" would be sufficient and cloning
the session seem to be effectively for that purpose.
The problem with the cloning is, that if I have a sessionscoped componet I
get the "rootsession" and thus calling `MavenSession.getCurrentProject()` most
of the time returns `null` as the actual project is set on a cloned copy.
> Make MavenSession#getCurrentProject() using a thread local
> ----------------------------------------------------------
>
> Key: MNG-7401
> URL: https://issues.apache.org/jira/browse/MNG-7401
> Project: Maven
> Issue Type: Improvement
> Reporter: Christoph Läubrich
> Priority: Major
> Fix For: waiting-for-feedback
>
>
> I noticed that a session is often cloned due to change the current project
> for a while.
> As this works for everyone passing down the session, consumers of the "upper
> session" (e.g. a SessionScoped Component) would never see this if they are
> (indirectly) called and e.g. use Session#getCurrentProject().
> I wonder if MavenSession could simply use a ThreadLocal for the
> currentProject (that is shared accross all cloned sessions), that way one
> would always get the correct value.
--
This message was sent by Atlassian Jira
(v8.20.7#820007)