Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-32509

avoid using skip in InputStreamFSInputWrapper.seek

    XMLWordPrintableJSON

Details

    Description

      The implementation of  InputStream does not return -1  for eof.

      The java doc of InputStream said "The skip method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly 0." 

      For FileInputStream, it allows skipping any number of bytes past the end of the file.

      So the method "seek" of InputStreamFSInputWrapper will cause infinite loop if 
      desired exceed end of file
       
      I reproduced with following case
       

      byte[] bytes = "flink".getBytes();
      
      try (InputStream inputStream = new ByteArrayInputStream(bytes)){ 
          InputStreamFSInputWrapper wrapper = new InputStreamFSInputWrapper(inputStream); 
          wrapper.seek(20); 
      } 

      I  found an issue of commons-io talks about the problem of skip
      https://issues.apache.org/jira/browse/IO-203

       

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              lbqin Libin Qin
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: