paulirwin opened a new pull request, #1095:
URL: https://github.com/apache/lucenenet/pull/1095

   - [X] You've read the [Contributor 
Guide](https://github.com/apache/lucenenet/blob/main/CONTRIBUTING.md) and [Code 
of Conduct](https://www.apache.org/foundation/policies/conduct.html).
   - [X] You've included unit or integration tests for your change, where 
applicable.
   - [X] You've included inline docs for your change, where applicable.
   - [X] There's an open issue for the PR that you are making. If you'd like to 
propose a change, please [open an 
issue](https://github.com/apache/lucenenet/issues/new/choose) to discuss the 
change or find an existing issue.
   
   Some minor cleanup of IDisposable pattern implementations, and a bug fix.
   
   Fixes #265
   
   ## Description
   
   I did a review of all implementations of `IDisposable.Dispose()` to ensure 
they follow the [Dispose 
Pattern](https://learn.microsoft.com/en-us/dotnet/standard/design-guidelines/dispose-pattern)
 correctly, and someone had clearly already done all of the hard work here: it 
was nearly all done right. There were a couple cases that I fixed in this PR:
   
   - Lucene42DocValuesConsumer.SortedSetEnumerator did not implement the 
pattern correctly, but it also is an internal type with no subclasses, so this 
was made `sealed`.
   - Hunspell's TestDictionary.CloseCheckInputStream had a curious shadowing of 
Dispose that was causing it to not work correctly, and this exposed a bug: the 
stream wrapper was getting disposed of in Hunspell.Dictionary, when it is 
expected to not be disposed of. The shadowed Dispose method was never called, 
even if the Dictionary code actually did dispose of the wrapper. This created a 
false negative, where the test thought it wasn't disposed of when it actually 
was. This PR fixes that by removing the shadowing Dispose method, marking 
`this.disposed` in the actual Dispose pattern override method so that it's 
properly marked when called virtually, and leaving the stream open in the 
Dictionary.ReadDictionaryFiles method to match Java's behavior (and the 
expected behavior per the unit test).  
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@lucenenet.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to