Uploaded image for project: 'Derby'
  1. Derby
  2. DERBY-3770

Create a utility class for skipping data in an InputStream

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 10.5.1.1
    • 10.5.1.1
    • Miscellaneous
    • None

    Description

      The contract of InputStream.skip is somewhat difficult, some would even say broken.
      See http://java.sun.com/javase/6/docs/api/java/io/InputStream.html#skip(long))

      A utility class should be created to ensure that we use the same skip procedure throughout the Derby code base.
      Suggested functionality:

      • long skipFully(InputStream) : skips until EOF, returns number of bytes skipped
      • void skipFully(InputStream,long) : skips requested number of bytes, throws EOFException if there is too few bytes in the stream

      I know of two different approaches, both skipping in a loop:
      a) Verify EOF with a read call when skip returns zero.
      b) Throw EOFException if skip returns zero before requested number of bytes have been skipped.

      There's related code in iapi.util.UTF8Util. Maybe this class, say StreamUtil, could be put in the same package?

      Attachments

        1. derby-3770-1.patch
          8 kB
          Junjie Peng
        2. derby-3770-1.stat
          0.3 kB
          Junjie Peng
        3. derby-3770-2.patch
          9 kB
          Junjie Peng
        4. derby-3770-2.stat
          0.3 kB
          Junjie Peng
        5. derby-3770-3.patch
          12 kB
          Junjie Peng
        6. derby-3770-3.stat
          0.3 kB
          Junjie Peng
        7. derby-3770-4.patch
          19 kB
          Junjie Peng
        8. derby-3770-4.patch
          19 kB
          Junjie Peng
        9. derby-3770-4.stat
          0.6 kB
          Junjie Peng
        10. derby-3770-4.stat
          0.6 kB
          Junjie Peng
        11. derby-3770-5.patch
          19 kB
          Junjie Peng
        12. derby-3770-5.stat
          0.6 kB
          Junjie Peng
        13. derby-3770-6.patch
          19 kB
          Junjie Peng
        14. derby-3770-6.stat
          0.5 kB
          Junjie Peng
        15. derby-3770-remove-1a.diff
          7 kB
          Knut Anders Hatlen
        16. derby-3770-use-1a.diff
          8 kB
          Knut Anders Hatlen

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            thinkallday Junjie Peng
            kristwaa Kristian Waagan
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment