Skip to content

Commit

Permalink
Relax dependencies on lucene to include 10.x
Browse files Browse the repository at this point in the history
- Update PrebuiltIndexCompatibility.checkReadable so that it compiles
for both 9.x and 10.x and passes the tests in both case.
- This prepares for updating the target platform to use lucene 10.x,
which requires Java 21.

eclipse-platform/eclipse.platform.releng.aggregator#2654
  • Loading branch information
merks committed Dec 15, 2024
1 parent 8b8afca commit 3d0d987
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
6 changes: 3 additions & 3 deletions ua/org.eclipse.help.base/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ Require-Bundle: org.eclipse.ant.core;bundle-version="[3.2.200,4.0.0)";resolution
org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)",
org.eclipse.help;bundle-version="[3.5.0,4.0.0)";visibility:=reexport,
org.eclipse.core.net;bundle-version="[1.2.200,2.0.0)",
org.apache.lucene.analysis-common;bundle-version="[9.5.0,10.0.0)",
org.apache.lucene.core;bundle-version="[9.5.0,10.0.0)",
org.apache.lucene.analysis-smartcn;bundle-version="[9.5.0,10.0.0)"
org.apache.lucene.analysis-common;bundle-version="[9.5.0,11.0.0)",
org.apache.lucene.core;bundle-version="[9.5.0,11.0.0)",
org.apache.lucene.analysis-smartcn;bundle-version="[9.5.0,11.0.0)"
Import-Package: org.eclipse.equinox.http.jetty;resolution:=optional
Bundle-RequiredExecutionEnvironment: JavaSE-17
Bundle-ActivationPolicy: lazy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import org.apache.lucene.index.CorruptIndexException;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexFormatTooOldException;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.TopDocs;
Expand Down Expand Up @@ -121,10 +122,22 @@ private void checkReadable(String indexPath) throws IOException,
IndexSearcher searcher;
try (Directory luceneDirectory = new NIOFSDirectory(new File(filePath).toPath())) {
try (DirectoryReader luceneDirectoryReader = DirectoryReader.open(luceneDirectory)) {
// This code never reached because the index is not
// readable.
searcher = new IndexSearcher(luceneDirectoryReader);
TopDocs hits = searcher.search(luceneQuery, 500);
assertTrue(hits.totalHits.value >= 1);
assertTrue(hits.totalHits != null);
}
} catch (IndexFormatTooOldException ex) {
// Lucene 10.x throws this more explicit exception whereas 9.x
// throws IllegalArgumentException.
// Note that in
// org.eclipse.help.internal.search.SearchIndex.SearchIndex(File,
// String, AnalyzerDescriptor, TocManager, String)
// it catches all these:
// catch (IndexFormatTooOldException | IndexNotFoundException |
// IllegalArgumentException e)
throw new IllegalArgumentException(ex);
}
} else {
fail("Cannot resolve to file protocol");
Expand Down

0 comments on commit 3d0d987

Please sign in to comment.