@Override
    public void run() {
        try {
            boolean keyStoreUpdated = false;
            boolean trustStoreUpdated = false;
            ZonedDateTime keyStoreModificationDateTime = null;
            ZonedDateTime trustStoreModificationDateTime = null;

            // Check if the keyStore file still exists and compare its last_modified_time
            if (keyStore != null && Files.exists(keyStore)) {
                keyStoreModificationDateTime = getLastModifiedTime(keyStore);
                keyStoreUpdated = lastModifiedTimeKeyStore.isBefore(keyStoreModificationDateTime);
                if (keyStoreUpdated) {
                    logger.info("KeyStore file has been modified.");
                }
            }

            // Check if the trustStore file still exists and compare its last_modified_time
            if (trustStore != null && Files.exists(trustStore)) {
                trustStoreModificationDateTime = getLastModifiedTime(trustStore);
                trustStoreUpdated = lastModifiedTimeTrustStore.isBefore(trustStoreModificationDateTime);
                if (trustStoreUpdated) {
                    logger.info("TrustStore file has been modified.");
                }
            }

            // If one of the files was updated, execute
            if (keyStoreUpdated || trustStoreUpdated) {
                onModificationRunnable.run();

                if (keyStoreUpdated) {
                    lastModifiedTimeKeyStore = keyStoreModificationDateTime;
                    logger.info("Updated KeyStore configuration");
                }
                if (trustStoreUpdated) {
                    lastModifiedTimeTrustStore = trustStoreModificationDateTime;
                    logger.info("Updated TrustStore configuration");
                }
            }
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }
    }
Create a FileWatcher on keyStore/trustStore

@param keyStore               path to the keyStore file or null to ignore
@param trustStore             path to the trustStore file or null to ignore
@param onModificationRunnable function to run when a modification to the keyStore or trustStore is detected
gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/SSLStoreFilesModificationWatcher.java