garydgregory commented on code in PR #790:
URL: https://github.com/apache/commons-io/pull/790#discussion_r2392958294
##########
src/main/java/org/apache/commons/io/input/BrokenReader.java:
##########
@@ -114,6 +115,10 @@ public void mark(final int readAheadLimit) throws
IOException {
*/
@Override
public int read(final char[] cbuf, final int off, final int len) throws
IOException {
+ IOUtils.checkFromIndexSize(cbuf, off, len);
Review Comment:
The class and method Javadoc, and the implementation are now divergent. The
point of this class is to always throw an `IOException` (see class Javadoc),
so... I'm not sure changing this implementation in such a subtle way is a good
thing.
##########
src/main/java/org/apache/commons/io/output/ClosedOutputStream.java:
##########
@@ -73,6 +75,7 @@ public void flush() throws IOException {
*/
@Override
public void write(final byte b[], final int off, final int len) throws
IOException {
+ IOUtils.checkFromIndexSize(b, off, len);
Review Comment:
Probably not? Not in agreement with Javadoc. See comments for the "Broken"
classes.
##########
src/main/java/org/apache/commons/io/output/FilterCollectionWriter.java:
##########
@@ -128,6 +129,7 @@ public void write(final char[] cbuf) throws IOException {
@SuppressWarnings("resource") // no allocation
@Override
public void write(final char[] cbuf, final int off, final int len) throws
IOException {
+ IOUtils.checkFromIndexSize(cbuf, off, len);
Review Comment:
This is not in agreement with the class Javadoc and may break some apps
perhaps.
##########
src/main/java/org/apache/commons/io/output/ClosedWriter.java:
##########
@@ -77,6 +79,7 @@ public void flush() throws IOException {
*/
@Override
public void write(final char[] cbuf, final int off, final int len) throws
IOException {
+ IOUtils.checkFromIndexSize(cbuf, off, len);
Review Comment:
Probably not? Not in agreement with Javadoc. See comments for the "Broken"
classes.
##########
src/main/java/org/apache/commons/io/output/FilterCollectionWriter.java:
##########
@@ -159,6 +161,7 @@ public void write(final String str) throws IOException {
@SuppressWarnings("resource") // no allocation
@Override
public void write(final String str, final int off, final int len) throws
IOException {
+ IOUtils.checkFromIndexSize(str, off, len);
forAllWriters(w -> w.write(str, off, len));
}
Review Comment:
This is not in agreement with the class Javadoc and may break some apps
perhaps.
##########
src/main/java/org/apache/commons/io/output/NullAppendable.java:
##########
@@ -51,6 +53,7 @@ public Appendable append(final CharSequence csq) throws
IOException {
@Override
public Appendable append(final CharSequence csq, final int start, final
int end) throws IOException {
+ IOUtils.checkFromToIndex(csq, start, end);
Review Comment:
This contradicts the class Javadoc. It seems to me that our "Null",
"Broken", and "Closed" classes are different beasts from other
stream/reader/writer implementations.
##########
src/main/java/org/apache/commons/io/output/BrokenWriter.java:
##########
@@ -121,6 +122,7 @@ private RuntimeException rethrow() {
*/
@Override
public void write(final char[] cbuf, final int off, final int len) throws
IOException {
+ IOUtils.checkFromIndexSize(cbuf, off, len);
Review Comment:
Probably not? See comments for other "Broken" classes.
##########
src/main/java/org/apache/commons/io/output/NullOutputStream.java:
##########
@@ -75,7 +77,7 @@ public void write(final byte[] b) throws IOException {
*/
@Override
public void write(final byte[] b, final int off, final int len) {
- // noop
+ IOUtils.checkFromIndexSize(b, off, len);
Review Comment:
This contradicts the class Javadoc. It seems to me that our "Null",
"Broken", and "Closed" classes are different beasts from other
stream/reader/writer implementations.
##########
src/main/java/org/apache/commons/io/output/NullWriter.java:
##########
@@ -87,7 +89,7 @@ public Writer append(final CharSequence csq) {
*/
@Override
public Writer append(final CharSequence csq, final int start, final int
end) {
- //to /dev/null
+ IOUtils.checkFromToIndex(csq, start, end);
Review Comment:
This contradicts the class Javadoc. It seems to me that our "Null",
"Broken", and "Closed" classes are different beasts from other
stream/reader/writer implementations.
##########
src/main/java/org/apache/commons/io/output/NullWriter.java:
##########
@@ -110,6 +112,7 @@ public void flush() {
*/
@Override
public void write(final char[] chr) {
+ write(chr, 0, chr.length);
Review Comment:
This defeats the purpose of writing to nowhere ("/dev/null").
This contradicts the class Javadoc. It seems to me that our "Null",
"Broken", and "Closed" classes are different beasts from other
stream/reader/writer implementations.
--
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]