Reputation: 113
My file structure has a symbolic link to a directory /home/me/myDir -> /some/other/dir. This link gets updated by another process and the notifies my process. Upon notification I attempt to get the new canonical path:
public static String getPath()
{
File file = new File("/home/me/myDir");
if(file.exists())
{
try
{
String canonical = file.getCanonicalPath();
return canonical;
}
catch ...
}
}
The problem is that after the link is changed (an i have verified it changes) it is taking 3-5 times of calling the above getPath() method for to actually get the new path before that the previous path is returned. The only thing I can think of is that java might be optimizing this method and returning the old path. Any ideas or insight is greatly appreciated.
Upvotes: 9
Views: 8219