public synchronized void removeRoot ( final WatchedDirectory pWatchedDirectory ) { requireNonNull ( pWatchedDirectory , WATCHED_DIRECTORY_IS_NULL ) ; final Object key = requireNonNull ( pWatchedDirectory . getKey ( ) , KEY_IS_NULL ) ; final Path directory = requireNonNull ( pWatchedDirectory . getDirectory ( ) , DIRECTORY_IS_NULL ) ; // It's already checked that nothing is null final DedicatedFileSystem fs = children . get ( directory . getFileSystem ( ) ) ; if ( fs == null ) { LOG . warn ( format ( "No dedicated file system registered! Path: %s" , directory ) ) ; } else { fs . unregisterRootDirectory ( pWatchedDirectory . getDirectory ( ) , pWatchedDirectory ) ; // IMPORTANT: remove watched-directory with key specified. watchedDirectories . remove ( key ) ; pWatchedDirectory . removeObserver ( this ) ; LOG . info ( "Removed [{}:{}]" , key , directory ) ; } }
discarded before another WatchedDirectory is being unregistered .