Skip to content

Commit bf78baf

Browse files
committed
Applied the fix suggested by Mirko Friedenhagen in #IO-100. This isn't something that it's easy to write a unit test for, but it is very easy to write a platform dependent test and show that the new code correctly throws an exception for '/etc/passwd'
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/io/trunk@482411 13f79535-47bb-0310-9956-ffa450edef68
1 parent 1d0c2d0 commit bf78baf

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/java/org/apache/commons/io/FileUtils.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,10 @@ public static void touch(File file) throws IOException {
142142
OutputStream out = new FileOutputStream(file);
143143
IOUtils.closeQuietly(out);
144144
}
145-
file.setLastModified(System.currentTimeMillis());
145+
boolean success = file.setLastModified(System.currentTimeMillis());
146+
if(!success) {
147+
throw new IOException("Unable to set the last modification time for " + file);
148+
}
146149
}
147150

148151
//-----------------------------------------------------------------------

0 commit comments

Comments
 (0)