Skip to content

Commit 3d0d987

Browse files
committed
Relax dependencies on lucene to include 10.x
- 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
1 parent 8b8afca commit 3d0d987

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

ua/org.eclipse.help.base/META-INF/MANIFEST.MF

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ Require-Bundle: org.eclipse.ant.core;bundle-version="[3.2.200,4.0.0)";resolution
4343
org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)",
4444
org.eclipse.help;bundle-version="[3.5.0,4.0.0)";visibility:=reexport,
4545
org.eclipse.core.net;bundle-version="[1.2.200,2.0.0)",
46-
org.apache.lucene.analysis-common;bundle-version="[9.5.0,10.0.0)",
47-
org.apache.lucene.core;bundle-version="[9.5.0,10.0.0)",
48-
org.apache.lucene.analysis-smartcn;bundle-version="[9.5.0,10.0.0)"
46+
org.apache.lucene.analysis-common;bundle-version="[9.5.0,11.0.0)",
47+
org.apache.lucene.core;bundle-version="[9.5.0,11.0.0)",
48+
org.apache.lucene.analysis-smartcn;bundle-version="[9.5.0,11.0.0)"
4949
Import-Package: org.eclipse.equinox.http.jetty;resolution:=optional
5050
Bundle-RequiredExecutionEnvironment: JavaSE-17
5151
Bundle-ActivationPolicy: lazy

ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/PrebuiltIndexCompatibility.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
import org.apache.lucene.index.CorruptIndexException;
3030
import org.apache.lucene.index.DirectoryReader;
31+
import org.apache.lucene.index.IndexFormatTooOldException;
3132
import org.apache.lucene.search.IndexSearcher;
3233
import org.apache.lucene.search.Query;
3334
import org.apache.lucene.search.TopDocs;
@@ -121,10 +122,22 @@ private void checkReadable(String indexPath) throws IOException,
121122
IndexSearcher searcher;
122123
try (Directory luceneDirectory = new NIOFSDirectory(new File(filePath).toPath())) {
123124
try (DirectoryReader luceneDirectoryReader = DirectoryReader.open(luceneDirectory)) {
125+
// This code never reached because the index is not
126+
// readable.
124127
searcher = new IndexSearcher(luceneDirectoryReader);
125128
TopDocs hits = searcher.search(luceneQuery, 500);
126-
assertTrue(hits.totalHits.value >= 1);
129+
assertTrue(hits.totalHits != null);
127130
}
131+
} catch (IndexFormatTooOldException ex) {
132+
// Lucene 10.x throws this more explicit exception whereas 9.x
133+
// throws IllegalArgumentException.
134+
// Note that in
135+
// org.eclipse.help.internal.search.SearchIndex.SearchIndex(File,
136+
// String, AnalyzerDescriptor, TocManager, String)
137+
// it catches all these:
138+
// catch (IndexFormatTooOldException | IndexNotFoundException |
139+
// IllegalArgumentException e)
140+
throw new IllegalArgumentException(ex);
128141
}
129142
} else {
130143
fail("Cannot resolve to file protocol");

0 commit comments

Comments
 (0)