private String get() { long nowTime = timeSource.currentTimeMillis(); if (content == null || (updateCheckFrequency > 0 && (lastUpdateCheckTime + updateCheckFrequency) < nowTime)) { // Only check for file updates at preconfigured intervals. This prevents // overwhelming the file system while maintaining a reasonable update rate w/o // implementing a full event-driven mechanism. lastUpdateCheckTime = nowTime; File file = new File(filePath); if (fileHasChanged(file, lastModified)) { // Only reload file content if it's changed (or if it's the first // load, when this check will succeed). String newContent = getFileContent(file); if (newContent != null) { content = newContent; lastModified = file.lastModified(); } else if (content != null) { // Content existed before, file removed - log error. LOG.warning("File existed before but is now missing! Name: " + filePath); } } } return content; } }
private String get() { long nowTime = timeSource.currentTimeMillis(); if (content == null || (updateCheckFrequency > 0 && (lastUpdateCheckTime + updateCheckFrequency) < nowTime)) { // Only check for file updates at preconfigured intervals. This prevents // overwhelming the file system while maintaining a reasonable update rate w/o // implementing a full event-driven mechanism. lastUpdateCheckTime = nowTime; File file = new File(filePath); if (fileHasChanged(file, lastModified)) { // Only reload file content if it's changed (or if it's the first // load, when this check will succeed). String newContent = getFileContent(file); if (newContent != null) { content = newContent; lastModified = file.lastModified(); } else if (content != null) { // Content existed before, file removed - log error. LOG.warning("File existed before but is now missing! Name: " + filePath); } } } return content; } }
return null; if (fileHasChanged(file, lastModified)) {