db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mamta A. Satoor (JIRA)" <j...@apache.org>
Subject [jira] Commented: (DERBY-3770) Create a utility class for skipping data in an InputStream
Date Wed, 20 Aug 2008 17:52:45 GMT

    [ https://issues.apache.org/jira/browse/DERBY-3770?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12624067#action_12624067
] 

Mamta A. Satoor commented on DERBY-3770:
----------------------------------------

Junjie, sorry for not getting back to you sooner.

What I meant bu comment 2) for the tests is something along following line. In most of the
JDBC junit tests in Derby, if say executing a specific query is only allowed to send a specific
exception, then we assert that using following (s below is java.sql.Statement)
        assertStatementError("42Y55", s, "CALL SYSCS_UTIL.SYSCS_UPDATE_STATISTICS('APP','T1',null)");
So, if the query above throws any exception other than "42Y55" then that will cause the junit
test to fail saying that it expected 42Y55 but it got something else.

I was wonderinf in the test in question here, if there was anyway of catching exceptions other
than NPE
+        try{
+            StreamUtil.skipFully(null);
+            fail("Null InputStream is accepted!");
+        }catch (NullPointerException e) {
+            assertTrue(true);
+        }

I guess, if the test case above did get an exception other than NPE, we will just get out
of the test fixture with that exception. I was curious if there was some more graceful way
of catching unexpected exceptions like we do for jave.sql.Statement with assertStatementError.
This is not a biggie and feel free to not address this issue if there is no simple way of
doing what assertStatementError does.

> Create a utility class for skipping data in an InputStream
> ----------------------------------------------------------
>
>                 Key: DERBY-3770
>                 URL: https://issues.apache.org/jira/browse/DERBY-3770
>             Project: Derby
>          Issue Type: Improvement
>          Components: Miscellaneous
>    Affects Versions: 10.5.0.0
>            Reporter: Kristian Waagan
>            Assignee: Junjie Peng
>            Priority: Minor
>         Attachments: derby-3770-1.patch, derby-3770-1.stat, derby-3770-2.patch, derby-3770-2.stat
>
>
> 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?

-- 
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