You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by zhangminglei <gi...@git.apache.org> on 2017/06/22 16:06:52 UTC

[GitHub] flink pull request #4168: [FLINK-6987] Fix erroneous when path containing sp...

GitHub user zhangminglei opened a pull request:

    https://github.com/apache/flink/pull/4168

    [FLINK-6987] Fix erroneous when path containing spaces

    Thanks for contributing to Apache Flink. Before you open your pull request, please take the following check list into consideration.
    If your changes take all of the items into account, feel free to open your pull request. For more information and/or questions please refer to the [How To Contribute guide](http://flink.apache.org/how-to-contribute.html).
    In addition to going through the list, please provide a meaningful description of your changes.
    
    - [ ] General
      - The pull request references the related JIRA issue ("[FLINK-XXX] Jira title text")
      - The pull request addresses only one issue
      - Each commit in the PR has a meaningful commit message (including the JIRA id)
    
    - [ ] Documentation
      - Documentation has been added for new functionality
      - Old documentation affected by the pull request has been updated
      - JavaDoc for public methods has been added
    
    - [ ] Tests & Build
      - Functionality added by the pull request is covered by tests
      - `mvn clean verify` has been executed successfully locally or a Travis build has passed


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/zhangminglei/flink flink-6987

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/flink/pull/4168.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #4168
    
----
commit b146f8e085f45b801cb8411962c6e3cc95f206c9
Author: zhangminglei <zm...@163.com>
Date:   2017-06-22T16:05:44Z

    [FLINK-6987] Fix erroneous when path containing spaces

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4168: [FLINK-6987] Fix erroneous when path containing sp...

Posted by zentol <gi...@git.apache.org>.
Github user zentol commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4168#discussion_r123687252
  
    --- Diff: flink-core/src/main/java/org/apache/flink/api/common/io/FileInputFormat.java ---
    @@ -461,8 +463,9 @@ public LocatableInputSplitAssigner getInputSplitAssigner(FileInputSplit[] splits
     		
     		// take the desired number of splits into account
     		minNumSplits = Math.max(minNumSplits, this.numSplits);
    -		
    -		final Path path = this.filePath;
    +
    +		final Path path = new Path(URLDecoder.decode(this.filePath.toString(), Charset.defaultCharset().name()));
    --- End diff --
    
    Pretty sure this fails on windows.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4168: [FLINK-6987] Fix erroneous when path containing sp...

Posted by zhangminglei <gi...@git.apache.org>.
Github user zhangminglei commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4168#discussion_r123726433
  
    --- Diff: flink-core/src/main/java/org/apache/flink/api/common/io/FileInputFormat.java ---
    @@ -461,8 +463,9 @@ public LocatableInputSplitAssigner getInputSplitAssigner(FileInputSplit[] splits
     		
     		// take the desired number of splits into account
     		minNumSplits = Math.max(minNumSplits, this.numSplits);
    -		
    -		final Path path = this.filePath;
    +
    +		final Path path = new Path(URLDecoder.decode(this.filePath.toString(), Charset.defaultCharset().name()));
    --- End diff --
    
    An awesome solution always welcomed.  I can literally use ```parentDir.toString()``` to avoid that issue.  Not to call ```parentDir.toURI().toString().```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink issue #4168: [FLINK-6987] Fix erroneous when path containing spaces

Posted by zhangminglei <gi...@git.apache.org>.
Github user zhangminglei commented on the issue:

    https://github.com/apache/flink/pull/4168
  
    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);```
    
    



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4168: [FLINK-6987] Fix erroneous when path containing sp...

Posted by zhangminglei <gi...@git.apache.org>.
Github user zhangminglei commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4168#discussion_r123743180
  
    --- Diff: flink-core/src/main/java/org/apache/flink/api/common/io/FileInputFormat.java ---
    @@ -461,8 +463,9 @@ public LocatableInputSplitAssigner getInputSplitAssigner(FileInputSplit[] splits
     		
     		// take the desired number of splits into account
     		minNumSplits = Math.max(minNumSplits, this.numSplits);
    -		
    -		final Path path = this.filePath;
    +
    +		final Path path = new Path(URLDecoder.decode(this.filePath.toString(), Charset.defaultCharset().name()));
    --- End diff --
    
    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 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4168: [FLINK-6987] Fix erroneous when path containing sp...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/flink/pull/4168


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4168: [FLINK-6987] Fix erroneous when path containing sp...

Posted by zhangminglei <gi...@git.apache.org>.
Github user zhangminglei commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4168#discussion_r123689575
  
    --- Diff: flink-core/src/main/java/org/apache/flink/api/common/io/FileInputFormat.java ---
    @@ -461,8 +463,9 @@ public LocatableInputSplitAssigner getInputSplitAssigner(FileInputSplit[] splits
     		
     		// take the desired number of splits into account
     		minNumSplits = Math.max(minNumSplits, this.numSplits);
    -		
    -		final Path path = this.filePath;
    +
    +		final Path path = new Path(URLDecoder.decode(this.filePath.toString(), Charset.defaultCharset().name()));
    --- End diff --
    
    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.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4168: [FLINK-6987] Fix erroneous when path containing sp...

Posted by zentol <gi...@git.apache.org>.
Github user zentol commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4168#discussion_r123692542
  
    --- Diff: flink-core/src/main/java/org/apache/flink/api/common/io/FileInputFormat.java ---
    @@ -461,8 +463,9 @@ public LocatableInputSplitAssigner getInputSplitAssigner(FileInputSplit[] splits
     		
     		// take the desired number of splits into account
     		minNumSplits = Math.max(minNumSplits, this.numSplits);
    -		
    -		final Path path = this.filePath;
    +
    +		final Path path = new Path(URLDecoder.decode(this.filePath.toString(), Charset.defaultCharset().name()));
    --- End diff --
    
    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.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink issue #4168: [FLINK-6987] Fix erroneous when path containing spaces

Posted by zentol <gi...@git.apache.org>.
Github user zentol commented on the issue:

    https://github.com/apache/flink/pull/4168
  
    merging.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4168: [FLINK-6987] Fix erroneous when path containing sp...

Posted by zentol <gi...@git.apache.org>.
Github user zentol commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4168#discussion_r123980520
  
    --- Diff: flink-core/src/main/java/org/apache/flink/api/common/io/FileInputFormat.java ---
    @@ -461,8 +463,9 @@ public LocatableInputSplitAssigner getInputSplitAssigner(FileInputSplit[] splits
     		
     		// take the desired number of splits into account
     		minNumSplits = Math.max(minNumSplits, this.numSplits);
    -		
    -		final Path path = this.filePath;
    +
    +		final Path path = new Path(URLDecoder.decode(this.filePath.toString(), Charset.defaultCharset().name()));
    --- End diff --
    
    I would keep the conversion to an URI for the sake of making less changes to the test.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4168: [FLINK-6987] Fix erroneous when path containing sp...

Posted by zhangminglei <gi...@git.apache.org>.
Github user zhangminglei commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4168#discussion_r124175328
  
    --- Diff: flink-core/src/main/java/org/apache/flink/api/common/io/FileInputFormat.java ---
    @@ -461,8 +463,9 @@ public LocatableInputSplitAssigner getInputSplitAssigner(FileInputSplit[] splits
     		
     		// take the desired number of splits into account
     		minNumSplits = Math.max(minNumSplits, this.numSplits);
    -		
    -		final Path path = this.filePath;
    +
    +		final Path path = new Path(URLDecoder.decode(this.filePath.toString(), Charset.defaultCharset().name()));
    --- End diff --
    
    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());```
    
    2. **Output: file:/D:/projects/hello%20world/**
    
    ```System.out.println(new Path(parentDirTest.toURI())); ```
    
    3. **Output: file:/D:/projects/hello world/**
    
    ```System.out.println(new Path(parentDirTest.toURI().toString()));```
    
    4. **Output: file:/D:/projects/hello%20world**


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink issue #4168: [FLINK-6987] Fix erroneous when path containing spaces

Posted by zhangminglei <gi...@git.apache.org>.
Github user zhangminglei commented on the issue:

    https://github.com/apache/flink/pull/4168
  
    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.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4168: [FLINK-6987] Fix erroneous when path containing sp...

Posted by zhangminglei <gi...@git.apache.org>.
Github user zhangminglei commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4168#discussion_r124168503
  
    --- Diff: flink-core/src/main/java/org/apache/flink/api/common/io/FileInputFormat.java ---
    @@ -461,8 +463,9 @@ public LocatableInputSplitAssigner getInputSplitAssigner(FileInputSplit[] splits
     		
     		// take the desired number of splits into account
     		minNumSplits = Math.max(minNumSplits, this.numSplits);
    -		
    -		final Path path = this.filePath;
    +
    +		final Path path = new Path(URLDecoder.decode(this.filePath.toString(), Charset.defaultCharset().name()));
    --- End diff --
    
    Oh. Yeah. You are very correct, we need make the less changes to test. PR will update soon today.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink issue #4168: [FLINK-6987] Fix erroneous when path containing spaces

Posted by zhangminglei <gi...@git.apache.org>.
Github user zhangminglei commented on the issue:

    https://github.com/apache/flink/pull/4168
  
    Oops. I might be wrong. I will check again.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink issue #4168: [FLINK-6987] Fix erroneous when path containing spaces

Posted by zentol <gi...@git.apache.org>.
Github user zentol commented on the issue:

    https://github.com/apache/flink/pull/4168
  
    I doubt this fixes the underlying issue, it just masks it by storing the input files in paths containing spaces.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink issue #4168: [FLINK-6987] Fix erroneous when path containing spaces

Posted by zhangminglei <gi...@git.apache.org>.
Github user zhangminglei commented on the issue:

    https://github.com/apache/flink/pull/4168
  
    Hi @twalthr , you can test it again. I think it works fine now. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4168: [FLINK-6987] Fix erroneous when path containing sp...

Posted by zentol <gi...@git.apache.org>.
Github user zentol commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4168#discussion_r124223192
  
    --- Diff: flink-core/src/main/java/org/apache/flink/api/common/io/FileInputFormat.java ---
    @@ -461,8 +463,9 @@ public LocatableInputSplitAssigner getInputSplitAssigner(FileInputSplit[] splits
     		
     		// take the desired number of splits into account
     		minNumSplits = Math.max(minNumSplits, this.numSplits);
    -		
    -		final Path path = this.filePath;
    +
    +		final Path path = new Path(URLDecoder.decode(this.filePath.toString(), Charset.defaultCharset().name()));
    --- End diff --
    
    That#s a problem of URI, not of the path class. URI#toString escapes certain characters (like spaces) but they aren't escaped internally.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4168: [FLINK-6987] Fix erroneous when path containing sp...

Posted by zhangminglei <gi...@git.apache.org>.
Github user zhangminglei commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4168#discussion_r124225059
  
    --- Diff: flink-core/src/main/java/org/apache/flink/api/common/io/FileInputFormat.java ---
    @@ -461,8 +463,9 @@ public LocatableInputSplitAssigner getInputSplitAssigner(FileInputSplit[] splits
     		
     		// take the desired number of splits into account
     		minNumSplits = Math.max(minNumSplits, this.numSplits);
    -		
    -		final Path path = this.filePath;
    +
    +		final Path path = new Path(URLDecoder.decode(this.filePath.toString(), Charset.defaultCharset().name()));
    --- End diff --
    
    Oh. I see, thanks.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---