@Override
    @SuppressWarnings("FutureReturnValueIgnored")
    public void run() {
        if (shouldEnableWatchService()) {
            try {
                var key = (WatchKey) null;
                while ((key = watchService.take()) != null) {
                    val finalKey = key;
                    executorService.submit(() -> handleEvent(finalKey));
                    val valid = key.reset();
                    if (!valid) {
                        LOGGER.info("Directory key is no longer valid. Quitting watcher service");
                    }
                }
            } catch (final InterruptedException | ClosedWatchServiceException e) {
                LOGGER.trace(e.getMessage(), e);
                Thread.currentThread().interrupt();
            }
        }
    }
Control watch operations on paths and files as a service.

@author David Rodriguez
@since 5.2.0
core/cas-server-core-util-api/src/main/java/org/apereo/cas/util/io/PathWatcherService.java