[
https://issues.apache.org/jira/browse/HADOOP-12991?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Akira Ajisaka updated HADOOP-12991:
-----------------------------------
Hadoop Flags: Reviewed
Description:
HADOOP-12304 introduced logic to ensure that the {{DelegateToFileSystem}}
constructor sets the default port to -1:
{code:title=DelegateToFileSystem.java}
protected DelegateToFileSystem(URI theUri, FileSystem theFsImpl,
Configuration conf, String supportedScheme, boolean authorityRequired)
throws IOException, URISyntaxException {
super(theUri, supportedScheme, authorityRequired,
getDefaultPortIfDefined(theFsImpl));
fsImpl = theFsImpl;
fsImpl.initialize(theUri, conf);
fsImpl.statistics = getStatistics();
}
private static int getDefaultPortIfDefined(FileSystem theFsImpl) {
int defaultPort = theFsImpl.getDefaultPort();
return defaultPort != 0 ? defaultPort : -1;
}
{code}
However, {{DelegateToFileSystem#getUriDefaultPort}} returns 0:
{code:title=DelegateToFileSystem.java}
public int getUriDefaultPort() {
return 0;
}
{code}
This breaks {{AbstractFileSystem#checkPath}}:
{code:title=AbstractFileSystem.java}
int thisPort = this.getUri().getPort(); // If using DelegateToFileSystem,
this is -1
int thatPort = uri.getPort(); // This is -1 by default in java.net.URI
if (thatPort == -1) {
thatPort = this.getUriDefaultPort(); // Sets thatPort to 0
}
if (thisPort != thatPort) {
throw new InvalidPathException("Wrong FS: " + path + ", expected: "
+ this.getUri());
}
{code}
Which breaks any subclasses of {{DelegateToFileSystem}} that don't specify a
port.
was:
HADOOP-12304 introduced logic to ensure that the {{DelegateToFileSystem}}
constructor sets the default port to -1:
{code:title=DelegateToFileSystem.java}
protected DelegateToFileSystem(URI theUri, FileSystem theFsImpl,
Configuration conf, String supportedScheme, boolean authorityRequired)
throws IOException, URISyntaxException {
super(theUri, supportedScheme, authorityRequired,
getDefaultPortIfDefined(theFsImpl));
fsImpl = theFsImpl;
fsImpl.initialize(theUri, conf);
fsImpl.statistics = getStatistics();
}
private static int getDefaultPortIfDefined(FileSystem theFsImpl) {
int defaultPort = theFsImpl.getDefaultPort();
return defaultPort != 0 ? defaultPort : -1;
}
{code}
However, {{DelegateToFileSystem#getUriDefaultPort}} returns 0:
{code:title=DelegateToFileSystem.java}
public int getUriDefaultPort() {
return 0;
}
{code}
This breaks {{AbstractFileSystem#checkPath}}:
{code:title=AbstractFileSystem.java}
int thisPort = this.getUri().getPort(); // If using DelegateToFileSystem,
this is -1
int thatPort = uri.getPort(); // This is -1 by default in java.net.URI
if (thatPort == -1) {
thatPort = this.getUriDefaultPort(); // Sets thatPort to 0
}
if (thisPort != thatPort) {
throw new InvalidPathException("Wrong FS: " + path + ", expected: "
+ this.getUri());
}
{code}
Which breaks any subclasses of {{DelegateToFileSystem}} that don't specify a
port (S3n, Wasb(s)).
Updating the description to remove the example, because s3n is not a subclass
of DelegateToFileSystem and wasb has a default port.
> Conflicting default ports in DelegateToFileSystem
> -------------------------------------------------
>
> Key: HADOOP-12991
> URL: https://issues.apache.org/jira/browse/HADOOP-12991
> Project: Hadoop Common
> Issue Type: Bug
> Components: fs
> Affects Versions: 2.7.2
> Reporter: Kevin Hogeland
> Assignee: Kai Sasaki
> Attachments: HADOOP-12991.01.patch, HADOOP-12991.02.patch,
> HADOOP-12991.03.patch
>
>
> HADOOP-12304 introduced logic to ensure that the {{DelegateToFileSystem}}
> constructor sets the default port to -1:
> {code:title=DelegateToFileSystem.java}
> protected DelegateToFileSystem(URI theUri, FileSystem theFsImpl,
> Configuration conf, String supportedScheme, boolean authorityRequired)
> throws IOException, URISyntaxException {
> super(theUri, supportedScheme, authorityRequired,
> getDefaultPortIfDefined(theFsImpl));
> fsImpl = theFsImpl;
> fsImpl.initialize(theUri, conf);
> fsImpl.statistics = getStatistics();
> }
> private static int getDefaultPortIfDefined(FileSystem theFsImpl) {
> int defaultPort = theFsImpl.getDefaultPort();
> return defaultPort != 0 ? defaultPort : -1;
> }
> {code}
> However, {{DelegateToFileSystem#getUriDefaultPort}} returns 0:
> {code:title=DelegateToFileSystem.java}
> public int getUriDefaultPort() {
> return 0;
> }
> {code}
> This breaks {{AbstractFileSystem#checkPath}}:
> {code:title=AbstractFileSystem.java}
> int thisPort = this.getUri().getPort(); // If using DelegateToFileSystem,
> this is -1
> int thatPort = uri.getPort(); // This is -1 by default in java.net.URI
> if (thatPort == -1) {
> thatPort = this.getUriDefaultPort(); // Sets thatPort to 0
> }
> if (thisPort != thatPort) {
> throw new InvalidPathException("Wrong FS: " + path + ", expected: "
> + this.getUri());
> }
> {code}
> Which breaks any subclasses of {{DelegateToFileSystem}} that don't specify a
> port.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]