Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 68217 invoked from network); 22 Aug 2008 16:55:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 22 Aug 2008 16:55:45 -0000 Received: (qmail 38598 invoked by uid 500); 22 Aug 2008 16:55:43 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 38574 invoked by uid 500); 22 Aug 2008 16:55:43 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 38563 invoked by uid 99); 22 Aug 2008 16:55:43 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 22 Aug 2008 09:55:43 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 22 Aug 2008 16:54:46 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 1B7F3234C1C9 for ; Fri, 22 Aug 2008 09:54:46 -0700 (PDT) Message-ID: <2074700668.1219424086111.JavaMail.jira@brutus> Date: Fri, 22 Aug 2008 09:54:46 -0700 (PDT) From: "Daniel John Debrunner (JIRA)" To: derby-dev@db.apache.org Subject: [jira] Commented: (DERBY-3770) Create a utility class for skipping data in an InputStream In-Reply-To: <1159217300.1215611612234.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/DERBY-3770?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12624901#action_12624901 ] Daniel John Debrunner commented on DERBY-3770: ---------------------------------------------- Some questions/comments about skipFully(InputStream is) What is the purpose of this method, when would it be used? Skipping until EOF seems a useless operation. SKIP_BUFFER_SIZE is a somewhat confusing name since no buffer is ever allocated. skipPersistent() states that if a fewer number of bytes is skipped then it is guaranteed that eof has been reached, but skipFully() does not take advantage of this, instead it will always perform an extra call to skipPersistent(). Other input stream utility methods are in org.apache.derby.iapi.services.io, any reason to have this new class in a different package? > 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, derby-3770-3.patch, derby-3770-3.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.