AbstractInterruptibleChannel#close / tracking resource leaks
Robert Muir
rcmuir at gmail.com
Wed Sep 9 23:03:45 UTC 2015
Hello,
In lucene we use the FileSystemProvider api to wrap the actual
filesystem during test execution:
* failing tests on resource leaks
* failing tests if they use too many file handles
* shuffling directory listing order in a predictable way
* acting like windows for file deletions
* adding optional low level logging
We don't have problems but there is one ugly part, and that is
delegation around FileChannel.close (because it is final). Our current
solution is an ugly hack:
https://github.com/apache/lucene-solr/blob/trunk/lucene/test-framework/src/java/org/apache/lucene/mockfile/FilterFileChannel.java#L139-L164
AsynchronousFileChannel does not have the issue, because its close()
method isn't final, the problem is limited to just FileChannel.
Is there a better way we can do this, or something that could be
improved here? This evil technique (not surprisingly) fails with the
jigsaw EA build, but it would be great to still be able to wrap the
filesystem in tests to e.g. detect leaks and so on in the future.
Thanks,
Robert
More information about the nio-dev
mailing list