[GitHub] [commons-io] michael-o commented on a change in pull request #101: IO-649 - Improve the performance of the contentEquals() methods.

2020-01-13 Thread GitBox
michael-o commented on a change in pull request #101: IO-649 - Improve the 
performance of the contentEquals() methods.
URL: https://github.com/apache/commons-io/pull/101#discussion_r365994005
 
 

 ##
 File path: src/main/java/org/apache/commons/io/IOUtils.java
 ##
 @@ -708,31 +706,79 @@ public static void closeQuietly(final Writer output) {
 @SuppressWarnings("resource")
 public static boolean contentEquals(final InputStream input1, final 
InputStream input2)
 throws IOException {
+return contentEquals(input1, input2, DEFAULT_BUFFER_SIZE);
+}
+
+/**
+ * Compares the contents of two Streams to determine if they are equal or 
not.
+ * 
+ * This method buffers the input internally.
+ *
+ * @param input1 the first stream
+ * @param input2 the second stream
+ * @param bufferSize the size of the internal buffer to use.
+ * @return true if the content of the streams are equal or they both don't
+ * exist, false otherwise
+ * @throws NullPointerException if either input is null
 
 Review comment:
   I would rather see an explicit NPE up front.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [commons-io] michael-o commented on a change in pull request #101: IO-649 - Improve the performance of the contentEquals() methods.

2020-01-13 Thread GitBox
michael-o commented on a change in pull request #101: IO-649 - Improve the 
performance of the contentEquals() methods.
URL: https://github.com/apache/commons-io/pull/101#discussion_r365984225
 
 

 ##
 File path: src/main/java/org/apache/commons/io/IOUtils.java
 ##
 @@ -708,31 +706,79 @@ public static void closeQuietly(final Writer output) {
 @SuppressWarnings("resource")
 public static boolean contentEquals(final InputStream input1, final 
InputStream input2)
 throws IOException {
+return contentEquals(input1, input2, DEFAULT_BUFFER_SIZE);
+}
+
+/**
+ * Compares the contents of two Streams to determine if they are equal or 
not.
+ * 
+ * This method buffers the input internally.
+ *
+ * @param input1 the first stream
+ * @param input2 the second stream
+ * @param bufferSize the size of the internal buffer to use.
+ * @return true if the content of the streams are equal or they both don't
+ * exist, false otherwise
+ * @throws NullPointerException if either input is null
+ * @throws IOException  if an I/O error occurs
+ */
+@SuppressWarnings("resource")
+public static boolean contentEquals(final InputStream input1, final 
InputStream input2, final int bufferSize)
+throws IOException {
+if (bufferSize <= 0) {
+throw new IllegalArgumentException("Buffer size must be positive: 
" + bufferSize);
 
 Review comment:
   This one is not documented.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [commons-io] michael-o commented on a change in pull request #101: IO-649 - Improve the performance of the contentEquals() methods.

2020-01-13 Thread GitBox
michael-o commented on a change in pull request #101: IO-649 - Improve the 
performance of the contentEquals() methods.
URL: https://github.com/apache/commons-io/pull/101#discussion_r365984302
 
 

 ##
 File path: src/main/java/org/apache/commons/io/IOUtils.java
 ##
 @@ -708,31 +706,79 @@ public static void closeQuietly(final Writer output) {
 @SuppressWarnings("resource")
 public static boolean contentEquals(final InputStream input1, final 
InputStream input2)
 throws IOException {
+return contentEquals(input1, input2, DEFAULT_BUFFER_SIZE);
+}
+
+/**
+ * Compares the contents of two Streams to determine if they are equal or 
not.
+ * 
+ * This method buffers the input internally.
+ *
+ * @param input1 the first stream
+ * @param input2 the second stream
+ * @param bufferSize the size of the internal buffer to use.
+ * @return true if the content of the streams are equal or they both don't
+ * exist, false otherwise
+ * @throws NullPointerException if either input is null
 
 Review comment:
   I fail to see where this one is thrown.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [commons-io] michael-o commented on a change in pull request #101: IO-649 - Improve the performance of the contentEquals() methods.

2020-01-13 Thread GitBox
michael-o commented on a change in pull request #101: IO-649 - Improve the 
performance of the contentEquals() methods.
URL: https://github.com/apache/commons-io/pull/101#discussion_r365985566
 
 

 ##
 File path: src/main/java/org/apache/commons/io/IOUtils.java
 ##
 @@ -746,25 +792,74 @@ public static boolean contentEquals(final InputStream 
input1, final InputStream
 @SuppressWarnings("resource")
 public static boolean contentEquals(final Reader input1, final Reader 
input2)
 throws IOException {
+return contentEquals(input1, input2, DEFAULT_BUFFER_SIZE);
+}
+
+/**
+ * Compares the contents of two Readers to determine if they are equal or 
not.
+ * 
+ * This method buffers the input internally.
+ * 
+ *
+ * @param input1 the first reader
+ * @param input2 the second reader
+ * @param bufferSize the size of the internal buffer to use.
+ * @return true if the content of the readers are equal or they both don't
+ * exist, false otherwise
+ * @throws NullPointerException if either input is null
 
 Review comment:
   Same here.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services