-
Notifications
You must be signed in to change notification settings - Fork 662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor ReaderInputStream
implementation
#293
Refactor ReaderInputStream
implementation
#293
Conversation
The new implementation follows more closely the required behavior defined by CharsetEncoder, instead of assuming that buffers of certain size will work without having to resize them.
This avoids having to implement error-prone CharsetEncoder logic in CharSequenceInputStream. However, to keep support for `mark` some extra code is needed, which does not add much value compared to using BufferedInputStream instead.
0566dbd
to
7ab9ef3
Compare
@@ -217,62 +218,60 @@ private void testIO_356(final int bufferSize, final int dataSize, final int read | |||
is.close(); | |||
|
|||
// data buffers should be identical | |||
assertArrayEquals(data1, data2, "bufferSize=" + bufferSize + " dataSize=" + dataSize); | |||
assertArrayEquals(data1, data2, "dataSize=" + dataSize); | |||
} | |||
|
|||
@Test | |||
public void testIO_356_B10_D10_S0_UTF16() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably have to change the method names of these tests (removing B10
).
"Please let me know what you think." All builds are red 🙁 |
Closing, no feedback. |
Sorry for not having responded earlier, and for not properly following up on this. The issues mentioned in the description still exist on
I asked for feedback for the following reasons, but did not describe them very well, or at all, in the original description:
|
if (bufferSize < 1) { | ||
throw new IllegalArgumentException("Buffer size must be >= 1"); | ||
} | ||
// TODO: bufferSize is unused |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will change this to pass it to ReaderInputStream
and use it as inital encoderOut
size there.
Also, will these changes require me to sign the Apache CLA? |
I don't think so but IANAL. |
Regardless of what will happen with this pull request, should I report the two issues mentioned above on Jira? |
For completeness sake I have pushed one more commit to this Though that branch would still need adjustments to the tests as mentioned in my comments above. Regardless of what will happen with this pull request I have now created two issues on Jira which track the bugs mentioned above: |
The new implementation follows more closely the required behavior defined by
CharsetEncoder
, instead of assuming that buffers of certain size will work without having to resize them.Relates to:
Sorry for creating this pull request so late and not participating in the review of the previous pull requests for these issues.
If you don't think this pull request is worth it, feel free to close it. The current implementation will probably work in most situations correctly, but here it overwrites the
lastCoderResult
, even when the previousencode
was unsuccessful, e.g. OVERFLOW or ERROR.I also tried refactoring
org.apache.commons.io.input.CharSequenceInputStream
to useReaderInputStream
to reduce error-prone usage ofCharsetEncoder
there. However, this causes some behavior changes:available()
will in most cases return 0readLimit
parameter ofmark
is now actually considered, so code callingmark(0)
will not work anymoreI have marked this pull request as draft for now because I have not extensively tested it. Please let me know what you think.