[ 
https://issues.apache.org/jira/browse/MNG-7455?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17521068#comment-17521068
 ] 

Guillaume Nodet commented on MNG-7455:
--------------------------------------

So the problem certainly happens if a thread is mutating the scope while 
another is injecting a session.  Between the following lines
https://github.com/apache/maven/blob/b4518b5fe416a552a59e5201b4569a9bc0af3153/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleModuleBuilder.java#L96-L97
the session will be null, and thus, a null session can be injected into a Mojo.

This specific concurrency issue can easily be mitigated by changing the 
{{SessionScope}} and providing the session as an argument, so that there will 
be no gap with a null session, however, this also means that the session that 
is injected into a mojo may be a random session, and not the one that is 
actually used to execute the project, which is wrong too.

Given the session are cloned and injected into components, I think MNG-7347 may 
need to be reverted, as there's no way to ensure the correct sessions are 
injected into components.  I need to investigate if this will have an impact on 
the build-cache extension and mvnd...  

> IllegalStateException in SessionScope during guice injection in multithreaded 
> build
> -----------------------------------------------------------------------------------
>
>                 Key: MNG-7455
>                 URL: https://issues.apache.org/jira/browse/MNG-7455
>             Project: Maven
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 3.8.5
>            Reporter: Emond Papegaaij
>            Priority: Major
>         Attachments: pom.xml.effective
>
>
> Since Maven 3.8.5 we are seeing intermittent failures with the stacktrace 
> below. With 3.8.4 we did not have this issue. Looking at the changelog I 
> suspect this regression is caused by MNG-7347.
> {code:java}
> 09:36:53 [mvn-builder-keyhub-manual] [INFO] --- 
> asciidoctor-maven-plugin:2.2.2:process-asciidoc (output-html-nl) @ 
> keyhub-manual ---
> 09:36:53 [mvn-builder-keyhub-manual] [WARNING] Error injecting: 
> org.asciidoctor.maven.AsciidoctorMojo
> com.google.inject.ProvisionException: Unable to provision, see the following 
> errors:
> 1) Error in custom provider, java.lang.IllegalStateException
>   at 
> org.apache.maven.session.scope.internal.SessionScopeModule.configure(SessionScopeModule.java:64)
>  (via modules: org.eclipse.sisu.wire.WireModule -> 
> org.apache.maven.session.scope.internal.SessionScopeModule)
>   while locating org.apache.maven.execution.MavenSession
>     for field at org.asciidoctor.maven.AsciidoctorMojo.session(Unknown Source)
>   while locating org.asciidoctor.maven.AsciidoctorMojo
> 1 error
>     at 
> com.google.inject.internal.InternalProvisionException.toProvisionException 
> (InternalProvisionException.java:226)
>     at com.google.inject.internal.InjectorImpl$1.get (InjectorImpl.java:1053)
>     at com.google.inject.internal.InjectorImpl.getInstance 
> (InjectorImpl.java:1086)
>     at org.eclipse.sisu.space.AbstractDeferredClass.get 
> (AbstractDeferredClass.java:48)
>     at com.google.inject.internal.ProviderInternalFactory.provision 
> (ProviderInternalFactory.java:85)
>     at 
> com.google.inject.internal.InternalFactoryToInitializableAdapter.provision 
> (InternalFactoryToInitializableAdapter.java:57)
>     at com.google.inject.internal.ProviderInternalFactory$1.call 
> (ProviderInternalFactory.java:66)
>     at 
> com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision 
> (ProvisionListenerStackCallback.java:112)
>     at 
> com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision 
> (ProvisionListenerStackCallback.java:127)
>     at com.google.inject.internal.ProvisionListenerStackCallback.provision 
> (ProvisionListenerStackCallback.java:66)
>     at com.google.inject.internal.ProviderInternalFactory.circularGet 
> (ProviderInternalFactory.java:61)
>     at com.google.inject.internal.InternalFactoryToInitializableAdapter.get 
> (InternalFactoryToInitializableAdapter.java:47)
>     at com.google.inject.internal.InjectorImpl$1.get (InjectorImpl.java:1050)
>     at org.eclipse.sisu.inject.Guice4$1.get (Guice4.java:162)
>     at org.eclipse.sisu.inject.LazyBeanEntry.getValue (LazyBeanEntry.java:81)
>     at org.eclipse.sisu.plexus.LazyPlexusBean.getValue 
> (LazyPlexusBean.java:51)
>     at org.codehaus.plexus.DefaultPlexusContainer.lookup 
> (DefaultPlexusContainer.java:263)
>     at org.codehaus.plexus.DefaultPlexusContainer.lookup 
> (DefaultPlexusContainer.java:255)
>     at 
> org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo 
> (DefaultMavenPluginManager.java:520)
>     at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo 
> (DefaultBuildPluginManager.java:124)
>     at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute 
> (MojoExecutor.java:301)
>     at org.apache.maven.lifecycle.internal.MojoExecutor.execute 
> (MojoExecutor.java:211)
>     at org.apache.maven.lifecycle.internal.MojoExecutor.execute 
> (MojoExecutor.java:165)
>     at org.apache.maven.lifecycle.internal.MojoExecutor.execute 
> (MojoExecutor.java:157)
>     at 
> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject 
> (LifecycleModuleBuilder.java:121)
>     at 
> org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call
>  (MultiThreadedBuilder.java:210)
>     at 
> org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call
>  (MultiThreadedBuilder.java:195)
>     at java.util.concurrent.FutureTask.run (FutureTask.java:264)
>     at java.util.concurrent.Executors$RunnableAdapter.call 
> (Executors.java:539)
>     at java.util.concurrent.FutureTask.run (FutureTask.java:264)
>     at java.util.concurrent.ThreadPoolExecutor.runWorker 
> (ThreadPoolExecutor.java:1136)
>     at java.util.concurrent.ThreadPoolExecutor$Worker.run 
> (ThreadPoolExecutor.java:635)
>     at java.lang.Thread.run (Thread.java:833)
> Caused by: java.lang.IllegalStateException
>     at org.apache.maven.session.scope.internal.SessionScope$1.get 
> (SessionScope.java:44)
>     at com.google.inject.internal.ProviderInternalFactory.provision 
> (ProviderInternalFactory.java:85)
>     at 
> com.google.inject.internal.InternalFactoryToInitializableAdapter.provision 
> (InternalFactoryToInitializableAdapter.java:57)
>     at com.google.inject.internal.ProviderInternalFactory$1.call 
> (ProviderInternalFactory.java:66)
>     at 
> com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision 
> (ProvisionListenerStackCallback.java:112)
>     at org.eclipse.sisu.bean.BeanScheduler$CycleActivator.onProvision 
> (BeanScheduler.java:230)
>     at 
> com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision 
> (ProvisionListenerStackCallback.java:120)
>     at com.google.inject.internal.ProvisionListenerStackCallback.provision 
> (ProvisionListenerStackCallback.java:66)
>     at com.google.inject.internal.ProviderInternalFactory.circularGet 
> (ProviderInternalFactory.java:61)
>     at com.google.inject.internal.InternalFactoryToInitializableAdapter.get 
> (InternalFactoryToInitializableAdapter.java:47)
>     at com.google.inject.internal.ProviderToInternalFactoryAdapter.get 
> (ProviderToInternalFactoryAdapter.java:40)
>     at 
> org.apache.maven.session.scope.internal.SessionScope$CachingProvider.get 
> (SessionScope.java:166)
>     at org.apache.maven.session.scope.internal.SessionScope$3.get 
> (SessionScope.java:133)
>     at com.google.inject.internal.InternalFactoryToProviderAdapter.get 
> (InternalFactoryToProviderAdapter.java:39)
>     at com.google.inject.internal.SingleFieldInjector.inject 
> (SingleFieldInjector.java:52)
>     at com.google.inject.internal.MembersInjectorImpl.injectMembers 
> (MembersInjectorImpl.java:147)
>     at com.google.inject.internal.ConstructorInjector.provision 
> (ConstructorInjector.java:124)
>     at com.google.inject.internal.ConstructorInjector.access$000 
> (ConstructorInjector.java:32)
>     at com.google.inject.internal.ConstructorInjector$1.call 
> (ConstructorInjector.java:98)
>     at 
> com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision 
> (ProvisionListenerStackCallback.java:112)
>     at 
> com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision 
> (ProvisionListenerStackCallback.java:127)
>     at com.google.inject.internal.ProvisionListenerStackCallback.provision 
> (ProvisionListenerStackCallback.java:66)
>     at com.google.inject.internal.ConstructorInjector.construct 
> (ConstructorInjector.java:93)
>     at com.google.inject.internal.ConstructorBindingImpl$Factory.get 
> (ConstructorBindingImpl.java:306)
>     at com.google.inject.internal.InjectorImpl$1.get (InjectorImpl.java:1050)
>     at com.google.inject.internal.InjectorImpl.getInstance 
> (InjectorImpl.java:1086)
>     at org.eclipse.sisu.space.AbstractDeferredClass.get 
> (AbstractDeferredClass.java:48)
>     at com.google.inject.internal.ProviderInternalFactory.provision 
> (ProviderInternalFactory.java:85)
>     at 
> com.google.inject.internal.InternalFactoryToInitializableAdapter.provision 
> (InternalFactoryToInitializableAdapter.java:57)
>     at com.google.inject.internal.ProviderInternalFactory$1.call 
> (ProviderInternalFactory.java:66)
>     at 
> com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision 
> (ProvisionListenerStackCallback.java:112)
>     at 
> com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision 
> (ProvisionListenerStackCallback.java:127)
>     at com.google.inject.internal.ProvisionListenerStackCallback.provision 
> (ProvisionListenerStackCallback.java:66)
>     at com.google.inject.internal.ProviderInternalFactory.circularGet 
> (ProviderInternalFactory.java:61)
>     at com.google.inject.internal.InternalFactoryToInitializableAdapter.get 
> (InternalFactoryToInitializableAdapter.java:47)
>     at com.google.inject.internal.InjectorImpl$1.get (InjectorImpl.java:1050)
>     at org.eclipse.sisu.inject.Guice4$1.get (Guice4.java:162)
>     at org.eclipse.sisu.inject.LazyBeanEntry.getValue (LazyBeanEntry.java:81)
>     at org.eclipse.sisu.plexus.LazyPlexusBean.getValue 
> (LazyPlexusBean.java:51)
>     at org.codehaus.plexus.DefaultPlexusContainer.lookup 
> (DefaultPlexusContainer.java:263)
>     at org.codehaus.plexus.DefaultPlexusContainer.lookup 
> (DefaultPlexusContainer.java:255)
>     at 
> org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo 
> (DefaultMavenPluginManager.java:520)
>     at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo 
> (DefaultBuildPluginManager.java:124)
>     at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute 
> (MojoExecutor.java:301)
>     at org.apache.maven.lifecycle.internal.MojoExecutor.execute 
> (MojoExecutor.java:211)
>     at org.apache.maven.lifecycle.internal.MojoExecutor.execute 
> (MojoExecutor.java:165)
>     at org.apache.maven.lifecycle.internal.MojoExecutor.execute 
> (MojoExecutor.java:157)
>     at 
> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject 
> (LifecycleModuleBuilder.java:121)
>     at 
> org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call
>  (MultiThreadedBuilder.java:210)
>     at 
> org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call
>  (MultiThreadedBuilder.java:195)
>     at java.util.concurrent.FutureTask.run (FutureTask.java:264)
>     at java.util.concurrent.Executors$RunnableAdapter.call 
> (Executors.java:539)
>     at java.util.concurrent.FutureTask.run (FutureTask.java:264)
>     at java.util.concurrent.ThreadPoolExecutor.runWorker 
> (ThreadPoolExecutor.java:1136)
>     at java.util.concurrent.ThreadPoolExecutor$Worker.run 
> (ThreadPoolExecutor.java:635)
>     at java.lang.Thread.run (Thread.java:833) {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to