Bug 40455 - ReaderInputStream handling character sets having preamples incorrect;ly
Summary: ReaderInputStream handling character sets having preamples incorrect;ly
Alias: None
Product: Ant
Classification: Unclassified
Component: Core (show other bugs)
Version: 1.8.2
Hardware: Other other
: P2 critical (vote)
Target Milestone: 1.10.9
Assignee: Ant Notifications List
Depends on:
Reported: 2006-09-10 11:51 UTC by Peter Reilly
Modified: 2020-08-22 19:09 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Peter Reilly 2006-09-10 11:51:50 UTC
Some character sets have a preample - for example
utf-16 which has a BOM indicator. ReaderInputStream
does not handle this because it restarts the
stream for each block read in:

in readBytes:
            if (n > 0) {
                slack = new String(buf, 0, n).getBytes(encoding);
                begin = 0;
The String.getBytes does the encoding, but it can
be called a number of times.
Comment 1 Vladimir Sitnikov 2020-08-14 20:23:19 UTC
Unfortunately the bug is still relevant, and it does impact users by corrupting the stream.

Here's unexpected file corruption in Gradle: https://github.com/gradle/gradle/issues/14134

I suggest to replace Ant's ReaderInputStream with the implementation from commons-io.

What do you think?
Comment 2 Stefan Bodewig 2020-08-22 19:09:00 UTC
We've implemented Vladimir's suggestion for 1.10.9.