Review request for #7087549

Alan Bateman Alan.Bateman at oracle.com
Mon Dec 12 02:14:11 PST 2011


On 09/12/2011 20:59, Brandon Passanisi wrote:
> Hi Alan.  I believe I understand the intention now.  Are you 
> suggesting the following:
>
>  1. Change the last line of newInputStream (line 384 in the webrev
>     version of FileSystemProvider.java) so that the options parameter
>     is passed into the Files.newByteChannel() call, i.e.: return
>     Channels.newInputStream(Files.newByteChannel(path, options));
>  2. Since the null check is done by newByteChannel, remove the
>     Objects.requireNonNull call.
>
> If this is correct, I can create an updated webrev for review.
Exactly! The bug is only an issue for providers that support additional 
open options but don't override newInputStream. With the above changes 
then the opens are passed through to newByteChannel so the provider can 
handle them. With that clear then I think the test should be focused on 
exercising newInputStream with custom options, something like the following:

     static enum CustomOptions implements OpenOption {
         IGNORE,
     }

     static class MyProvider extends 
PassThroughFileSystem.PassThroughProvider {
         public MyProvider() {
         }
         public InputStream newInputStream(Path path, OpenOption... options)
             throws IOException
         {
             if (options.length != 1)
                 throw new RuntimeException("One option expected");
             if (options[0] != CustomOptions.IGNORE)
                 throw new RuntimeException(options[0] + " not expected");
             return super.newInputStream(path);
         }
     }

     public static void main(String[] args) throws Exception {
         FileSystemProvider provider = new MyProvider();
         Map<String,?> env = Collections.emptyMap();
         URI uri = URI.create("pass:///");
         FileSystem fs = provider.newFileSystem(uri, env);

         :
         InputStream in = Files.newInputStream(path, CustomOptions.IGNORE);
     }

PassThroughFileSystem is in test/java/nio/file/Files and is used by 
tests that need to use a custom file system.

-Alan


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20111212/4f20601b/attachment.html 


More information about the nio-dev mailing list