commit | bdc79300cd4103f0ca76f5d18a777e5ba9dc331a | [log] [tgz] |
---|---|---|
author | Hugo Arès <hugo.ares@ericsson.com> | Tue Apr 18 20:17:25 2017 -0400 |
committer | Hugo Arès <hugo.ares@ericsson.com> | Wed Apr 19 00:21:34 2017 +0000 |
tree | 7b1cdb0d0f1f377fd12720410fccd2d442c5d7c3 | |
parent | 8ecdcc0f8635f2746cff142cbf93ffd1f51a8324 [diff] |
Use path.toFile().exists() instead of Files.exists(path) According to SonarQube: The Files.exists method has noticeably poor performance in JDK 8, and can slow an application significantly when used to check files that don't actually exist. The same goes for Files.notExists, Files.isDirectory and Files.isRegularFile. Change-Id: I061630e5ba7daeccb4576dc6317230d960006716
diff --git a/src/main/java/com/ericsson/gerrit/plugins/highavailability/websession/file/FileBasedWebsessionCache.java b/src/main/java/com/ericsson/gerrit/plugins/highavailability/websession/file/FileBasedWebsessionCache.java index 5a356a7..b162141 100644 --- a/src/main/java/com/ericsson/gerrit/plugins/highavailability/websession/file/FileBasedWebsessionCache.java +++ b/src/main/java/com/ericsson/gerrit/plugins/highavailability/websession/file/FileBasedWebsessionCache.java
@@ -181,7 +181,7 @@ } private Val readFile(Path path) { - if (Files.exists(path)) { + if (path.toFile().exists()) { try (InputStream fileStream = Files.newInputStream(path); ObjectInputStream objStream = new ObjectInputStream(fileStream)) { return (Val) objStream.readObject();