cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject git commit: CXF-5938: LuceneQueryVisitor is not reusable / not thread-safe
Date Sat, 30 Aug 2014 19:08:49 GMT
Repository: cxf
Updated Branches:
  refs/heads/master d0c5c3def -> 38bb9fea4


CXF-5938: LuceneQueryVisitor is not reusable / not thread-safe


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/38bb9fea
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/38bb9fea
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/38bb9fea

Branch: refs/heads/master
Commit: 38bb9fea460262ff2781cbfdf85032d3f4fb9fe1
Parents: d0c5c3d
Author: reta <drreta@gmail.com>
Authored: Sat Aug 30 15:08:37 2014 -0400
Committer: reta <drreta@gmail.com>
Committed: Sat Aug 30 15:08:37 2014 -0400

----------------------------------------------------------------------
 .../main/java/demo/jaxrs/search/server/Catalog.java    | 13 +++++++------
 .../jaxrs/ext/search/lucene/LuceneQueryVisitor.java    |  3 ++-
 2 files changed, 9 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/38bb9fea/distribution/src/main/release/samples/jax_rs/search/src/main/java/demo/jaxrs/search/server/Catalog.java
----------------------------------------------------------------------
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 8e5c4b1..b1404bc 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
@@ -152,11 +152,11 @@ public class Catalog {
             final Query query = new MatchAllDocsQuery();
             
             for (final ScoreDoc scoreDoc: searcher.search(query, 1000).scoreDocs) {
-                final DocumentStoredFieldVisitor visitor = 
+                final DocumentStoredFieldVisitor fieldVisitor = 
                     new DocumentStoredFieldVisitor(LuceneDocumentMetadata.SOURCE_FIELD);
               
                 
-                reader.document(scoreDoc.doc, visitor);
-                builder.add(visitor
+                reader.document(scoreDoc.doc, fieldVisitor);
+                builder.add(fieldVisitor
                         .getDocument()
                         .getField(LuceneDocumentMetadata.SOURCE_FIELD)
                         .stringValue());
@@ -265,10 +265,11 @@ public class Catalog {
         final Map< String, Class< ? > > fieldTypes = new HashMap< String,
Class< ? > >();
         fieldTypes.put("modified", Date.class);
         
-        LuceneQueryVisitor<SearchBean> visitor = new LuceneQueryVisitor<SearchBean>(
+        LuceneQueryVisitor<SearchBean> newVisitor = new LuceneQueryVisitor<SearchBean>(
             "ct", "contents", analyzer);
-        visitor.setPrimitiveFieldTypeMap(fieldTypes);
-        return visitor;
+        newVisitor.setPrimitiveFieldTypeMap(fieldTypes);
+        
+        return newVisitor;
     }
     
     private boolean exists(final String source) throws IOException {

http://git-wip-us.apache.org/repos/asf/cxf/blob/38bb9fea/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/lucene/LuceneQueryVisitor.java
----------------------------------------------------------------------
diff --git a/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/lucene/LuceneQueryVisitor.java
b/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/lucene/LuceneQueryVisitor.java
index 68abcca..1836ce7 100644
--- a/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/lucene/LuceneQueryVisitor.java
+++ b/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/lucene/LuceneQueryVisitor.java
@@ -103,7 +103,8 @@ public class LuceneQueryVisitor<T> extends AbstractSearchConditionVisitor<T,
Que
             queryBuilder = new QueryBuilder(analyzer);
         }                
         
-        reset();
+        state.set(new Stack<List<Query>>());
+        state.get().push(new ArrayList<Query>());        
     }
     
     public void setContentsFieldMap(Map<String, String> map) {


Mime
View raw message