@ SuppressWarnings ( "PMD.EmptyCatchBlock" ) private synchronized void cleanup ( final WatchKey key ) { logger . trace ( "cleanUp {}" , key ) ; try { key . cancel ( ) ; } catch ( Exception ex ) { //trap } Collection < SFMF4JWatchListener > listeners = listenersByWatchKey . remove ( key ) ; if ( listeners != null && ! listeners . isEmpty ( ) ) { logger . warn ( "Cleaning up key but listeners are still registered." ) ; } String path = pathsByWatchKey . remove ( key ) ; if ( path != null ) { watchKeysByPath . remove ( path ) ; } }
Properly unregisters and removes a watch key .