Author: epbernard
Date: 2008-05-30 18:26:13 -0400 (Fri, 30 May 2008)
New Revision: 14718
Modified:
search/trunk/src/java/org/hibernate/search/backend/Workspace.java
Log:
NPE when optimize try to apply similarity: guard against that
Modified: search/trunk/src/java/org/hibernate/search/backend/Workspace.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/backend/Workspace.java 2008-05-30 18:39:44
UTC (rev 14717)
+++ search/trunk/src/java/org/hibernate/search/backend/Workspace.java 2008-05-30 22:26:13
UTC (rev 14718)
@@ -252,7 +252,7 @@
/**
* Gets the currently open IndexWriter, or creates one.
* If a IndexReader was open, it will be closed first.
- * @param entity The entity for which the IndexWriter is needed
+ * @param entity The entity for which the IndexWriter is needed. entity can be null
when calling for Optimize
* @param modificationOperation set to true if needed to perform modifications to
index
* @return created or existing IndexWriter
*/
@@ -275,7 +275,9 @@
documentBuilder.getAnalyzer() :
SIMPLE_ANALYZER; //never used
writer = new IndexWriter( directoryProvider.getDirectory(), analyzer, false ); //has
been created at init time
- writer.setSimilarity( documentBuilder.getSimilarity() );
+ if ( entity != null ) {
+ writer.setSimilarity( documentBuilder.getSimilarity() );
+ }
LuceneIndexingParameters indexingParams =
searchFactoryImplementor.getIndexingParameters( directoryProvider );
indexingParams.applyToWriter( writer, isBatch );
}
Show replies by date