public void run()

in src/main/java/com/pastdev/jsch/nio/file/UnixSshPathWatchKey.java [188:254]


    public void run() {
        boolean first = true;
        try {
            while ( true ) {
                if ( !isValid() ) {
                    break;
                }
                try {
                    logger.trace( "polling {}", dir );
                    Map<UnixSshPath, PosixFileAttributes> entries =
                            dir.getFileSystem().provider().statDirectory( dir );
                    logger.trace( "got response {}", dir );
                    if ( first ) {
                        first = false;
                        this.entries = entries;
                        try {
                            pollerLock.lock();
                            logger.trace( "initialization complete got lock" );
                            initialized = true;
                            initializationComplete.signalAll();
                            logger.debug( "poller is initialized" );
                        }
                        finally {
                            pollerLock.unlock();
                        }
                    }
                    else {
                        for ( UnixSshPath entryPath : entries.keySet() ) {
                            if ( this.entries.containsKey( entryPath ) ) {
                                if ( modified( entries.get( entryPath ), this.entries.remove( entryPath ) ) ) {
                                    addModifyEvent( entryPath );
                                }
                            }
                            else {
                                addCreateEvent( entryPath );
                            }
                        }
                        for ( UnixSshPath entryPath : this.entries.keySet() ) {
                            addDeleteEvent( entryPath );
                        }
                        this.entries = entries;
                    }
                }
                catch ( IOException e ) {
                    logger.error( "checking {} failed: {}", dir, e );
                    logger.debug( "checking directory failed: ", e );
                }

                try {
                    pollerLock.lock();
                    logger.trace( "poller entering await {} {}", pollingInterval, pollingIntervalTimeUnit );
                    runImmediately.await( pollingInterval, pollingIntervalTimeUnit );
                }
                finally {
                    pollerLock.unlock();
                }
            }
        }
        catch ( ClosedWatchServiceException e ) {
            logger.debug( "watch service was closed, so exit" );
        }
        catch ( InterruptedException e ) {
            // time to close out
            logger.debug( "interrupt caught, closing down poller" );
        }
        logger.info( "poller stopped for {}", dir );
    }