retrieve IndexSearcher from NexusIndexer instead of manual creation to prevent lucene locks

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1140036 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2011-06-27 07:45:32 +00:00
parent 23d74d0956
commit 8233856ae4
1 changed files with 4 additions and 8 deletions

View File

@ -26,7 +26,6 @@ import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.TopDocs; import org.apache.lucene.search.TopDocs;
import org.apache.lucene.store.SimpleFSDirectory;
import org.apache.maven.archiva.common.utils.ArchivaNexusIndexerUtil; import org.apache.maven.archiva.common.utils.ArchivaNexusIndexerUtil;
import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
@ -175,7 +174,7 @@ public class ArchivaIndexingTaskExecutorTest
Set<ArtifactInfo> results = response.getResults(); Set<ArtifactInfo> results = response.getResults();
ArtifactInfo artifactInfo = (ArtifactInfo) results.iterator().next(); ArtifactInfo artifactInfo = results.iterator().next();
assertEquals( "org.apache.archiva", artifactInfo.groupId ); assertEquals( "org.apache.archiva", artifactInfo.groupId );
assertEquals( "archiva-index-methods-jar-test", artifactInfo.artifactId ); assertEquals( "archiva-index-methods-jar-test", artifactInfo.artifactId );
assertEquals( "test-repo", artifactInfo.repository ); assertEquals( "test-repo", artifactInfo.repository );
@ -203,8 +202,7 @@ public class ArchivaIndexingTaskExecutorTest
indexer.constructQuery( MAVEN.ARTIFACT_ID, new StringSearchExpression( "archiva-index-methods-jar-test" ) ), indexer.constructQuery( MAVEN.ARTIFACT_ID, new StringSearchExpression( "archiva-index-methods-jar-test" ) ),
Occur.SHOULD ); Occur.SHOULD );
IndexSearcher searcher = IndexSearcher searcher = nexusIndexer.getIndexingContexts().get( repositoryConfig.getId() ).getIndexSearcher();
new IndexSearcher( new SimpleFSDirectory( new File( repositoryConfig.getLocation() + "/.indexer" ) ) );
TopDocs topDocs = searcher.search( q, null, 10 ); TopDocs topDocs = searcher.search( q, null, 10 );
searcher.close(); searcher.close();
@ -236,8 +234,7 @@ public class ArchivaIndexingTaskExecutorTest
indexer.constructQuery( MAVEN.ARTIFACT_ID, new StringSearchExpression( "archiva-index-methods-jar-test" ) ), indexer.constructQuery( MAVEN.ARTIFACT_ID, new StringSearchExpression( "archiva-index-methods-jar-test" ) ),
Occur.SHOULD ); Occur.SHOULD );
IndexSearcher searcher = IndexSearcher searcher = nexusIndexer.getIndexingContexts().get( repositoryConfig.getId() ).getIndexSearcher();
new IndexSearcher( new SimpleFSDirectory( new File( repositoryConfig.getLocation() + "/.indexer" ) ) );
TopDocs topDocs = searcher.search( q, null, 10 ); TopDocs topDocs = searcher.search( q, null, 10 );
@ -267,8 +264,7 @@ public class ArchivaIndexingTaskExecutorTest
indexer.constructQuery( MAVEN.ARTIFACT_ID, new StringSearchExpression( "archiva-index-methods-jar-test" ) ), indexer.constructQuery( MAVEN.ARTIFACT_ID, new StringSearchExpression( "archiva-index-methods-jar-test" ) ),
Occur.SHOULD ); Occur.SHOULD );
searcher = searcher = nexusIndexer.getIndexingContexts().get( repositoryConfig.getId() ).getIndexSearcher();
new IndexSearcher( new SimpleFSDirectory( new File( repositoryConfig.getLocation() + "/.indexer" ) ) );
topDocs = searcher.search( q, null, 10 ); topDocs = searcher.search( q, null, 10 );