FS: ignore AccessDeniedException when measuring timestamp resolution
It seems on cygwin creating a file under a writable directory can fail with AccessDeniedException. Log a warning in this case and fallback to worst case timestamp resolution of 2 seconds. Bug: 548648 Change-Id: Ic50c31ce9dc9ccadd4db5247df929418ac62d45c Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
parent
09fec1a102
commit
be66222d1a
|
@ -56,6 +56,7 @@
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
import java.nio.file.AccessDeniedException;
|
||||||
import java.nio.file.FileStore;
|
import java.nio.file.FileStore;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
@ -312,6 +313,8 @@ private static Optional<Duration> measureFsTimestampResolution(
|
||||||
Duration resolution = Duration.between(t1.toInstant(), t2.toInstant());
|
Duration resolution = Duration.between(t1.toInstant(), t2.toInstant());
|
||||||
saveFileTimeResolution(s, resolution);
|
saveFileTimeResolution(s, resolution);
|
||||||
return Optional.of(resolution);
|
return Optional.of(resolution);
|
||||||
|
} catch (AccessDeniedException e) {
|
||||||
|
LOG.warn(e.getLocalizedMessage(), e); // see bug 548648
|
||||||
} catch (IOException | TimeoutException e) {
|
} catch (IOException | TimeoutException e) {
|
||||||
LOG.error(e.getLocalizedMessage(), e);
|
LOG.error(e.getLocalizedMessage(), e);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
|
Loading…
Reference in New Issue