Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-7907 Ant precommit task WARNINGS about unclosed resources
  3. LUCENE-9376

Fix or suppress 20 resource leak precommit warnings in lucene/search

    XMLWordPrintableJSON

    Details

    • Type: Sub-task
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 8.6
    • Component/s: None
    • Labels:
      None
    • Lucene Fields:
      New

      Description

      There are 20 resource leak precommit warnings in org/apache/lucene/search:

       [ecj-lint] 71. WARNING in /Users/andrassalamon/src/lucene-solr-upstream/lucene/core/src/test/org/apache/lucene/search/TestFuzzyQuery.java (at line 414)
       [ecj-lint] 	MockAnalyzer analyzer = new MockAnalyzer(random());
       [ecj-lint] 	             ^^^^^^^^
       [ecj-lint] Resource leak: 'analyzer' is never closed
      --
       [ecj-lint] 72. WARNING in /Users/andrassalamon/src/lucene-solr-upstream/lucene/core/src/test/org/apache/lucene/search/TestFuzzyQuery.java (at line 557)
       [ecj-lint] 	RandomIndexWriter w = new RandomIndexWriter(random(), dir);
       [ecj-lint] 	                  ^
       [ecj-lint] Resource leak: 'w' is never closed
      --
       [ecj-lint] 73. WARNING in /Users/andrassalamon/src/lucene-solr-upstream/lucene/core/src/test/org/apache/lucene/search/TestLRUQueryCache.java (at line 185)
       [ecj-lint] 	throw error.get();
       [ecj-lint] 	^^^^^^^^^^^^^^^^^^
       [ecj-lint] Resource leak: 'mgr' is not closed at this location
      --
       [ecj-lint] 74. WARNING in /Users/andrassalamon/src/lucene-solr-upstream/lucene/core/src/test/org/apache/lucene/search/TestLRUQueryCache.java (at line 185)
       [ecj-lint] 	throw error.get();
       [ecj-lint] 	^^^^^^^^^^^^^^^^^^
       [ecj-lint] Resource leak: 'w' is not closed at this location
      --
       [ecj-lint] 75. WARNING in /Users/andrassalamon/src/lucene-solr-upstream/lucene/core/src/test/org/apache/lucene/search/TestSameScoresWithThreads.java (at line 49)
       [ecj-lint] 	LineFileDocs docs = new LineFileDocs(random());
       [ecj-lint] 	             ^^^^
       [ecj-lint] Resource leak: 'docs' is never closed
      --
       [ecj-lint] 76. WARNING in /Users/andrassalamon/src/lucene-solr-upstream/lucene/core/src/test/org/apache/lucene/search/TestSearcherManager.java (at line 313)
       [ecj-lint] 	SearcherManager sm = new SearcherManager(writer, false, false, new SearcherFactory());
       [ecj-lint] 	                ^^
       [ecj-lint] Resource leak: 'sm' is never closed
      --
       [ecj-lint] 79. WARNING in /Users/andrassalamon/src/lucene-solr-upstream/lucene/core/src/test/org/apache/lucene/search/TestTermQuery.java (at line 52)
       [ecj-lint] 	new TermQuery(new Term("foo", "bar"), TermStates.build(new MultiReader().getContext(), new Term("foo", "bar"), true)));
       [ecj-lint] 	                                                       ^^^^^^^^^^^^^^^^^
       [ecj-lint] Resource leak: '<unassigned Closeable value>' is never closed
      --
       [ecj-lint] 15. WARNING in /Users/andrassalamon/src/lucene-solr-upstream/lucene/test-framework/src/java/org/apache/lucene/search/ShardSearchingTestBase.java (at line 554)
       [ecj-lint] 	final LineFileDocs docs = new LineFileDocs(random());
       [ecj-lint] 	                   ^^^^
       [ecj-lint] Resource leak: 'docs' is never closed
      --
       [ecj-lint] 1. WARNING in /Users/andrassalamon/src/lucene-solr-upstream/lucene/highlighter/src/java/org/apache/lucene/search/uhighlight/UnifiedHighlighter.java (at line 598)
       [ecj-lint] 	IndexReader indexReaderWithTermVecCache =
       [ecj-lint] 	            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
       [ecj-lint] Resource leak: 'indexReaderWithTermVecCache' is never closed
      --
       [ecj-lint] 1. WARNING in /Users/andrassalamon/src/lucene-solr-upstream/lucene/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java (at line 1365)
       [ecj-lint] 	Analyzer analyzer = new SynonymAnalyzer(synonyms);
       [ecj-lint] 	         ^^^^^^^^
       [ecj-lint] Resource leak: 'analyzer' is never closed
      --
       [ecj-lint] 2. WARNING in /Users/andrassalamon/src/lucene-solr-upstream/lucene/highlighter/src/test/org/apache/lucene/search/highlight/TokenSourcesTest.java (at line 379)
       [ecj-lint] 	final BaseTermVectorsFormatTestCase.RandomTokenStream rTokenStream =
       [ecj-lint] 	                                                      ^^^^^^^^^^^^
       [ecj-lint] Resource leak: 'rTokenStream' is never closed
      --
       [ecj-lint] 3. WARNING in /Users/andrassalamon/src/lucene-solr-upstream/lucene/highlighter/src/test/org/apache/lucene/search/highlight/custom/HighlightCustomQueryTest.java (at line 108)
       [ecj-lint] 	TokenStream tokenStream = new MockAnalyzer(random(), MockTokenizer.SIMPLE,
       [ecj-lint]         true, MockTokenFilter.ENGLISH_STOPSET).tokenStream(fieldName, text);
       [ecj-lint] 	                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      --
       [ecj-lint] 4. WARNING in /Users/andrassalamon/src/lucene-solr-upstream/lucene/sandbox/src/test/org/apache/lucene/search/TestTermAutomatonQuery.java (at line 426)
       [ecj-lint] 	RandomIndexWriter w = new RandomIndexWriter(random(), dir, iwc);
       [ecj-lint] 	                  ^
       [ecj-lint] Resource leak: 'w' is never closed
      --
       [ecj-lint] 1. WARNING in /Users/andrassalamon/src/lucene-solr-upstream/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/TestFreeTextSuggester.java (at line 134)
       [ecj-lint] 	final LineFileDocs lfd = new LineFileDocs(null, "/lucenedata/enwiki/enwiki-20120502-lines-1k.txt");
       [ecj-lint] 	                   ^^^
       [ecj-lint] Resource leak: 'lfd' is never closed
      --
       [ecj-lint] 2. WARNING in /Users/andrassalamon/src/lucene-solr-upstream/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/TestSuggestStopFilter.java (at line 53)
       [ecj-lint] 	filter = new SuggestStopFilter(stream, stopWords);
       [ecj-lint] 	^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       [ecj-lint] Resource leak: 'filter' is not closed at this location
      --
       [ecj-lint] 3. WARNING in /Users/andrassalamon/src/lucene-solr-upstream/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/TestSuggestStopFilter.java (at line 73)
       [ecj-lint] 	filter = new SuggestStopFilter(stream, stopWords);
       [ecj-lint] 	^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       [ecj-lint] Resource leak: 'filter' is not closed at this location
      --
       [ecj-lint] 4. WARNING in /Users/andrassalamon/src/lucene-solr-upstream/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/TestSuggestStopFilter.java (at line 93)
       [ecj-lint] 	filter = new SuggestStopFilter(stream, stopWords);
       [ecj-lint] 	^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       [ecj-lint] Resource leak: 'filter' is not closed at this location
      --
       [ecj-lint] 5. WARNING in /Users/andrassalamon/src/lucene-solr-upstream/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/TestSuggestStopFilter.java (at line 113)
       [ecj-lint] 	filter = new SuggestStopFilter(stream, stopWords);
       [ecj-lint] 	^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       [ecj-lint] Resource leak: 'filter' is not closed at this location
      --
       [ecj-lint] 6. WARNING in /Users/andrassalamon/src/lucene-solr-upstream/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/TestSuggestStopFilter.java (at line 133)
       [ecj-lint] 	filter = new SuggestStopFilter(stream, stopWords);
       [ecj-lint] 	^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       [ecj-lint] Resource leak: 'filter' is not closed at this location
      --
       [ecj-lint] 7. WARNING in /Users/andrassalamon/src/lucene-solr-upstream/lucene/suggest/src/test/org/apache/lucene/search/suggest/document/TestSuggestField.java (at line 724)
       [ecj-lint] 	LineFileDocs lineFileDocs = new LineFileDocs(random());
       [ecj-lint] 	             ^^^^^^^^^^^^
       [ecj-lint] Resource leak: 'lineFileDocs' is never closed
      
      

        Attachments

        1. LUCENE-9376.patch
          17 kB
          Andras Salamon

          Issue Links

            Activity

              People

              • Assignee:
                erickerickson Erick Erickson
                Reporter:
                asalamon74 Andras Salamon
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: