]> source.dussan.org Git - jgit.git/commitdiff
[findbugs] Do not ignore exceptional return value of createNewFile() 06/2106/8
authorMatthias Sohn <matthias.sohn@sap.com>
Mon, 10 Jan 2011 21:45:47 +0000 (22:45 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Fri, 28 Jan 2011 00:11:12 +0000 (01:11 +0100)
Properly handle return value of java.io.File.createNewFile().

Change-Id: I3a74cc84cd126ca1a0eaccc77b2944d783ff0747
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/FileResolverTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/filter/IndexDiffFilterTest.java

index a7e31a5d4ca38915ab709e661184acaddece6590..7009cf98a37ae80784a19a52f833bc82ce043ebb 100644 (file)
@@ -47,7 +47,6 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import java.io.File;
@@ -58,6 +57,7 @@ import org.eclipse.jgit.http.server.resolver.FileResolver;
 import org.eclipse.jgit.http.server.resolver.ServiceNotEnabledException;
 import org.eclipse.jgit.junit.LocalDiskRepositoryTestCase;
 import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.util.FileUtils;
 import org.junit.Test;
 
 public class FileResolverTest extends LocalDiskRepositoryTestCase {
@@ -116,8 +116,7 @@ public class FileResolverTest extends LocalDiskRepositoryTestCase {
                        fail("did not honor export-all flag");
                }
 
-               export.createNewFile();
-               assertTrue("has git-daemon-export-ok", export.exists());
+               FileUtils.createNewFile(export);
                resolver = new FileResolver(base, false /* require flag */);
                try {
                        resolver.open(null, name).close();
index 542e169d73d2655578adc222e8568edb6979e58b..4c103c83dac4d0a7995f9c5f286d0c1e76a35a2a 100644 (file)
@@ -56,6 +56,7 @@ import org.eclipse.jgit.lib.RepositoryTestCase;
 import org.eclipse.jgit.revwalk.RevCommit;
 import org.eclipse.jgit.treewalk.FileTreeIterator;
 import org.eclipse.jgit.treewalk.TreeWalk;
+import org.eclipse.jgit.util.FileUtils;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -537,8 +538,7 @@ public class IndexDiffFilterTest extends RepositoryTestCase {
 
        private void createEmptyFolder() throws Exception {
                File path = new File(db.getWorkTree(), FOLDER);
-               path.mkdir();
-               assertTrue(path.isDirectory());
+               FileUtils.mkdir(path);
        }
 
        private RevCommit createEmptyFolderAndCommit() throws Exception {
@@ -548,14 +548,12 @@ public class IndexDiffFilterTest extends RepositoryTestCase {
 
        private void createEmptyFolderUntracked() throws Exception {
                File path = new File(db.getWorkTree(), UNTRACKED_FOLDER);
-               path.mkdir();
-               assertTrue(path.isDirectory());
+               FileUtils.mkdir(path);
        }
 
        private void createEmptyFolderIgnored() throws Exception {
                File path = new File(db.getWorkTree(), IGNORED_FOLDER);
-               path.mkdir();
-               assertTrue(path.isDirectory());
+               FileUtils.mkdir(path);
                writeTrashFile(GITIGNORE, GITIGNORE + "\n" + IGNORED_FOLDER + "/");
        }