File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed
main/java/org/apache/jackrabbit/oak/plugins/index/lucene
test/java/org/apache/jackrabbit/oak/plugins/index/lucene Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change 5858import org .slf4j .Logger ;
5959import org .slf4j .LoggerFactory ;
6060
61- import static java .util .Objects .requireNonNull ;
62-
6361/**
6462 * Constructs a Lucene Analyzer from nodes (based on NodeState content).
6563 *
@@ -141,9 +139,13 @@ private CharFilterFactory[] loadCharFilterFactories(NodeState charFiltersState)
141139 }
142140
143141 private TokenizerFactory loadTokenizer (NodeState state ) {
144- String clazz = requireNonNull (state .getString (FulltextIndexConstants .ANL_NAME ));
142+ String name = state .getString (FulltextIndexConstants .ANL_NAME );
143+ if (name == null ) {
144+ log .warn ("No tokenizer name specified in analyzer configuration. Using default 'standard' tokenizer." );
145+ name = "standard" ;
146+ }
145147 Map <String , String > args = convertNodeState (state );
146- TokenizerFactory tf = TokenizerFactory .forName (clazz , args );
148+ TokenizerFactory tf = TokenizerFactory .forName (name , args );
147149 init (tf , state );
148150 return tf ;
149151 }
Original file line number Diff line number Diff line change 3838import org .apache .lucene .analysis .core .StopFilterFactory ;
3939import org .apache .lucene .analysis .core .WhitespaceTokenizerFactory ;
4040import org .apache .lucene .analysis .path .PathHierarchyTokenizerFactory ;
41+ import org .apache .lucene .analysis .standard .StandardTokenizerFactory ;
4142import org .apache .lucene .analysis .util .CharArraySet ;
4243import org .apache .lucene .analysis .util .ClasspathResourceLoader ;
4344import org .apache .lucene .analysis .util .StopwordAnalyzerBase ;
@@ -191,6 +192,18 @@ public void nodeStateAsMap() throws Exception{
191192 assertNull (result .get (":hiddenProp" ));
192193 }
193194
195+ @ Test
196+ public void missingTokenizerName () throws Exception {
197+ NodeBuilder nb = EMPTY_NODE .builder ();
198+ nb .child (ANL_TOKENIZER );
199+
200+ TokenizerChain analyzer = (TokenizerChain ) factory .createInstance (nb .getNodeState ());
201+ assertNotNull (analyzer );
202+ assertNotNull (analyzer .getTokenizer ());
203+
204+ assertEquals (StandardTokenizerFactory .class .getName (), analyzer .getTokenizer ().getClassArg ());
205+ }
206+
194207 private static NodeBuilder createFileNode (NodeBuilder nb , String nodeName , byte [] content ){
195208 return nb .child (nodeName ).child (JCR_CONTENT ).setProperty (JCR_DATA , content );
196209 }
You can’t perform that action at this time.
0 commit comments