NPE in
org.apache.commons.io.FileUtils.contentEqualsIgnoreEOL(File, File) when
only one input is null.
MODIFY
src/changes/changes.xml
src/changes/changes.xml
@@ -174,8 +174,8 @@ The <action> type attribute can be add,update,fix,remove.
<action issue="IO-643" dev="ggregory" type="add" due-to="Gary Gregory">
NPE in org.apache.commons.io.IOUtils.contentEqualsIgnoreEOL(Reader, Reader) when only one input is null.
</action>
- <action issue="IO-643" dev="ggregory" type="add" due-to="Gary Gregory">
- NPE in org.apache.commons.io.FileUtils.contentEquals(File, File) when only one input is null.
+ <action issue="IO-644" dev="ggregory" type="add" due-to="Gary Gregory">
+ NPE in org.apache.commons.io.FileUtils.contentEqualsIgnoreEOL(File, File) when only one input is null.
</action>
</release>

MODIFY
src/main/java/org/apache/commons/io/FileUtils.java
src/main/java/org/apache/commons/io/FileUtils.java
@@ -445,6 +445,12 @@ public static boolean contentEquals(final File file1, final File file2) throws I
*/
public static boolean contentEqualsIgnoreEOL(final File file1, final File file2, final String charsetName)
throws IOException {
+ if (file1 == null && file2 == null) {
+ return true;
+ }
+ if (file1 == null ^ file2 == null) {
+ return false;
+ }
final boolean file1Exists = file1.exists();
if (file1Exists != file2.exists()) {
return false;

MODIFY
src/test/java/org/apache/commons/io/FileUtilsTestCase.java
src/test/java/org/apache/commons/io/FileUtilsTestCase.java
@@ -630,6 +630,9 @@ public void testContentEqualsIgnoreEOL() throws Exception {
// Non-existent files
final File file1 = new File(temporaryFolder, getName());
final File file2 = new File(temporaryFolder, getName() + "2");
+ assertTrue(FileUtils.contentEqualsIgnoreEOL(null, null, null));
+ assertFalse(FileUtils.contentEqualsIgnoreEOL(null, file1, null));
+ assertFalse(FileUtils.contentEqualsIgnoreEOL(file1, null, null));
// both don't exist
assertTrue(FileUtils.contentEqualsIgnoreEOL(file1, file1, null));
assertTrue(FileUtils.contentEqualsIgnoreEOL(file1, file2, null));

[IO-644] NPE in
org.apache.commons.io.FileUtils.contentEqualsIgnoreEOL(File, File) when
only one input is null.