* [Bug libgcj/18376] java.io.BufferedWriter outputing extraneous characters?
2004-11-08 14:57 [Bug java/18376] New: java.io.BufferedWriter outputing extraneous characters? wayne dot gray at coynetextileservices dot com
@ 2004-11-08 15:00 ` pinskia at gcc dot gnu dot org
2004-11-08 15:02 ` wayne dot gray at coynetextileservices dot com
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-11-08 15:00 UTC (permalink / raw)
To: java-prs
--
What |Removed |Added
----------------------------------------------------------------------------
Component|java |libgcj
Summary| java.io.BufferedWriter |java.io.BufferedWriter
|outputing extraneous |outputing extraneous
|characters? |characters?
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18376
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libgcj/18376] java.io.BufferedWriter outputing extraneous characters?
2004-11-08 14:57 [Bug java/18376] New: java.io.BufferedWriter outputing extraneous characters? wayne dot gray at coynetextileservices dot com
2004-11-08 15:00 ` [Bug libgcj/18376] " pinskia at gcc dot gnu dot org
@ 2004-11-08 15:02 ` wayne dot gray at coynetextileservices dot com
2004-11-08 18:34 ` pinskia at gcc dot gnu dot org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: wayne dot gray at coynetextileservices dot com @ 2004-11-08 15:02 UTC (permalink / raw)
To: java-prs
------- Additional Comments From wayne dot gray at coynetextileservices dot com 2004-11-08 15:02 -------
Created an attachment (id=7492)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=7492&action=view)
Java class, build script, and example output in demo directory
This is a demo of the function. In the demo directory file buildlog.txt is the
source file and file buildlogcopy.txt is the resulting file.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18376
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libgcj/18376] java.io.BufferedWriter outputing extraneous characters?
2004-11-08 14:57 [Bug java/18376] New: java.io.BufferedWriter outputing extraneous characters? wayne dot gray at coynetextileservices dot com
2004-11-08 15:00 ` [Bug libgcj/18376] " pinskia at gcc dot gnu dot org
2004-11-08 15:02 ` wayne dot gray at coynetextileservices dot com
@ 2004-11-08 18:34 ` pinskia at gcc dot gnu dot org
2004-11-08 22:17 ` tromey at gcc dot gnu dot org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-11-08 18:34 UTC (permalink / raw)
To: java-prs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-11-08 18:34 -------
Confirmed on the mainline, I don't know what is going on but we are writting out zeros.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2004-11-08 18:34:31
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18376
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libgcj/18376] java.io.BufferedWriter outputing extraneous characters?
2004-11-08 14:57 [Bug java/18376] New: java.io.BufferedWriter outputing extraneous characters? wayne dot gray at coynetextileservices dot com
` (2 preceding siblings ...)
2004-11-08 18:34 ` pinskia at gcc dot gnu dot org
@ 2004-11-08 22:17 ` tromey at gcc dot gnu dot org
2004-11-09 13:37 ` wayne dot gray at coynetextileservices dot com
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: tromey at gcc dot gnu dot org @ 2004-11-08 22:17 UTC (permalink / raw)
To: java-prs
------- Additional Comments From tromey at gcc dot gnu dot org 2004-11-08 22:17 -------
The code says:
while (br.read(charBuff,0,fileLength) != -1)
bw.write(charBuff,0,fileLength);
There is no guarantee that read() will fill the buffer.
If you see a partial read, you will then write a full buffer,
meaning that the remainder of the buffer will be zero
(or leftovers from an earlier read).
So, I think this is not a libgcj bug.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18376
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libgcj/18376] java.io.BufferedWriter outputing extraneous characters?
2004-11-08 14:57 [Bug java/18376] New: java.io.BufferedWriter outputing extraneous characters? wayne dot gray at coynetextileservices dot com
` (3 preceding siblings ...)
2004-11-08 22:17 ` tromey at gcc dot gnu dot org
@ 2004-11-09 13:37 ` wayne dot gray at coynetextileservices dot com
2004-11-09 22:11 ` tromey at gcc dot gnu dot org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: wayne dot gray at coynetextileservices dot com @ 2004-11-09 13:37 UTC (permalink / raw)
To: java-prs
------- Additional Comments From wayne dot gray at coynetextileservices dot com 2004-11-09 13:36 -------
(In reply to comment #3)
> The code says:
>
> while (br.read(charBuff,0,fileLength) != -1)
> bw.write(charBuff,0,fileLength);
>
> There is no guarantee that read() will fill the buffer.
> If you see a partial read, you will then write a full buffer,
> meaning that the remainder of the buffer will be zero
> (or leftovers from an earlier read).
>
> So, I think this is not a libgcj bug.
>
I see what you're saying. But if that were true then the while loop would have
multiple iterations. No?
The read and write methods are only being called once in this method for this
file. Just confirmed with another test.
This is true because I'm sizing the buffer to the length of the file and...
br.read(charBuff,0,fileLength)
...reads the entire file length in the first shot.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18376
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libgcj/18376] java.io.BufferedWriter outputing extraneous characters?
2004-11-08 14:57 [Bug java/18376] New: java.io.BufferedWriter outputing extraneous characters? wayne dot gray at coynetextileservices dot com
` (4 preceding siblings ...)
2004-11-09 13:37 ` wayne dot gray at coynetextileservices dot com
@ 2004-11-09 22:11 ` tromey at gcc dot gnu dot org
2004-11-10 18:23 ` wayne dot gray at coynetextileservices dot com
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: tromey at gcc dot gnu dot org @ 2004-11-09 22:11 UTC (permalink / raw)
To: java-prs
------- Additional Comments From tromey at gcc dot gnu dot org 2004-11-09 22:11 -------
I downloaded the test case and modified it to print the
number of characters it read. I can confirm that for me it
does in fact loop:
opsy. gij TestGcj.IoTest ../demo/buildlog.txt Out.txt
fileLength = 2290
x = 2048
x = 242
A few things to note here.
First, you're using a BufferedReader, so you aren't guaranteed
to fill your request array. You might pick up buffered data instead.
Second, using characters here is incorrect, as File.length() returns
the size in bytes. This seems to be the cause of the problem we're
seeing with the test case, since it still operates in the same way
if I remove the buffering. I think the internal character set converters
have their own buffers and as a result we don't get a full file read.
If I change the loop in this test program to use the actual read result
as the length argument to write, it works properly. So, even though libgcj
is perhaps a little odd here, I still think it is correct.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18376
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libgcj/18376] java.io.BufferedWriter outputing extraneous characters?
2004-11-08 14:57 [Bug java/18376] New: java.io.BufferedWriter outputing extraneous characters? wayne dot gray at coynetextileservices dot com
` (5 preceding siblings ...)
2004-11-09 22:11 ` tromey at gcc dot gnu dot org
@ 2004-11-10 18:23 ` wayne dot gray at coynetextileservices dot com
2005-04-28 21:52 ` pinskia at gcc dot gnu dot org
2005-04-28 22:38 ` greenrd at greenrd dot org
8 siblings, 0 replies; 10+ messages in thread
From: wayne dot gray at coynetextileservices dot com @ 2004-11-10 18:23 UTC (permalink / raw)
To: java-prs
------- Additional Comments From wayne dot gray at coynetextileservices dot com 2004-11-10 18:23 -------
Ok thanks. I'll rip out that File.length() stuff and see if that works.
Thanks for your time.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18376
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libgcj/18376] java.io.BufferedWriter outputing extraneous characters?
2004-11-08 14:57 [Bug java/18376] New: java.io.BufferedWriter outputing extraneous characters? wayne dot gray at coynetextileservices dot com
` (6 preceding siblings ...)
2004-11-10 18:23 ` wayne dot gray at coynetextileservices dot com
@ 2005-04-28 21:52 ` pinskia at gcc dot gnu dot org
2005-04-28 22:38 ` greenrd at greenrd dot org
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-28 21:52 UTC (permalink / raw)
To: java-prs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-04-28 21:52 -------
*** Bug 21270 has been marked as a duplicate of this bug. ***
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |mnefedov at rogers dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18376
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libgcj/18376] java.io.BufferedWriter outputing extraneous characters?
2004-11-08 14:57 [Bug java/18376] New: java.io.BufferedWriter outputing extraneous characters? wayne dot gray at coynetextileservices dot com
` (7 preceding siblings ...)
2005-04-28 21:52 ` pinskia at gcc dot gnu dot org
@ 2005-04-28 22:38 ` greenrd at greenrd dot org
8 siblings, 0 replies; 10+ messages in thread
From: greenrd at greenrd dot org @ 2005-04-28 22:38 UTC (permalink / raw)
To: java-prs
------- Additional Comments From greenrd at greenrd dot org 2005-04-28 22:38 -------
Please reopen. JDK1.5 javadocs for BufferedReader.read include this new information:
"As an additional convenience, it attempts to read as many characters as
possible by repeatedly invoking the read method of the underlying stream."
Bug 18840 addressed the same issue for BufferedInputStream by bringing libgcj
into compliance with JDK1.5; the same should be done here, for BufferedReader.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18376
^ permalink raw reply [flat|nested] 10+ messages in thread