[
https://issues.apache.org/jira/browse/OAK-9881?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17576769#comment-17576769
]
Nuno Santos commented on OAK-9881:
----------------------------------
The method that contains the unreachable code in the Lucene plugin:
{code}
private static void addNonFullTextConstraints(List<Query> qs, Filter filter,
IndexReader reader, Analyzer analyzer, IndexDefinition indexDefinition)
{code}
may not be in use anymore. It is not used by the unit tests, even though there
are some Lucene tests with like constraints. Maybe this method was replaced by
some other logic and was left by mistake? Could be worth to investigate if this
whole method can be removed.
> Unreachable code in the logic that processes like constraints
> -------------------------------------------------------------
>
> Key: OAK-9881
> URL: https://issues.apache.org/jira/browse/OAK-9881
> Project: Jackrabbit Oak
> Issue Type: Bug
> Components: indexing
> Reporter: Nuno Santos
> Priority: Minor
>
> In ElasticRequestHandler, the following code has a section that is
> unreachable:
> {code:java}
> private static Query like(String name, String first) {
> first = first.replace('%', WildcardQuery.WILDCARD_STRING);
> first = first.replace('_', WildcardQuery.WILDCARD_CHAR);
> int indexOfWS = first.indexOf(WildcardQuery.WILDCARD_STRING);
> int indexOfWC = first.indexOf(WildcardQuery.WILDCARD_CHAR);
> int len = first.length();
> if (indexOfWS == len || indexOfWC == len) {
> // Unreachable code
> }{code}
> The condition {{indexOfWS == len || indexOfWC == len}} will always evaluate
> to false because the variables {{indexOfWS}} and {{indexOfWC}} are between
> {{-1}} and {{len-1}} (from the specification of {{indexOf()}}), so they will
> never be equal to {{len}}. (I found this issue from a warning in the static
> analyzer of IntelliJ).
> Is this indeed a bug? If so, then we are missing tests to expose this bug.
> The same logic can be found here:
> https://github.com/apache/jackrabbit-oak/blob/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndex.java#L767-L791
--
This message was sent by Atlassian Jira
(v8.20.10#820010)