Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-6655

All analysis factory constructors fail if the passed in map is immutable

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 5.1
    • None
    • None
    • None
    • New

    Description

      One of our tests tried to initialise a StandardTokenizer by passing a version into the factory. Unfortunately, this required passing a map:

              return new StandardTokenizerFactory(ImmutableMap.of(
                  AbstractAnalysisFactory.LUCENE_MATCH_VERSION_PARAM,
                  Version.LUCENE_4_6_1.toString()
              )).create();
      

      This then fails:

      java.lang.UnsupportedOperationException
      	at com.google.common.collect.ImmutableMap.remove(ImmutableMap.java:338)
      	at org.apache.lucene.analysis.util.AbstractAnalysisFactory.get(AbstractAnalysisFactory.java:122)
      	at org.apache.lucene.analysis.util.AbstractAnalysisFactory.<init>(AbstractAnalysisFactory.java:71)
      	at org.apache.lucene.analysis.util.TokenizerFactory.<init>(TokenizerFactory.java:70)
      	at org.apache.lucene.analysis.standard.StandardTokenizerFactory.<init>(StandardTokenizerFactory.java:42)
      

      I suspect that someone put in a `remove` when it should have been a `get`... bit of a weird mistake to make, especially when you don't know whether the map will permit it.

      I haven't verified whether the same occurs in later versions but getting updated to 5.2.1 will probably be the next thing on my list.

      Attachments

        Activity

          People

            Unassigned Unassigned
            trejkaz Trejkaz
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: