[ 
https://issues.apache.org/jira/browse/LUCENE-7646?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15834304#comment-15834304
 ] 

Tom Mortimer edited comment on LUCENE-7646 at 1/23/17 11:37 AM:
----------------------------------------------------------------

Mike, thanks for the comments. I didn't notice that when I posted the code like 
that, it changed the regex from

{noformat}.*.*{noformat}

to

{noformat}..{noformat}

which doesn't cause a problem. I've since found the same problem with the 
"non-silly" expression 

{noformat}.*{noformat}

{noformat}
Exception in thread "main" java.lang.NullPointerException
        at 
org.apache.lucene.index.AutomatonTermsEnum.<init>(AutomatonTermsEnum.java:79)
        at RegExpNPE.main(RegExpNPE.java:20)
{noformat}



was (Author: tommortimer):
Mike, thanks for the comments. I didn't notice that when I posted the code like 
that, it changed the regex from

{noformat}.*.*{noformat}

to

{noformat}..{noformat}

which doesn't cause a problem. I've since found the same problem with the 
"non-silly" expression 

{noformat}.*{noformat}



> AutomatonTermsEnum constructor throws a NullPointerException with "silly" 
> RegExp
> --------------------------------------------------------------------------------
>
>                 Key: LUCENE-7646
>                 URL: https://issues.apache.org/jira/browse/LUCENE-7646
>             Project: Lucene - Core
>          Issue Type: Bug
>          Components: core/index, core/other
>    Affects Versions: 6.2, 6.3
>         Environment: MacOS
> java version "1.8.0_77"
> Java(TM) SE Runtime Environment (build 1.8.0_77-b03)
> Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode)
>            Reporter: Tom Mortimer
>            Priority: Minor
>         Attachments: LUCENE-7646.patch
>
>
> When constructing a AutomatonTermsEnum using a CompiledAutomaton with a 
> "silly" RegExp (".*.*") a NullPointerException is thrown. See code below:
> import java.nio.file.Paths;
> import org.apache.lucene.index.*;
> import org.apache.lucene.store.*;
> import org.apache.lucene.util.automaton.*;
> public class RegExpNPE {
>   final static String REGEXP = ".*.*";
>   // replace these as appropriate
>   final static String INDEX = "../src/test/resources/index";
>   final static String FIELD = "text";
>   public static void main(String[] args) throws Exception {
>     Directory directory = FSDirectory.open(Paths.get(INDEX));
>     IndexReader reader = DirectoryReader.open(directory);
>     Fields fields = MultiFields.getFields(reader);
>     Terms terms = fields.terms(FIELD);
>     TermsEnum termsEnum = terms.iterator();
>     CompiledAutomaton automaton = new CompiledAutomaton(new 
> RegExp(REGEXP).toAutomaton());
>     TermsEnum termsEnum2 = new AutomatonTermsEnum(termsEnum, automaton);
>   }
> }



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to