Skip to content

Conversation

rice668
Copy link

@rice668 rice668 commented Jun 22, 2017

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 into flink-1.3.1%202 and then the system can not find the path.

@rice668
Copy link
Author

rice668 commented Jun 22, 2017

Hi @twalthr , you can test it again. I think it works fine now.

@zentol
Copy link
Contributor

zentol commented Jun 22, 2017

I doubt this fixes the underlying issue, it just masks it by storing the input files in paths containing spaces.

@rice668
Copy link
Author

rice668 commented Jun 22, 2017

I dont think it has an underlying issue as below line of code throw an error, and it is not relavant to the TextInputFormat class . tmpDir has spaces and then trigger that problem. If my understanding is wrong, please help me out.

File tempFile = File.createTempFile("TextInputFormatTest", ".tmp", tmpDir);

@rice668
Copy link
Author

rice668 commented Jun 22, 2017

Oops. I might be wrong. I will check again.

@rice668
Copy link
Author

rice668 commented Jun 23, 2017

Thanks @twalthr for reporting this VERY good issue. And thanks @zentol for looking over it. PR has been updated. I misread the error from JIRA before , so literally used trim() to solve and it was proved to be wrong.


final Path path = this.filePath;

final Path path = new Path(URLDecoder.decode(this.filePath.toString(), Charset.defaultCharset().name()));
Copy link
Contributor

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.

Copy link
Author

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.

Copy link
Contributor

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.

Copy link
Author

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().

Copy link
Author

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

Copy link
Contributor

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.

Copy link
Author

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.

Copy link
Author

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());

  1. Output: file:/D:/projects/hello%20world/

System.out.println(parentDirTest.toURI().toString());

  1. Output: file:/D:/projects/hello%20world/

System.out.println(new Path(parentDirTest.toURI()));

  1. Output: file:/D:/projects/hello world/

System.out.println(new Path(parentDirTest.toURI().toString()));

  1. Output: file:/D:/projects/hello%20world

Copy link
Contributor

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh. I see, thanks.

@rice668 rice668 force-pushed the flink-6987 branch 6 times, most recently from c925dbb to c09c502 Compare June 23, 2017 11:55
@zentol
Copy link
Contributor

zentol commented Jun 27, 2017

merging.

zentol pushed a commit to zentol/flink that referenced this pull request Jun 27, 2017
zentol pushed a commit to zentol/flink that referenced this pull request Jun 27, 2017
zentol pushed a commit to zentol/flink that referenced this pull request Jun 27, 2017
zentol pushed a commit to zentol/flink that referenced this pull request Jun 27, 2017
zentol pushed a commit to zentol/flink that referenced this pull request Jun 28, 2017
zentol pushed a commit to zentol/flink that referenced this pull request Jun 28, 2017
zentol pushed a commit to zentol/flink that referenced this pull request Jun 28, 2017
zentol pushed a commit to zentol/flink that referenced this pull request Jun 29, 2017
zentol pushed a commit to zentol/flink that referenced this pull request Jun 29, 2017
zentol pushed a commit to zentol/flink that referenced this pull request Jun 30, 2017
@asfgit asfgit closed this in c84a828 Jul 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants