@Override
    public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException {
        try {
            if(implementations.containsKey(Command.mlsd)) {
                // Note that there is no distinct FEAT output for MLSD. The presence of the MLST feature
                // indicates that both MLST and MLSD are supported.
                if(session.getClient().hasFeature(FTPCmd.MLST.getCommand())) {
                    try {
                        return this.post(directory, implementations.get(Command.mlsd).list(directory, listener), listener);
                    }
                    catch(InteroperabilityException e) {
                        this.remove(Command.mlsd);
                    }
                }
                else {
                    this.remove(Command.mlsd);
                }
            }
            if(implementations.containsKey(Command.stat)) {
                try {
                    return this.post(directory, implementations.get(Command.stat).list(directory, listener), listener);
                }
                catch(InteroperabilityException | AccessDeniedException | NotfoundException e) {
                    this.remove(Command.stat);
                }
            }
            if(implementations.containsKey(Command.lista)) {
                try {
                    return this.post(directory, implementations.get(Command.lista).list(directory, listener), listener);
                }
                catch(FTPInvalidListException e) {
                    // Empty directory listing. #7737
                }
                catch(InteroperabilityException e) {
                    this.remove(Command.lista);
                }
            }
            try {
                return this.post(directory, implementations.get(Command.list).list(directory, listener), listener);
            }
            catch(FTPInvalidListException f) {
                // Empty directory listing
                return this.post(directory, f.getParsed(), listener);
            }
        }
        catch(IOException e) {
            throw new FTPExceptionMappingService().map("Listing directory {0} failed", e, directory);
        }
    }
@Test(expected = NotfoundException.class)
    public void testListNotfound() throws Exception {
        final Path f = new Path(UUID.randomUUID().toString(), EnumSet.of(Path.Type.directory));
        final FTPListService service = new FTPListService(session, null, TimeZone.getDefault());
        service.list(f, new DisabledListProgressListener());
    }