NPE in org.apache.commons.io.FileUtils.contentEquals(File,
File) when only one input is null.
MODIFY
src/changes/changes.xml
src/changes/changes.xml
@@ -171,9 +171,12 @@ The <action> type attribute can be add,update,fix,remove.
<action issue="IO-641" dev="ggregory" type="add" due-to="Gary Gregory">
NPE in org.apache.commons.io.IOUtils.contentEquals(Reader, Reader) when only one input is null.
</action>
- <action issue="IO-642" dev="ggregory" type="add" due-to="Gary Gregory">
+ <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>
</release>
<release version="2.6" date="2017-10-15" description="Java 7 required, Java 9 supported.">

MODIFY
src/main/java/org/apache/commons/io/FileUtils.java
src/main/java/org/apache/commons/io/FileUtils.java
@@ -388,6 +388,12 @@ private static void cleanDirectoryOnExit(final File directory) throws IOExceptio
* @throws IOException in case of an I/O error
*/
public static boolean contentEquals(final File file1, final File file2) 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
@@ -571,6 +571,9 @@ public void testContentEquals() throws Exception {
// Non-existent files
final File file = new File(temporaryFolder, getName());
final File file2 = new File(temporaryFolder, getName() + "2");
+ assertTrue(FileUtils.contentEquals(null, null));
+ assertFalse(FileUtils.contentEquals(null, file));
+ assertFalse(FileUtils.contentEquals(file, null));
// both don't exist
assertTrue(FileUtils.contentEquals(file, file));
assertTrue(FileUtils.contentEquals(file, file2));

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