RFR 8189657: LineBrokenMultiByteCharacter.java fails on some systems that does not accept a non-ASCII char in Path

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

RFR 8189657: LineBrokenMultiByteCharacter.java fails on some systems that does not accept a non-ASCII char in Path

Weijun Wang
Please review this patch:

$ hg qdiff -wb
diff --git a/test/lib/jdk/test/lib/util/JarUtils.java b/test/lib/jdk/test/lib/util/JarUtils.java
--- a/test/lib/jdk/test/lib/util/JarUtils.java
+++ b/test/lib/jdk/test/lib/util/JarUtils.java
@@ -28,6 +28,7 @@
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.nio.file.Files;
+import java.nio.file.InvalidPathException;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.Enumeration;
@@ -88,12 +89,17 @@
             if (file.equals("-")) {
                 update = false;
             } else if (update) {
+                try {
                 Path p = Paths.get(file);
                 if (Files.exists(p)) {
                     changes.put(file, p);
                 } else {
                     changes.put(file, file);
                 }
+                } catch (InvalidPathException e) {
+                    // Fallback if file not a valid Path.
+                    changes.put(file, file);
+                }
             } else {
                 changes.put(file, Boolean.FALSE);
             }

This is a part of the JarUtils::updateJar method. When it adds a new entry into a jar, it will add the actual file if a file with the entry name exists, and fabricate some content if not. Unfortunately just creating a Path object on some systems would fail.

Noreg-self.

Thanks
Max

Reply | Threaded
Open this post in threaded view
|

Re: RFR 8189657: LineBrokenMultiByteCharacter.java fails on some systems that does not accept a non-ASCII char in Path

Weijun Wang
False alarm! Turns out I introduced the bug in another change I am still working on. I'll close this bug.

--Max

> On Oct 19, 2017, at 2:45 PM, Weijun Wang <[hidden email]> wrote:
>
> Please review this patch:
>
> $ hg qdiff -wb
> diff --git a/test/lib/jdk/test/lib/util/JarUtils.java b/test/lib/jdk/test/lib/util/JarUtils.java
> --- a/test/lib/jdk/test/lib/util/JarUtils.java
> +++ b/test/lib/jdk/test/lib/util/JarUtils.java
> @@ -28,6 +28,7 @@
> import java.io.FileOutputStream;
> import java.io.IOException;
> import java.nio.file.Files;
> +import java.nio.file.InvalidPathException;
> import java.nio.file.Path;
> import java.nio.file.Paths;
> import java.util.Enumeration;
> @@ -88,12 +89,17 @@
>             if (file.equals("-")) {
>                 update = false;
>             } else if (update) {
> +                try {
>                 Path p = Paths.get(file);
>                 if (Files.exists(p)) {
>                     changes.put(file, p);
>                 } else {
>                     changes.put(file, file);
>                 }
> +                } catch (InvalidPathException e) {
> +                    // Fallback if file not a valid Path.
> +                    changes.put(file, file);
> +                }
>             } else {
>                 changes.put(file, Boolean.FALSE);
>             }
>
> This is a part of the JarUtils::updateJar method. When it adds a new entry into a jar, it will add the actual file if a file with the entry name exists, and fabricate some content if not. Unfortunately just creating a Path object on some systems would fail.
>
> Noreg-self.
>
> Thanks
> Max
>