fix a  a coding pattern that could possibly have security impact (#10136)

diff --git a/server/src/main/java/org/apache/iotdb/db/conf/directories/TierManager.java b/server/src/main/java/org/apache/iotdb/db/conf/directories/TierManager.java
index e4dafa2..c513d05 100644
--- a/server/src/main/java/org/apache/iotdb/db/conf/directories/TierManager.java
+++ b/server/src/main/java/org/apache/iotdb/db/conf/directories/TierManager.java
@@ -220,13 +220,12 @@
     if (!file.exists()) {
       return getTiersNum() - 1;
     }
-
-    String filePath;
+    Path filePath;
     try {
-      filePath = file.getCanonicalPath();
+      filePath = file.getCanonicalFile().toPath();
     } catch (IOException e) {
       logger.error("Fail to get canonical path of data dir {}", file, e);
-      filePath = file.getPath();
+      filePath = file.toPath();
     }
 
     for (Map.Entry<String, Integer> entry : seqDir2TierLevel.entrySet()) {