[jira] Created: (LUCENE-1248) Unncessary creation of object in org.apache.lucene.analysis.WordlistLoader.getWordSet()

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] Created: (LUCENE-1248) Unncessary creation of object in org.apache.lucene.analysis.WordlistLoader.getWordSet()

JIRA jira@apache.org
Unncessary creation of object in org.apache.lucene.analysis.WordlistLoader.getWordSet()
---------------------------------------------------------------------------------------

                 Key: LUCENE-1248
                 URL: https://issues.apache.org/jira/browse/LUCENE-1248
             Project: Lucene - Java
          Issue Type: Improvement
          Components: Analysis
    Affects Versions: 2.3.1, 2.3.2
            Reporter: David Dillard
            Priority: Trivial


Here's the function:

  public static HashSet getWordSet(File wordfile) throws IOException {
    HashSet result = new HashSet();
    FileReader reader = null;
    try {
      reader = new FileReader(wordfile);
      result = getWordSet(reader);
    }
    finally {
      if (reader != null)
        reader.close();
    }
    return result;
  }

The creation of the new HashSet object in the declaration of "result" is unnecessary.  Either "result" will be unconditionally set by the call to getWordSet() or an exception will occur.

This was detected by FindBugs.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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