MNG-4866 use intermediate array to make sure we can purge all inherited MavenSession instances

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@1022613 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Igor Fedorenko 2010-10-14 16:59:46 +00:00
parent d76af58fce
commit 41fd344011
1 changed files with 10 additions and 4 deletions

View File

@ -37,23 +37,29 @@ public class DefaultLegacySupport
implements LegacySupport
{
private ThreadLocal<MavenSession> session = new InheritableThreadLocal<MavenSession>();
private static final ThreadLocal<MavenSession[]> session = new InheritableThreadLocal<MavenSession[]>();
public void setSession( MavenSession session )
{
if ( session == null )
{
this.session.remove();
MavenSession[] oldSession = DefaultLegacySupport.session.get();
if ( oldSession != null )
{
oldSession[0] = null;
DefaultLegacySupport.session.remove();
}
}
else
{
this.session.set( session );
DefaultLegacySupport.session.set( new MavenSession[] { session } );
}
}
public MavenSession getSession()
{
return session.get();
MavenSession[] currentSession = DefaultLegacySupport.session.get();
return currentSession != null ? currentSession[0] : null;
}
public RepositorySystemSession getRepositorySession()