You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by re...@apache.org on 2022/11/19 16:00:45 UTC

[cxf] branch main updated: CXF-8794: Update to Lucene 9.4.x. Replaced MMapDirectory with ByteBuffersDirectory in tests and samples

This is an automated email from the ASF dual-hosted git repository.

reta pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/main by this push:
     new 0bfc8552e7 CXF-8794: Update to Lucene 9.4.x. Replaced MMapDirectory with ByteBuffersDirectory in tests and samples
0bfc8552e7 is described below

commit 0bfc8552e73a54cf5fe52633be18e81edf1a375d
Author: Andriy Redko <dr...@gmail.com>
AuthorDate: Sat Nov 19 10:54:23 2022 -0500

    CXF-8794: Update to Lucene 9.4.x. Replaced MMapDirectory with ByteBuffersDirectory in tests and samples
---
 .../src/main/java/demo/jaxrs/search/server/Catalog.java  | 15 ++-------------
 .../apache/cxf/systest/jaxrs/extraction/BookCatalog.java | 16 ++--------------
 2 files changed, 4 insertions(+), 27 deletions(-)

diff --git a/distribution/src/main/release/samples/jax_rs/search/src/main/java/demo/jaxrs/search/server/Catalog.java b/distribution/src/main/release/samples/jax_rs/search/src/main/java/demo/jaxrs/search/server/Catalog.java
index e94d5ceaf6..dd89a203a6 100644
--- a/distribution/src/main/release/samples/jax_rs/search/src/main/java/demo/jaxrs/search/server/Catalog.java
+++ b/distribution/src/main/release/samples/jax_rs/search/src/main/java/demo/jaxrs/search/server/Catalog.java
@@ -26,8 +26,6 @@ import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.io.UncheckedIOException;
-import java.nio.file.Files;
 import java.util.Arrays;
 import java.util.Date;
 import java.util.HashMap;
@@ -82,8 +80,8 @@ import org.apache.lucene.search.Query;
 import org.apache.lucene.search.ScoreDoc;
 import org.apache.lucene.search.TermQuery;
 import org.apache.lucene.search.TopDocs;
+import org.apache.lucene.store.ByteBuffersDirectory;
 import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.MMapDirectory;
 import org.apache.tika.parser.Parser;
 import org.apache.tika.parser.odf.OpenDocumentParser;
 import org.apache.tika.parser.pdf.PDFParser;
@@ -93,7 +91,7 @@ public class Catalog {
     private final TikaLuceneContentExtractor extractor = new TikaLuceneContentExtractor(
         Arrays.< Parser >asList(new PDFParser(), new OpenDocumentParser()),
         new LuceneDocumentMetadata());
-    private final Directory directory;
+    private final Directory directory = new ByteBuffersDirectory();
     private final Analyzer analyzer = new StandardAnalyzer();
     private final Storage storage;
     private final LuceneQueryVisitor<SearchBean> visitor;
@@ -107,15 +105,6 @@ public class Catalog {
     public Catalog(final Storage storage) throws IOException {
         this.storage = storage;
         this.visitor = createVisitor();
-
-        try {
-            final java.nio.file.Path path = Files.createTempDirectory("search-demo");
-            directory = new MMapDirectory(path);
-            path.toFile().deleteOnExit();
-        } catch (final IOException ex) {
-            throw new UncheckedIOException(ex);
-        }
-
         initIndex();
     }
 
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/extraction/BookCatalog.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/extraction/BookCatalog.java
index a0d2357591..5f7fa881b2 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/extraction/BookCatalog.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/extraction/BookCatalog.java
@@ -21,8 +21,6 @@ package org.apache.cxf.systest.jaxrs.extraction;
 
 
 import java.io.IOException;
-import java.io.UncheckedIOException;
-import java.nio.file.Files;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Date;
@@ -55,27 +53,17 @@ import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.IndexWriterConfig;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.ScoreDoc;
+import org.apache.lucene.store.ByteBuffersDirectory;
 import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.MMapDirectory;
 import org.apache.tika.parser.pdf.PDFParser;
 
 @Path("/catalog")
 public class BookCatalog {
     private final TikaLuceneContentExtractor extractor = new TikaLuceneContentExtractor(new PDFParser());
-    private final Directory directory;
+    private final Directory directory = new ByteBuffersDirectory();
     private final Analyzer analyzer = new StandardAnalyzer();
     private final LuceneQueryVisitor<SearchBean> visitor = createVisitor();
     
-    public BookCatalog() {
-        try {
-            final java.nio.file.Path path = Files.createTempDirectory("catalog");
-            directory = new MMapDirectory(path);
-            path.toFile().deleteOnExit();
-        } catch (final IOException ex) {
-            throw new UncheckedIOException(ex);
-        }
-    }
-
     @POST
     @Consumes("multipart/form-data")
     public Response addBook(final MultipartBody body) throws Exception {