mirror of https://github.com/apache/archiva.git
fix possible NPE when restarting a tomcat with serialized session
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1443484 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9c07475c30
commit
9ff7c33332
|
@ -50,11 +50,18 @@ public class TemporaryGroupIndexSessionCleaner
|
||||||
public void sessionCreated( HttpSessionEvent httpSessionEvent )
|
public void sessionCreated( HttpSessionEvent httpSessionEvent )
|
||||||
{
|
{
|
||||||
// ensure the map is here to avoid NPE
|
// ensure the map is here to avoid NPE
|
||||||
httpSessionEvent.getSession().setAttribute( TEMPORARY_INDEX_SESSION_KEY,
|
if ( httpSessionEvent.getSession().getAttribute( TEMPORARY_INDEX_SESSION_KEY ) == null )
|
||||||
new HashMap<String, TemporaryGroupIndex>() );
|
{
|
||||||
WebApplicationContext webApplicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(
|
httpSessionEvent.getSession().setAttribute( TEMPORARY_INDEX_SESSION_KEY,
|
||||||
httpSessionEvent.getSession().getServletContext() );
|
new HashMap<String, TemporaryGroupIndex>() );
|
||||||
indexMerger = webApplicationContext.getBean( IndexMerger.class );
|
}
|
||||||
|
|
||||||
|
if ( indexMerger == null )
|
||||||
|
{
|
||||||
|
WebApplicationContext webApplicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(
|
||||||
|
httpSessionEvent.getSession().getServletContext() );
|
||||||
|
indexMerger = webApplicationContext.getBean( IndexMerger.class );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sessionDestroyed( HttpSessionEvent httpSessionEvent )
|
public void sessionDestroyed( HttpSessionEvent httpSessionEvent )
|
||||||
|
@ -67,8 +74,19 @@ public class TemporaryGroupIndexSessionCleaner
|
||||||
{
|
{
|
||||||
log.info( "cleanup temporaryGroupIndex {} directory {}", temporaryGroupIndex.getIndexId(),
|
log.info( "cleanup temporaryGroupIndex {} directory {}", temporaryGroupIndex.getIndexId(),
|
||||||
temporaryGroupIndex.getDirectory().getAbsolutePath() );
|
temporaryGroupIndex.getDirectory().getAbsolutePath() );
|
||||||
indexMerger.cleanTemporaryGroupIndex( temporaryGroupIndex );
|
getIndexMerger( httpSessionEvent ).cleanTemporaryGroupIndex( temporaryGroupIndex );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IndexMerger getIndexMerger( HttpSessionEvent httpSessionEvent )
|
||||||
|
{
|
||||||
|
if ( indexMerger == null )
|
||||||
|
{
|
||||||
|
WebApplicationContext webApplicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(
|
||||||
|
httpSessionEvent.getSession().getServletContext() );
|
||||||
|
indexMerger = webApplicationContext.getBean( IndexMerger.class );
|
||||||
|
}
|
||||||
|
return indexMerger;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue