aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok
diff options
context:
space:
mode:
authorRoel Spilker <r.spilker@gmail.com>2014-01-15 21:28:31 +0100
committerRoel Spilker <r.spilker@gmail.com>2014-01-15 21:28:31 +0100
commitb6afe56dc25c982d471cf17ec4102a643613237e (patch)
tree84531d104dc547cd6bb62b4491c0060ae8ba318e /src/core/lombok
parentbb56c53547256f6ea828ef39ebb26a3af553a82e (diff)
downloadlombok-b6afe56dc25c982d471cf17ec4102a643613237e.tar.gz
lombok-b6afe56dc25c982d471cf17ec4102a643613237e.tar.bz2
lombok-b6afe56dc25c982d471cf17ec4102a643613237e.zip
[configuration] Use URI in the API instead of files. Null results in an empty Iterable. Some improvements on the time-out code
Diffstat (limited to 'src/core/lombok')
-rw-r--r--src/core/lombok/core/configuration/FileSystemSourceCache.java12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/core/lombok/core/configuration/FileSystemSourceCache.java b/src/core/lombok/core/configuration/FileSystemSourceCache.java
index 50a3bac7..c329b435 100644
--- a/src/core/lombok/core/configuration/FileSystemSourceCache.java
+++ b/src/core/lombok/core/configuration/FileSystemSourceCache.java
@@ -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;
}
}