-
Notifications
You must be signed in to change notification settings - Fork 13.7k
[FLINK-6987] Fix erroneous when path containing spaces #4168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Hi @twalthr , you can test it again. I think it works fine now. |
I doubt this fixes the underlying issue, it just masks it by storing the input files in paths containing spaces. |
I dont think it has an underlying issue as below line of code throw an error, and it is not relavant to the
|
Oops. I might be wrong. I will check again. |
|
||
final Path path = this.filePath; | ||
|
||
final Path path = new Path(URLDecoder.decode(this.filePath.toString(), Charset.defaultCharset().name())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty sure this fails on windows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean ? My computer is windows and operation system belongs to windows 7. I didnt get any error with this line of code and with a folder called flink-1.3.1 2
to build it with test. Test passed with flink-1.3.1 2
when build flink.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typically, when going from flink paths to Strings to jave file API's on Windows you get exceptions since Flink paths on Windows always start with a "/". But this call never goes through the file API, hence it does succeed.
Anyway, an easier solution is to simply not call URI#toString
when calling the Path
constructor in the tests. Then the spaces aren't escaped and the tests succeed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An awesome solution always welcomed. I can literally use parentDir.toString()
to avoid that issue. Not to call parentDir.toURI().toString().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can also use parentDir.getAbsoluteFile().toString()
to hack that. Not very sure about which way is better. I would think parentDir.getAbsoluteFile().toString()
is better as it can obtain the whole path. What do you think ? @zentol
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would keep the conversion to an URI for the sake of making less changes to the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh. Yeah. You are very correct, we need make the less changes to test. PR will update soon today.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated the code. Please check again. One thing we should concern though.
FYI, though, it is not very relevant to this issue here.
We can see, for 1 and 2 output results, they are both the same. That is to say, call toString()
from toURI()
does not change the internal of the result. But, if we call them in context of flink.core.fs.Path
. what I got is 3 and 4 outputs. It seems new Path
change someting stuff. I guess that we should expect that not happen under this context. Instead, I expect new Path(parentDirTest.toURI().toString())
return the same value as new Path(parentDirTest.toURI())
. Now, they are not equal.
File parentDirTest = new File("D:\\projects\\hello world");
System.out.println(parentDirTest.toURI());
- Output: file:/D:/projects/hello%20world/
System.out.println(parentDirTest.toURI().toString());
- Output: file:/D:/projects/hello%20world/
System.out.println(new Path(parentDirTest.toURI()));
- Output: file:/D:/projects/hello world/
System.out.println(new Path(parentDirTest.toURI().toString()));
- Output: file:/D:/projects/hello%20world
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That#s a problem of URI, not of the path class. URI#toString escapes certain characters (like spaces) but they aren't escaped internally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh. I see, thanks.
c925dbb
to
c09c502
Compare
merging. |
We will get an error
Reason: "Test erroneous"
when use a folder was called "flink-1.3.1 2" to build flink and in which contains spaces then that error was triggered. The reason is that the spaces will encode intoflink-1.3.1%202
and then the system can not find the path.