@Test public void testRelease() throws Exception { FileHandleFiller filler = mock(FileHandleFiller.class); ArgumentCaptor<Integer> handleCaptor = ArgumentCaptor.forClass(Integer.class); doNothing().when(filler).setFileHandle(handleCaptor.capture()); Path fooBar = mockPath(mirrorRoot, "foo.bar"); when(fileSystem.provider().newFileChannel(eq(fooBar), eq(set(StandardOpenOption.READ)))).thenReturn(mock(FileChannel.class)); fs.open("foo.bar", filler); int result = fs.release("foo.bar", handleCaptor.getValue()); assertThat(result).isEqualTo(SUCCESS); }
@Override public int release(String path, int fileHandle) { logger.info("release({}, {})", fileHandle, path); FileChannel fileChannel = openFiles.remove(fileHandle); if (fileChannel == null) { return -ErrorCodes.EBADF(); } safeClose(fileChannel); return SUCCESS; }
MirrorFs implements se.tfiskgul.mux2fs.fs.base.FileSystem { @Override public int release(String path, int fileHandle) { logger.info("release({}, {})", fileHandle, path); FileChannel fileChannel = openFiles.remove(fileHandle); if (fileChannel == null) { return -ErrorCodes.EBADF(); } safeClose(fileChannel); return SUCCESS; } }
MirrorFs implements se.tfiskgul.mux2fs.fs.base.FileSystem { @Override public int release(String path, int fileHandle) { logger.info("release({}, {})", fileHandle, path); FileChannel fileChannel = openFiles.remove(fileHandle); if (fileChannel == null) { return -ErrorCodes.EBADF(); } safeClose(fileChannel); return SUCCESS; } MirrorFs(Path mirroredPath); @VisibleForTesting protected  MirrorFs(Path mirroredPath, FileChannelCloser fileChannelCloser); }
MirrorFs implements se.tfiskgul.mux2fs.fs.base.FileSystem { @Override public int release(String path, int fileHandle) { logger.info("release({}, {})", fileHandle, path); FileChannel fileChannel = openFiles.remove(fileHandle); if (fileChannel == null) { return -ErrorCodes.EBADF(); } safeClose(fileChannel); return SUCCESS; } MirrorFs(Path mirroredPath); @VisibleForTesting protected  MirrorFs(Path mirroredPath, FileChannelCloser fileChannelCloser); @Override String getFSName(); @Override int getattr(String path, StatFiller stat); @Override int readdir(String path, DirectoryFiller filler); @Override int readLink(String path, Consumer<String> buf, int size); @Override int open(String path, FileHandleFiller filler); @Override int read(String path, Consumer<byte[]> buf, int size, long offset, int fileHandle); @Override int release(String path, int fileHandle); @Override void destroy(); }
MirrorFs implements se.tfiskgul.mux2fs.fs.base.FileSystem { @Override public int release(String path, int fileHandle) { logger.info("release({}, {})", fileHandle, path); FileChannel fileChannel = openFiles.remove(fileHandle); if (fileChannel == null) { return -ErrorCodes.EBADF(); } safeClose(fileChannel); return SUCCESS; } MirrorFs(Path mirroredPath); @VisibleForTesting protected  MirrorFs(Path mirroredPath, FileChannelCloser fileChannelCloser); @Override String getFSName(); @Override int getattr(String path, StatFiller stat); @Override int readdir(String path, DirectoryFiller filler); @Override int readLink(String path, Consumer<String> buf, int size); @Override int open(String path, FileHandleFiller filler); @Override int read(String path, Consumer<byte[]> buf, int size, long offset, int fileHandle); @Override int release(String path, int fileHandle); @Override void destroy();  }