mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-14 12:16:49 +00:00
[configuration] Use URI in the API instead of files. Null results in an empty Iterable. Some improvements on the time-out code
This commit is contained in:
1 parent
bb56c53547
commit
b6afe56dc2
1 file changed
+8
-4
@@ -24,6 +24,8 @@ package lombok.core.configuration;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.net.URI;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -43,8 +45,9 @@ public class FileSystemSourceCache {
|
||||
this.reporterFactory = reporterFactory;
|
||||
}
|
||||
|
||||
public Iterable<ConfigurationSource> sourcesForJavaFile(File javaFile) {
|
||||
final File directory = new File(javaFile.toURI().normalize()).getParentFile();
|
||||
public Iterable<ConfigurationSource> sourcesForJavaFile(URI javaFile) {
|
||||
if (javaFile == null) return Collections.emptyList();
|
||||
final File directory = new File(javaFile.normalize()).getParentFile();
|
||||
return new Iterable<ConfigurationSource>() {
|
||||
@Override
|
||||
public Iterator<ConfigurationSource> iterator() {
|
||||
@@ -91,12 +94,13 @@ public class FileSystemSourceCache {
|
||||
|
||||
Content content = ensureContent(directory);
|
||||
synchronized (content) {
|
||||
if (content.lastChecked != MISSING && content.lastChecked - now < RECHECK_FILESYSTEM && getLastModified(configFile) == content.lastModified) {
|
||||
if (content.lastChecked != MISSING && now - content.lastChecked < RECHECK_FILESYSTEM && getLastModified(configFile) == content.lastModified) {
|
||||
return content.source;
|
||||
}
|
||||
content.lastChecked = now;
|
||||
long previouslyModified = content.lastModified;
|
||||
content.lastModified = getLastModified(configFile);
|
||||
content.source = content.lastModified == MISSING ? null : parse(configFile);
|
||||
if (content.lastModified != previouslyModified) content.source = content.lastModified == MISSING ? null : parse(configFile);
|
||||
return content.source;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user