Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 45666 invoked from network); 23 May 2007 05:31:37 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 23 May 2007 05:31:37 -0000 Received: (qmail 19224 invoked by uid 500); 23 May 2007 05:31:43 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 19197 invoked by uid 500); 23 May 2007 05:31:42 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 19188 invoked by uid 99); 23 May 2007 05:31:42 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 May 2007 22:31:42 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 May 2007 22:31:36 -0700 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 65C12714057 for ; Tue, 22 May 2007 22:31:16 -0700 (PDT) Message-ID: <3453356.1179898276414.JavaMail.jira@brutus> Date: Tue, 22 May 2007 22:31:16 -0700 (PDT) From: "spark shen (JIRA)" To: commits@harmony.apache.org Subject: [jira] Updated: (HARMONY-3854) [classlib][luni] InputStreamReader.read(char[] buffer) doesn't fill in all the buffer when input is still available In-Reply-To: <10894354.1179135676386.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/HARMONY-3854?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] spark shen updated HARMONY-3854: -------------------------------- Attachment: InputStreamReader_3854.patch Would you please try this patch? > [classlib][luni] InputStreamReader.read(char[] buffer) doesn't fill in all the buffer when input is still available > ------------------------------------------------------------------------------------------------------------------- > > Key: HARMONY-3854 > URL: https://issues.apache.org/jira/browse/HARMONY-3854 > Project: Harmony > Issue Type: Bug > Components: Classlib > Reporter: Elena Sayapina > Attachments: InputStreamReader_3854.patch, readTest.zip, readTest2.zip > > > Method read of InputStreamReader works incorrectly in some cases. > If call method read(char[] buffer) with the non-tiny buffer more than two times it reads chars incorrectly, > i.e. doesn't fill in all the buffer when some input is still available. > Please, consider the following piece of code (note that data.txt contains about 14000 chars): > import java.io.File; > import java.io.FileInputStream; > import java.io.IOException; > import java.io.InputStream; > import java.io.InputStreamReader; > public class readTest { > public static void main(String[] args) throws IOException { > > String filename = new String("data.txt"); > System.out.println("Data file length: " + new File(filename).length()); > InputStream stream = new FileInputStream(new File(filename)); > InputStreamReader reader = new InputStreamReader(stream); > > int read = 0; > char[] buffer = new char[4]; > System.out.println("Char buffer capacity: " + buffer.length); > try { > read = reader.read(buffer); > } catch (Exception e) { > e.printStackTrace(); > System.out.println("TEST FAILED: unexpected" + e); > } > System.out.println("Number of chars read: " + read); > read = 0; > buffer = new char[9000]; > System.out.println("Char buffer capacity: " + buffer.length); > try { > read = reader.read(buffer); > } catch (Exception e) { > e.printStackTrace(); > System.out.println("TEST FAILED: unexpected" + e); > } > System.out.println("Number of chars read: " + read); > > System.out.println("buffer[8999]: " + buffer[8999]); > System.out.println("buffer[8998]: " + buffer[8998]); > System.out.println("buffer[8189]: " + buffer[8189]); > System.out.println("buffer[8188]: " + buffer[8188]); > System.out.println("buffer[8187]: " + buffer[8187]); > > if (read == buffer.length) System.out.println("TEST PASSED"); > else System.out.println("TEST FAILED"); > } > } > Output on Harmony-r537585: > Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors, > as applicable. > java version "1.5.0" > pre-alpha : not complete or compatible > svn = r537585, (May 13 2007), Windows/ia32/msvc 1310, debug build > http://incubator.apache.org/harmony > Data file length: 14000 > Char buffer capacity: 4 > Number of chars read: 4 > Char buffer capacity: 9000 > Number of chars read: 8188 > buffer[8999]: > buffer[8998]: > buffer[8189]: > buffer[8188]: > buffer[8187]: t > TEST FAILED > Output on HotSpot: > java version "1.5.0_11" > Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_11-b03) > Java HotSpot(TM) Client VM (build 1.5.0_11-b03, mixed mode) > Data file length: 14000 > Char buffer capacity: 4 > Number of chars read: 4 > Char buffer capacity: 9000 > Number of chars read: 9000 > buffer[8999]: t > buffer[8998]: s > buffer[8189]: e > buffer[8188]: T > buffer[8187]: t > TEST PASSED > NOTE that if remove first try..catch block with reader.read(buffer) then test passes, > or if reduce buffer size from 9000 to 8188 test also passes. > Please, use the data from attached readTest.zip to reproduce the failure. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.