[
https://issues.apache.org/jira/browse/IO-714?focusedWorklogId=663880&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-663880
]
ASF GitHub Bot logged work on IO-714:
-------------------------------------
Author: ASF GitHub Bot
Created on: 12/Oct/21 05:49
Start Date: 12/Oct/21 05:49
Worklog Time Spent: 10m
Work Description: kevinwang1975 commented on pull request #283:
URL: https://github.com/apache/commons-io/pull/283#issuecomment-940685076
> @kevinwang1975 Broken builds, please check the logs for Checkstyle errors.
@garydgregory Fixed the style issue.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 663880)
Time Spent: 20m (was: 10m)
> ReaderInputStream does not call CharsetEncoder.flush(...)
> ---------------------------------------------------------
>
> Key: IO-714
> URL: https://issues.apache.org/jira/browse/IO-714
> Project: Commons IO
> Issue Type: Bug
> Components: Streams/Writers
> Affects Versions: 2.8.0
> Reporter: Marcono1234
> Priority: Major
> Attachments:
> 0001-Fixed-ReaderInputStream-not-calling-CharsetEncoder.f.patch
>
> Time Spent: 20m
> Remaining Estimate: 0h
>
> As defined by the {{CharsetEncoder}}
> [documentation|https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/charset/CharsetEncoder.html]
> the _encoding operation_ consists of:
> # (reset)
> # encode
> # flush
> However, {{org.apache.commons.io.input.ReaderInputStream}} does not call
> {{flush}}. This leads to incorrect results for charsets whose {{flush}}
> method appends additional bytes.
> Example:
> {code}
> // Charset whose CharsetEncoder.flush(...) puts bytes
> Charset charset = Charset.forName("Cp930");
> // \u0391: Causes CharsetEncoder.flush(...) to put additional bytes
> String s = "\u0391";
> byte[] expected = s.getBytes(charset);
> byte[] actual;
> try (InputStream in = new ReaderInputStream(new StringReader(s), charset)) {
> actual = IOUtils.toByteArray(in);
> }
> if (!Arrays.equals(expected, actual)) {
> throw new AssertionError("\n Expected: " + Arrays.toString(expected) +
> "\n Actual: " + Arrays.toString(actual));
> }
> {code}
> Also make sure to check the result of {{flush()}} because {{OVERFLOW}} as
> result is possible. In theory {{isError() == true}} might be possible as
> well, but I don't think any of charset implementations currently return that.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)