You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-dev@hadoop.apache.org by Simon Scott <Si...@viavisolutions.com> on 2017/03/03 13:30:27 UTC
FsUrlStreamHandlerFactory and Windows file URLs
Apologies if this an old topic, however the following test program:
package com.viavi;
import org.apache.hadoop.fs.FsUrlStreamHandlerFactory;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
public class Main {
public static void main(String[] args) {
System.out.println("URI is " + makeURI());
URL.setURLStreamHandlerFactory(new FsUrlStreamHandlerFactory());
System.out.println("URI is " + makeURI());
}
private static URI makeURI() {
try {
File file = new File("C:/Users");
final URL url = new URL("file:///" + file.getAbsolutePath());
return url.toURI();
} catch (MalformedURLException x) {
x.printStackTrace();
return null;
} catch (URISyntaxException x) {
x.printStackTrace();
return null;
}
}
}
gives the following output:
URI is file:/C:/Users
URI is null
java.net.URISyntaxException: Illegal character in path at index 8: file:/C:\Users
at java.net.URI$Parser.fail(URI.java:2848)
at java.net.URI$Parser.checkChars(URI.java:3021)
at java.net.URI$Parser.parseHierarchical(URI.java:3105)
at java.net.URI$Parser.parse(URI.java:3053)
at java.net.URI.<init>(URI.java:588)
at java.net.URL.toURI(URL.java:946)
at com.viavi.Main.makeURI(Main.java:23)
at com.viavi.Main.main(Main.java:16)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
That is, it seems that registering the FsUrlStreamHandlerFactory disrupts the subsequent creation of Windows "file" URLs.
I encountered this on 2.6.5, and have reproduced in 3.0.0 - alpha2.
I believe I have a fair understanding of the root of the issue. Is this of interest to anybody?
Thanks
Simon
Re: FsUrlStreamHandlerFactory and Windows file URLs
Posted by Steve Loughran <st...@hortonworks.com>.
> On 6 Mar 2017, at 09:10, Simon Scott <Si...@viavisolutions.com> wrote:
>
> Yes it is. But the registration of the FsUrlStreamHandlerFactory has surely influenced the JDK in some manner?
>
Not at that point, I don't think. Why not comment out the hadoop code and rerun
'
> -----Original Message-----
> From: Steve Loughran [mailto:stevel@hortonworks.com]
> Sent: 03 March 2017 21:49
> Cc: common-dev@hadoop.apache.org
> Subject: Re: FsUrlStreamHandlerFactory and Windows file URLs
>
> That stack trace is coming from the java code before it his Hadoop
>
>> On 3 Mar 2017, at 13:30, Simon Scott <Si...@viavisolutions.com> wrote:
>>
>> Apologies if this an old topic, however the following test program:
>>
>> package com.viavi;
>>
>> import org.apache.hadoop.fs.FsUrlStreamHandlerFactory;
>>
>> import java.io.File;
>> import java.net.MalformedURLException; import java.net.URI; import
>> java.net.URISyntaxException; import java.net.URL;
>>
>> public class Main {
>>
>> public static void main(String[] args) {
>> System.out.println("URI is " + makeURI());
>> URL.setURLStreamHandlerFactory(new FsUrlStreamHandlerFactory());
>> System.out.println("URI is " + makeURI());
>> }
>>
>> private static URI makeURI() {
>> try {
>> File file = new File("C:/Users");
>> final URL url = new URL("file:///" + file.getAbsolutePath());
>> return url.toURI(); ** HERE**
>
>
> Ty creating the URI via File.toURI();
>
>
>
>
>> } catch (MalformedURLException x) {
>> x.printStackTrace();
>> return null;
>> } catch (URISyntaxException x) {
>> x.printStackTrace();
>> return null;
>> }
>> }
>> }
>>
>> gives the following output:
>>
>> URI is file:/C:/Users
>> URI is null
>> java.net.URISyntaxException: Illegal character in path at index 8: file:/C:\Users
>> at java.net.URI$Parser.fail(URI.java:2848)
>> at java.net.URI$Parser.checkChars(URI.java:3021)
>> at java.net.URI$Parser.parseHierarchical(URI.java:3105)
>> at java.net.URI$Parser.parse(URI.java:3053)
>> at java.net.URI.<init>(URI.java:588)
>> at java.net.URL.toURI(URL.java:946)
>> at com.viavi.Main.makeURI(Main.java:23)
>> at com.viavi.Main.main(Main.java:16)
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>> at java.lang.reflect.Method.invoke(Method.java:498)
>> at
>> com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
>>
>> That is, it seems that registering the FsUrlStreamHandlerFactory disrupts the subsequent creation of Windows "file" URLs.
>> I encountered this on 2.6.5, and have reproduced in 3.0.0 - alpha2.
>>
>> I believe I have a fair understanding of the root of the issue. Is this of interest to anybody?
>>
>> Thanks
>> Simon
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: common-dev-unsubscribe@hadoop.apache.org
> For additional commands, e-mail: common-dev-help@hadoop.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: common-dev-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-dev-help@hadoop.apache.org
RE: FsUrlStreamHandlerFactory and Windows file URLs
Posted by Simon Scott <Si...@viavisolutions.com>.
Yes it is. But the registration of the FsUrlStreamHandlerFactory has surely influenced the JDK in some manner?
-----Original Message-----
From: Steve Loughran [mailto:stevel@hortonworks.com]
Sent: 03 March 2017 21:49
Cc: common-dev@hadoop.apache.org
Subject: Re: FsUrlStreamHandlerFactory and Windows file URLs
That stack trace is coming from the java code before it his Hadoop
> On 3 Mar 2017, at 13:30, Simon Scott <Si...@viavisolutions.com> wrote:
>
> Apologies if this an old topic, however the following test program:
>
> package com.viavi;
>
> import org.apache.hadoop.fs.FsUrlStreamHandlerFactory;
>
> import java.io.File;
> import java.net.MalformedURLException; import java.net.URI; import
> java.net.URISyntaxException; import java.net.URL;
>
> public class Main {
>
> public static void main(String[] args) {
> System.out.println("URI is " + makeURI());
> URL.setURLStreamHandlerFactory(new FsUrlStreamHandlerFactory());
> System.out.println("URI is " + makeURI());
> }
>
> private static URI makeURI() {
> try {
> File file = new File("C:/Users");
> final URL url = new URL("file:///" + file.getAbsolutePath());
> return url.toURI(); ** HERE**
Ty creating the URI via File.toURI();
> } catch (MalformedURLException x) {
> x.printStackTrace();
> return null;
> } catch (URISyntaxException x) {
> x.printStackTrace();
> return null;
> }
> }
> }
>
> gives the following output:
>
> URI is file:/C:/Users
> URI is null
> java.net.URISyntaxException: Illegal character in path at index 8: file:/C:\Users
> at java.net.URI$Parser.fail(URI.java:2848)
> at java.net.URI$Parser.checkChars(URI.java:3021)
> at java.net.URI$Parser.parseHierarchical(URI.java:3105)
> at java.net.URI$Parser.parse(URI.java:3053)
> at java.net.URI.<init>(URI.java:588)
> at java.net.URL.toURI(URL.java:946)
> at com.viavi.Main.makeURI(Main.java:23)
> at com.viavi.Main.main(Main.java:16)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:498)
> at
> com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
>
> That is, it seems that registering the FsUrlStreamHandlerFactory disrupts the subsequent creation of Windows "file" URLs.
> I encountered this on 2.6.5, and have reproduced in 3.0.0 - alpha2.
>
> I believe I have a fair understanding of the root of the issue. Is this of interest to anybody?
>
> Thanks
> Simon
>
---------------------------------------------------------------------
To unsubscribe, e-mail: common-dev-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-dev-help@hadoop.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: common-dev-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-dev-help@hadoop.apache.org
Re: FsUrlStreamHandlerFactory and Windows file URLs
Posted by Steve Loughran <st...@hortonworks.com>.
That stack trace is coming from the java code before it his Hadoop
> On 3 Mar 2017, at 13:30, Simon Scott <Si...@viavisolutions.com> wrote:
>
> Apologies if this an old topic, however the following test program:
>
> package com.viavi;
>
> import org.apache.hadoop.fs.FsUrlStreamHandlerFactory;
>
> import java.io.File;
> import java.net.MalformedURLException;
> import java.net.URI;
> import java.net.URISyntaxException;
> import java.net.URL;
>
> public class Main {
>
> public static void main(String[] args) {
> System.out.println("URI is " + makeURI());
> URL.setURLStreamHandlerFactory(new FsUrlStreamHandlerFactory());
> System.out.println("URI is " + makeURI());
> }
>
> private static URI makeURI() {
> try {
> File file = new File("C:/Users");
> final URL url = new URL("file:///" + file.getAbsolutePath());
> return url.toURI(); ** HERE**
Ty creating the URI via File.toURI();
> } catch (MalformedURLException x) {
> x.printStackTrace();
> return null;
> } catch (URISyntaxException x) {
> x.printStackTrace();
> return null;
> }
> }
> }
>
> gives the following output:
>
> URI is file:/C:/Users
> URI is null
> java.net.URISyntaxException: Illegal character in path at index 8: file:/C:\Users
> at java.net.URI$Parser.fail(URI.java:2848)
> at java.net.URI$Parser.checkChars(URI.java:3021)
> at java.net.URI$Parser.parseHierarchical(URI.java:3105)
> at java.net.URI$Parser.parse(URI.java:3053)
> at java.net.URI.<init>(URI.java:588)
> at java.net.URL.toURI(URL.java:946)
> at com.viavi.Main.makeURI(Main.java:23)
> at com.viavi.Main.main(Main.java:16)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:498)
> at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
>
> That is, it seems that registering the FsUrlStreamHandlerFactory disrupts the subsequent creation of Windows "file" URLs.
> I encountered this on 2.6.5, and have reproduced in 3.0.0 - alpha2.
>
> I believe I have a fair understanding of the root of the issue. Is this of interest to anybody?
>
> Thanks
> Simon
>
---------------------------------------------------------------------
To unsubscribe, e-mail: common-dev-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-dev-help@hadoop.apache.org