db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kristian Waagan (JIRA)" <j...@apache.org>
Subject [jira] Updated: (DERBY-2686) The skip method for some InputStreams and Readers return invalid values
Date Thu, 24 May 2007 10:46:16 GMT

     [ https://issues.apache.org/jira/browse/DERBY-2686?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Kristian Waagan updated DERBY-2686:
-----------------------------------

    Derby Info:   (was: [Patch Available])

As I said, this area is a bit "fuzzzy"...
What exactly is the contract of InputStream.skip?

The problem being solved, is an infinite loop when skip returns 0. Since you really can't
tell if the stream just chooses to skip zero bytes, or if EOF has been reached, it is hard
to know when to stop calling skip.
To be more on the safe side, I plan to investigate the possibility of checking for 0 inside
the higher level skip-method, then do a read() to check if EOF has been reached or not.
Have a look at BufferedByteHolderInputStream.skip for an example of code that hangs.


Secondly, we have readers in Derby that returns -1 in skip, which definitely breaks the contract:
"This method will block until some characters are available, an I/O error occurs, or the end
of the stream is reached.
Returns:
    The number of characters actually skipped"

I will split the patch I submitted into at least two smaller ones, and the patch 1a is also
buggy. I forgot to update a check in EmbedClob from -1 to 0, which causes length() to hang.

> The skip method for some InputStreams and Readers return invalid values
> -----------------------------------------------------------------------
>
>                 Key: DERBY-2686
>                 URL: https://issues.apache.org/jira/browse/DERBY-2686
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC, Store
>    Affects Versions: 10.3.0.0
>            Reporter: Kristian Waagan
>         Assigned To: Kristian Waagan
>         Attachments: derby-2686-1a.diff, derby-2686-1a.stat
>
>
> The Java API docs for InputStream.skip and Reader.skip seem to indicate that returning
a negative value is breaking the contract.
> The contract for Reader.skip is the more clear one, while I have taken the assumption
that all Derby InputStreams will return 0 only when EOF has been reached or 0 is passed in
as the amount of bytes to skip.
> Bad checking in a skip method also caused Derby to enter an infinite loop in a skip method.
> It should also be noted that skipping bytes/characters should be done in a loop, as skip
 is free to skip a smaller amount of bytes than requested. This is true even if EOF is not
reached.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message