A DESCRIPTION OF THE PROBLEM :
I think it is very similar to https://bugs.java.com/bugdatabase/view_bug.do?bug_id=6925169.
Yet, 6925169 is marked as resolved where the bug still remains, hence a new bug report.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
On a linux machine:
Path a = Paths.get("./a")
Path b = Paths.get("b")
a.relativize(b)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
should something be along the lone of ../b or .././b
ACTUAL -
is ../../b which is wrong, would definitely not point to the same file if we would call
a.normalize().resolve(b.normalize())
assuming a and b are in folder /c/d then the above would result in /c/b instead of /c/d/b
---------- BEGIN SOURCE ----------
You can take it from above
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
call normalize() before calling relativize()
a.normalize().relativize(b) => ../b
FREQUENCY : always
I think it is very similar to https://bugs.java.com/bugdatabase/view_bug.do?bug_id=6925169.
Yet, 6925169 is marked as resolved where the bug still remains, hence a new bug report.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
On a linux machine:
Path a = Paths.get("./a")
Path b = Paths.get("b")
a.relativize(b)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
should something be along the lone of ../b or .././b
ACTUAL -
is ../../b which is wrong, would definitely not point to the same file if we would call
a.normalize().resolve(b.normalize())
assuming a and b are in folder /c/d then the above would result in /c/b instead of /c/d/b
---------- BEGIN SOURCE ----------
You can take it from above
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
call normalize() before calling relativize()
a.normalize().relativize(b) => ../b
FREQUENCY : always
- duplicates
-
JDK-8066943 (fs) Path.relativize() gives incorrect result for ".."
- Resolved