提交 5c0bf4d0 编写于 作者: A alanb

8037945: Paths.get("").normalize() throws ArrayIndexOutOfBoundsException

Reviewed-by: chegar
上级 c81ad67d
...@@ -482,7 +482,7 @@ class UnixPath ...@@ -482,7 +482,7 @@ class UnixPath
@Override @Override
public Path normalize() { public Path normalize() {
final int count = getNameCount(); final int count = getNameCount();
if (count == 0) if (count == 0 || isEmpty())
return this; return this;
boolean[] ignore = new boolean[count]; // true => ignore name boolean[] ignore = new boolean[count]; // true => ignore name
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
*/ */
/* @test /* @test
* @bug 4313887 6838333 6925932 7006126 * @bug 4313887 6838333 6925932 7006126 8037945
* @summary Unit test for java.nio.file.Path path operations * @summary Unit test for java.nio.file.Path path operations
*/ */
...@@ -899,6 +899,8 @@ public class PathOps { ...@@ -899,6 +899,8 @@ public class PathOps {
.normalize("foo"); .normalize("foo");
test("/foo") test("/foo")
.normalize("/foo"); .normalize("/foo");
test("")
.normalize("");
test(".") test(".")
.normalize(""); .normalize("");
test("..") test("..")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册