Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
10.5.1.1
-
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
Attachments
Issue Links
- relates to
-
DERBY-3941 Unsafe use of DataInput.skipBytes() in StoredPage and StoredFieldHeader
- Closed