Also wrap IndexInput if CFS is used

This commit is contained in:
Simon Willnauer 2013-12-12 12:14:03 +01:00
parent d95420cc67
commit 198d36dc15
1 changed files with 22 additions and 0 deletions

View File

@ -167,6 +167,28 @@ public class MockDirectoryHelper {
public synchronized IndexInput openInput(String name, IOContext context) throws IOException { public synchronized IndexInput openInput(String name, IOContext context) throws IOException {
return new CloseTrackingMockIndexInputWrapper(name, super.openInput(name, context), logger); return new CloseTrackingMockIndexInputWrapper(name, super.openInput(name, context), logger);
} }
@Override
public IndexInputSlicer createSlicer(final String name, IOContext context) throws IOException {
final IndexInputSlicer slicer = super.createSlicer(name, context);
return new IndexInputSlicer() {
@Override
public IndexInput openSlice(String sliceDescription, long offset, long length) throws IOException {
return new CloseTrackingMockIndexInputWrapper(name, slicer.openSlice(sliceDescription, offset, length), logger);
}
@Override
public IndexInput openFullSlice() throws IOException {
return new CloseTrackingMockIndexInputWrapper(name, slicer.openFullSlice(), logger);
}
@Override
public void close() throws IOException {
slicer.close();
}
};
}
} }
private static class CloseTrackingMockIndexInputWrapper extends IndexInput { private static class CloseTrackingMockIndexInputWrapper extends IndexInput {