Uploaded image for project: 'Apache Hudi'
  1. Apache Hudi
  2. HUDI-786

InlineFileSystem.read API should ensure content beyond inline length gets an EOF

    XMLWordPrintableJSON

Details

    Description

      While trying to investigate a flaky test, noticed that the readFully() just proceeds to read bytes from the outerStream without any bounds checking

      @Override
        public void readFully(long position, byte[] buffer, int offset, int length) throws IOException {
          if ((length - offset) > this.length) {
            throw new IOException("Attempting to read past inline content");
          }
          outerStream.readFully(startOffset + position, buffer, offset, length);
        }
      
        @Override
        public void readFully(long position, byte[] buffer)
            throws IOException {
          readFully(position, buffer, 0, buffer.length);
        }
      

      we need to throw an error for buffers that are trying to read past the inline content.. (potentially buggy) example shown above.

      I have also ignored the TestInlineFileSystem#testFileSystemAPIs() ... we need to make a change to respect suffix length (we randomly generate) while attempting to read past the 1000 bytes of inline content..

       actualBytes = new byte[1000 + outerPathInfo.suffixLength];
          fsDataInputStream.readFully(0, actualBytes);
          verifyArrayEquality(outerPathInfo.expectedBytes, 0, 1000, actualBytes, 0, 1000);
      

      Attachments

        Issue Links

          Activity

            People

              shivnarayan sivabalan narayanan
              vinoth Vinoth Chandar
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m