/** * Force an update of the cache to get the current value of the hostname. */ public void updateCache() { FutureTask<String> futureTask = new FutureTask<>(new HostRetriever()); try { new Thread(futureTask).start(); logger.debug("Updating the hostname cache"); hostname = futureTask.get(GET_HOSTNAME_TIMEOUT, TimeUnit.MILLISECONDS); expirationTimestamp = System.currentTimeMillis() + cacheDuration; } catch (Exception e) { futureTask.cancel(true); expirationTimestamp = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(1); logger.warn("Localhost hostname lookup failed, keeping the value '{}'", hostname, e); } }