@Override
    public boolean find(final Path file, final ListProgressListener listener) throws BackgroundException {
        if(file.isRoot()) {
            return delegate.find(file, listener);
        }
        if(cache.isValid(file.getParent())) {
            final AttributedList<Path> list = cache.get(file.getParent());
            final Path found = list.find(new ListFilteringFeature.ListFilteringPredicate(sensitivity, file));
            if(found != null) {
                if(log.isDebugEnabled()) {
                    log.debug(String.format("Found %s in cache", file));
                }
                return true;
            }
            if(log.isDebugEnabled()) {
                log.debug(String.format("Cached directory listing does not contain %s", file));
            }
            return false;
        }
        final CachingListProgressListener caching = new CachingListProgressListener(cache);
        final boolean found = delegate.find(file, new ProxyListProgressListener(listener, caching));
        caching.cache();
        return found;
    }
@Test
    public void testFindNotfound() throws Exception {
        final PathCache cache = new PathCache(1);
        final Path directory = new Path("/", EnumSet.of(Path.Type.directory));
        final Path file = new Path(directory, "f", EnumSet.of(Path.Type.file));
        final CachingFindFeature feature = new CachingFindFeature(Protocol.Case.sensitive, cache,
                new DefaultFindFeature(new NullSession(new Host(new TestProtocol())) {
                    @Override
                    public AttributedList<Path> list(final Path folder, final ListProgressListener listener) throws BackgroundException {
                        throw new NotfoundException(folder.getAbsolute());
                    }
                }));
        feature.find(file, new DisabledListProgressListener());
        assertEquals(0, cache.size());
        assertFalse(cache.isCached(directory));
    }