RFR: 8235459: HttpRequest.BodyPublishers#ofFile(Path) assumes the default file system
    Anthony Vanelverdinghe 
    anthonyv.be at outlook.com
       
    Thu Mar  5 18:25:46 UTC 2020
    
    
  
Hi Julia
Here's some suggestions w.r.t. RequestPublishers.java:
For distinguishing the non-default filesystem case, an alternative to 
using the try-catch block
is an if-else block with the same check as is done in Path::toFile:
     if (path.getFileSystem() == FileSystems.getDefault())
When setting `length`, the catch clause can be limited to IOException, 
rather than Exception.
Maybe change the method `RuntimeException toUncheckedException(...)` to 
`void throwAsUncheckedException(...)`
and then instead of `throw toUncheckedException(...)` use 
`throwAsUncheckedException(...)`
Kind regards,
Anthony
On 05/03/2020 14:50, Julia Boes wrote:
> Hi,
>
> Please see this fix that adds support for non-default file systems to 
> the HttpClient. More specifically, the change is in 
> RequestPublishers.FilePublisher where an UnsupportedOperationException 
> is thrown if a java.io.File cannot be obtained. The exception is now 
> caught and a function is used to obtain an InputStream with a 
> privileged scope based on the captured AccessControlContext.
>
> Bug: https://bugs.openjdk.java.net/browse/JDK-8235459
>
> CSR: https://bugs.openjdk.java.net/browse/JDK-8240526
>
> Webrev: http://cr.openjdk.java.net/~jboes/webrevs/8235459/webrev.01/
>
> Tests were run with repeat 100 cross-platform. A similar change to the 
> receiving side is currently work in progress.
>
> Regards,
>
> Julia
>
>
>
    
    
More information about the net-dev
mailing list