bhabegger commented on code in PR #3139:
URL: https://github.com/apache/jackrabbit-oak/pull/3139#discussion_r4073071787


##########
oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/FulltextRegexQueryTest.java:
##########
@@ -0,0 +1,340 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.jackrabbit.oak.plugins.index.lucene;
+
+import java.text.ParseException;
+import java.util.Random;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.function.Predicate;
+
+import org.apache.jackrabbit.oak.InitialContent;
+import org.apache.jackrabbit.oak.Oak;
+import org.apache.jackrabbit.oak.api.ContentRepository;
+import org.apache.jackrabbit.oak.api.ContentSession;
+import org.apache.jackrabbit.oak.api.QueryEngine;
+import org.apache.jackrabbit.oak.api.Result;
+import org.apache.jackrabbit.oak.api.ResultRow;
+import org.apache.jackrabbit.oak.api.Root;
+import org.apache.jackrabbit.oak.api.Tree;
+import org.apache.jackrabbit.oak.api.Type;
+import org.apache.jackrabbit.oak.plugins.index.AsyncIndexUpdate;
+import 
org.apache.jackrabbit.oak.plugins.index.counter.NodeCounterEditorProvider;
+import 
org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexDefinitionBuilder;
+import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore;
+import org.apache.jackrabbit.oak.spi.commit.Observer;
+import org.apache.jackrabbit.oak.spi.query.QueryIndexProvider;
+import org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider;
+import org.apache.jackrabbit.oak.spi.state.NodeStore;
+import org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard;
+import org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+/**
+ * Explores LUCENE-9981: a Lucene regex query is parsed into a {@code 
RegexpQuery} by
+ * converting the regex to an automaton ({@code RegExp.toAutomaton()}). For 
certain
+ * pathological regexes (e.g. repeated {@code .*} groups), 
building/determinizing that
+ * automaton can take catastrophic amounts of time and memory.
+ * <p>
+ * A slash-delimited regex passed to a plain {@code contains(*, '/regex/')} 
clause does
+ * <b>not</b> reach this code: {@code FulltextIndex.rewriteQueryText()} 
unconditionally
+ * escapes the delimiting slashes first, so the term is never recognized as a 
regex (see
+ * {@link #fuzzForEncodingThatReachesGenuineRegexParsing}). A {@code 
native('lucene', ...)}
+ * clause, however, bypasses that escaping and does genuinely reach
+ * {@code RegExp.toAutomaton()} (see {@link 
#nativeLuceneQueryReachesGenuineRegexParsing}
+ * and {@link #pathologicalRegexCanCauseCatastrophicSlowdown}).
+ * <p>
+ * Note oak-lucene bundles its own (very old, Lucene 4.7.2 based, see 
OAK-10786) copy of
+ * the automaton classes, so this needs to be verified against oak-lucene's 
actual runtime
+ * behaviour rather than assumed from the upstream Lucene ticket.
+ */
+public class FulltextRegexQueryTest {

Review Comment:
   Is this related to the introduction of IF and EXISTS ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to