mirror of https://github.com/apache/lucene.git
Make RAMDirectory's touchFile method wait long enough for the system clock
to register a new timestamp. This makes locking logic more robust. git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@150065 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
28ef35ee3e
commit
250f13e99c
|
@ -146,8 +146,23 @@ public final class RAMDirectory extends Directory {
|
||||||
|
|
||||||
/** Set the modified time of an existing file to now. */
|
/** Set the modified time of an existing file to now. */
|
||||||
public void touchFile(String name) throws IOException {
|
public void touchFile(String name) throws IOException {
|
||||||
|
final boolean MONITOR = false;
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
RAMFile file = (RAMFile)files.get(name);
|
RAMFile file = (RAMFile)files.get(name);
|
||||||
file.lastModified = System.currentTimeMillis();
|
long ts2, ts1 = System.currentTimeMillis();
|
||||||
|
do {
|
||||||
|
try {
|
||||||
|
Thread.sleep(0, 1);
|
||||||
|
} catch (InterruptedException e) {}
|
||||||
|
ts2 = System.currentTimeMillis();
|
||||||
|
if (MONITOR) count ++;
|
||||||
|
} while(ts1 == ts2);
|
||||||
|
|
||||||
|
file.lastModified = ts2;
|
||||||
|
|
||||||
|
if (MONITOR)
|
||||||
|
System.out.println("SLEEP COUNT: " + count);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the length in bytes of a file in the directory. */
|
/** Returns the length in bytes of a file in the directory. */
|
||||||
|
|
Loading…
Reference in New Issue