changeset 13369:f69991f67a2e

8131146: "java.lang.RuntimeException: java.io.UTFDataFormatException: malformed input around byte 10" when querying jrt-fs Reviewed-by: jlaskey
author sundar
date Wed, 15 Jul 2015 10:06:11 +0530
parents 0560e00dfa35
children 284b928a4f8f
files src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java test/jdk/internal/jrtfs/Basic.java
diffstat 2 files changed, 20 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java	Tue Jul 14 17:36:37 2015 +0100
+++ b/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java	Wed Jul 15 10:06:11 2015 +0530
@@ -39,6 +39,7 @@
 import java.nio.file.FileSystemException;
 import java.nio.file.FileSystemNotFoundException;
 import java.nio.file.Files;
+import java.nio.file.InvalidPathException;
 import java.nio.file.NoSuchFileException;
 import java.nio.file.NotDirectoryException;
 import java.nio.file.OpenOption;
@@ -280,8 +281,12 @@
 
     private NodeAndImage lookup(byte[] path) {
         ImageReader image = bootImage;
-        Node node = bootImage.findNode(path);
-
+        Node node;
+        try {
+            node = bootImage.findNode(path);
+        } catch (RuntimeException re) {
+            throw new InvalidPathException(getString(path), re.toString());
+        }
         return node != null? new NodeAndImage(node, image) : null;
     }
 
--- a/test/jdk/internal/jrtfs/Basic.java	Tue Jul 14 17:36:37 2015 +0100
+++ b/test/jdk/internal/jrtfs/Basic.java	Wed Jul 15 10:06:11 2015 +0530
@@ -30,6 +30,7 @@
 import java.io.InputStream;
 import java.io.DataInputStream;
 import java.nio.file.DirectoryStream;
+import java.nio.file.InvalidPathException;
 import java.nio.file.Files;
 import java.nio.file.FileSystem;
 import java.nio.file.FileSystems;
@@ -566,4 +567,16 @@
         assertTrue(javaSeen);
         assertTrue(javaxSeen);
     }
+
+    @Test
+    public void invalidPathTest() {
+        FileSystem fs = FileSystems.getFileSystem(URI.create("jrt:/"));
+        InvalidPathException ipe = null;
+        try {
+            Files.exists(fs.getPath("/packages/\ud834\udd7b"));
+        } catch (InvalidPathException e) {
+            ipe = e;
+        }
+        assertTrue(ipe != null);
+    }
 }