apache / lucene

Apache Lucene open-source search software
https://lucene.apache.org/
Apache License 2.0
2.65k stars 1.03k forks source link

Ignoring the Return Values Of Immutable Objects [LUCENE-5506] #6569

Open asfimport opened 10 years ago

asfimport commented 10 years ago

I was checking the source code of Lucene and I realized that return values of immutable objects are ignored at CSVUtil.java and Compile.java as follows:

CSVUtil.java:

  /**
   * Quote and escape input value for CSV
   */
  public static String quoteEscape(String original) {
    String result = original;

    if (result.indexOf('\"') >= 0) {
      result.replace("\"", ESCAPED_QUOTE);
    }
    if(result.indexOf(COMMA) >= 0) {
      result = "\"" + result + "\"";
    }
    return result;
  }

Compile.java

    if (args.length < 1) {
      return;
    }

    args[0].toUpperCase(Locale.ROOT);

Migrated from LUCENE-5506 by Furkan Kamaci, 1 vote, updated May 09 2016 Attachments: LUCENE-5506.patch Linked issues:

asfimport commented 10 years ago

Furkan Kamaci (migrated from JIRA)

I've added patch file.

asfimport commented 10 years ago

Furkan Kamaci (migrated from JIRA)

Reopening issue until a committer commits it.

asfimport commented 10 years ago

Michael McCandless (@mikemccand) (migrated from JIRA)

Hmm, these do look bad, but I'd like to get a test case showing the bugs.

And, the fix to Compile.java causes failures in TestCompile.java.

asfimport commented 10 years ago

Furkan Kamaci (migrated from JIRA)

@mikemccand I'll check the test case.

asfimport commented 10 years ago

Furkan Kamaci (migrated from JIRA)

@mikemccand I've debugged the code and I see that optimize() method at Reduce.java has bug (I think so). Right now args[0] is not upper cased properly so optimize (removing the holes in the rows of the given trie) did not into take count. Because of optimize() method never runs the bug is not realized. If the bug is resolved stemmer may work faster. I will open a new Jira for it.

asfimport commented 10 years ago

Uwe Schindler (@uschindler) (migrated from JIRA)

Move issue to Lucene 4.9.

asfimport commented 10 years ago

Mark Miller (@markrmiller) (migrated from JIRA)

Nice to get a test, but probably more important to commit the fixes. CSVUtil looks pretty clear cut.