You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by ol...@apache.org on 2013/02/07 15:03:08 UTC
svn commit: r1443484 -
/archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/util/TemporaryGroupIndexSessionCleaner.java
Author: olamy
Date: Thu Feb 7 14:03:07 2013
New Revision: 1443484
URL: http://svn.apache.org/viewvc?rev=1443484&view=rev
Log:
fix possible NPE when restarting a tomcat with serialized session
Modified:
archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/util/TemporaryGroupIndexSessionCleaner.java
Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/util/TemporaryGroupIndexSessionCleaner.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/util/TemporaryGroupIndexSessionCleaner.java?rev=1443484&r1=1443483&r2=1443484&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/util/TemporaryGroupIndexSessionCleaner.java (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/util/TemporaryGroupIndexSessionCleaner.java Thu Feb 7 14:03:07 2013
@@ -50,11 +50,18 @@ public class TemporaryGroupIndexSessionC
public void sessionCreated( HttpSessionEvent httpSessionEvent )
{
// ensure the map is here to avoid NPE
- httpSessionEvent.getSession().setAttribute( TEMPORARY_INDEX_SESSION_KEY,
- new HashMap<String, TemporaryGroupIndex>() );
- WebApplicationContext webApplicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(
- httpSessionEvent.getSession().getServletContext() );
- indexMerger = webApplicationContext.getBean( IndexMerger.class );
+ if ( httpSessionEvent.getSession().getAttribute( TEMPORARY_INDEX_SESSION_KEY ) == null )
+ {
+ httpSessionEvent.getSession().setAttribute( TEMPORARY_INDEX_SESSION_KEY,
+ new HashMap<String, TemporaryGroupIndex>() );
+ }
+
+ if ( indexMerger == null )
+ {
+ WebApplicationContext webApplicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(
+ httpSessionEvent.getSession().getServletContext() );
+ indexMerger = webApplicationContext.getBean( IndexMerger.class );
+ }
}
public void sessionDestroyed( HttpSessionEvent httpSessionEvent )
@@ -67,8 +74,19 @@ public class TemporaryGroupIndexSessionC
{
log.info( "cleanup temporaryGroupIndex {} directory {}", temporaryGroupIndex.getIndexId(),
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;
}
}