src/jdk.dns.client/share/classes/jdk/dns/client/internal/util/ReloadTracker.java
branchaefimov-dns-client-branch
changeset 59101 258033faefc9
parent 58870 35c438a6d45c
--- a/src/jdk.dns.client/share/classes/jdk/dns/client/internal/util/ReloadTracker.java	Thu Nov 14 23:13:47 2019 +0000
+++ b/src/jdk.dns.client/share/classes/jdk/dns/client/internal/util/ReloadTracker.java	Thu Nov 14 23:16:40 2019 +0000
@@ -25,20 +25,18 @@
 
 package jdk.dns.client.internal.util;
 
-import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
 import java.util.concurrent.atomic.AtomicLong;
 
 public class ReloadTracker {
 
-    public static ReloadTracker newInstance(Path fileToTrack, long refreshTimeoutMillis) {
+    public static ReloadTracker newInstance(Path fileToTrack, long refreshTimeoutNanos) {
         Path absolutePath = fileToTrack.toAbsolutePath();
-        return new ReloadTracker(absolutePath, refreshTimeoutMillis);
+        return new ReloadTracker(absolutePath, refreshTimeoutNanos);
     }
 
     public static class ReloadStatus {
@@ -66,9 +64,9 @@
     }
 
 
-    private ReloadTracker(Path filePath, long refreshTimeoutMillis) {
+    private ReloadTracker(Path filePath, long refreshTimeoutNanos) {
         this.filePath = filePath;
-        this.refreshTimeoutMillis = refreshTimeoutMillis;
+        this.refreshTimeoutNanos = refreshTimeoutNanos;
     }
 
 
@@ -92,13 +90,13 @@
         }
         return new ReloadStatus(fileExists,
                 (lastModificationTime != lastSeenChanged.get()) ||
-                        (System.currentTimeMillis() - lastReload > refreshTimeoutMillis),
+                        (System.nanoTime() - lastReload > refreshTimeoutNanos),
                 lastModificationTime);
     }
 
     public void updateTimestamps(ReloadStatus rs) {
         lastSeenChanged.set(rs.lastModificationTimestamp);
-        lastRefreshed.set(System.currentTimeMillis());
+        lastRefreshed.set(System.nanoTime());
     }
 
     // Last timestamp when tracked file has been reloaded by consumer of this utility class
@@ -106,7 +104,7 @@
     // Last processed FS last modified timestamp
     private final AtomicLong lastSeenChanged = new AtomicLong(-1);
     // Refresh timeout
-    private final long refreshTimeoutMillis;
+    private final long refreshTimeoutNanos;
     // Path of the tracked file
     private final Path filePath;
 }