@Override
    public synchronized void close() {
        this.length = 0L;
        if(temporary.exists()) {
            try {
                if(file != null) {
                    file.close();
                }
            }
            catch(IOException e) {
                log.error(String.format("Failure closing buffer %s", this));
            }
            finally {
                try {
                    temporary.delete();
                    file = null;
                }
                catch(AccessDeniedException | NotfoundException e) {
                    log.warn(String.format("Failure removing temporary file %s for buffer %s. Schedule for delete on exit.", temporary, this));
                    Paths.get(temporary.getAbsolute()).toFile().deleteOnExit();
                }
            }
        }
    }
@Test
    public void testClose() throws Exception {
        final FileBuffer buffer = new FileBuffer();
        assertEquals(0L, buffer.length(), 0L);
        final byte[] chunk = RandomUtils.nextBytes(100);
        buffer.write(chunk, 0L);
        assertEquals(100L, buffer.length(), 0L);
        buffer.close();
        assertEquals(0L, buffer.length(), 0L);
        buffer.write(chunk, 0L);
        assertEquals(100L, buffer.length(), 0L);
    }