mirror of
https://github.com/internetarchive/heritrix3.git
synced 2026-10-07 04:41:23 +00:00
Fix HER-1935 Many calls to File.mkdirs() and other file/dir methods don't check the return value. Also fix bug where pointless empty directories were created in scratch dir.
* BasicProfileTest.java, SelfTestBase.java, CrawlControllerTest.java, PrecedenceLoader.java, MigrateH1to3Tool.java, CrawlerLoggerModule.java, StatisticsTracker.java, CheckpointUtils.java, BdbUriUniqFilter.java, ARCWriterProcessorTest.java, WARCWriterProcessorTest.java, PersistProcessor.java, WriterPoolProcessor.java, PrefixFinderTest.java, StoredQueueTest.java, FileUtilsTest.java, ObjectIdentityBdbManualCacheTest.java, ObjectIdentityBdbCacheTest.java, ObjectPlusFilesOutputStream.java, TestUtils.java, TmpDirTestCase.java, Engine.java
Replace calls to File.mkdirs() with FileUtils.ensureWriteableDirectory(dir). In these cases the calls were either already in a spot where the possible IOException would be handled appropriately, or the line was trivially moved into such a block.
* ActionDirectory.java, Engine.java
replace calls to File.mkdirs() with FileUtils.ensureWriteableDirectory(dir), and throw IllegalStateException on failure
* BdbModule.java
setup() - replace call to File.mkdirs() with FileUtils.ensureWriteableDirectory(dir) and add "throws IOException" - conveniently the place where this method is called was already in a try block that catches IOException
* Checkpoint.java
generateFrom() - replace call to File.mkdirs() with FileUtils.ensureWriteableDirectory(dir) and add "throws IOException"
* CheckpointService.java
move call to Checkpoint.generateFrom() inside existing try block since it now can throw IOException
* Recorder.java
ensure(File) - replace call to File.mkdirs() with FileUtils.ensureWriteableDirectory(dir), and throw IllegalStateException on failure
new Recorder(File,String,int,int) - call ensure() on the correct object, the containing directory; and remove redundant call to ensure()
This commit is contained in:
1 parent
f7cc187b09
commit
f20b3eee30
29 files changed
+78
-63
No files matched your search
@@ -42,7 +42,7 @@ public class StoredQueueTest extends TmpDirTestCase {
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
this.envDir = new File(getTmpDir(),"StoredMapTest");
|
||||
this.envDir.mkdirs();
|
||||
org.archive.util.FileUtils.ensureWriteableDirectory(this.envDir);
|
||||
try {
|
||||
EnvironmentConfig envConfig = new EnvironmentConfig();
|
||||
envConfig.setTransactional(false);
|
||||
|
||||
@@ -82,7 +82,7 @@ public class PrefixFinderTest extends TmpDirTestCase {
|
||||
|
||||
File f = new File(getTmpDir(), "PrefixFinderText");
|
||||
FileUtils.deleteQuietly(f);
|
||||
f.mkdirs();
|
||||
org.archive.util.FileUtils.ensureWriteableDirectory(f);
|
||||
Environment bdbEnvironment = new Environment(f, config);
|
||||
DatabaseConfig dbConfig = new DatabaseConfig();
|
||||
dbConfig.setAllowCreate(true);
|
||||
|
||||
@@ -56,9 +56,9 @@ public class FileUtilsTest extends TmpDirTestCase {
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
this.srcDirFile = new File(getTmpDir(), srcDirName);
|
||||
this.srcDirFile.mkdirs();
|
||||
FileUtils.ensureWriteableDirectory(srcDirFile);
|
||||
this.tgtDirFile = new File(getTmpDir(), tgtDirName);
|
||||
this.tgtDirFile.mkdirs();
|
||||
FileUtils.ensureWriteableDirectory(tgtDirFile);
|
||||
addFiles();
|
||||
|
||||
zeroLengthLinesUnix = setUpLinesFile("zeroLengthLinesUnix",0,0,400,IOUtils.LINE_SEPARATOR_UNIX);
|
||||
|
||||
@@ -37,10 +37,10 @@ public class ObjectIdentityBdbCacheTest extends TmpDirTestCase {
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
File envDir = new File(getTmpDir(),"ObjectIdentityBdbCacheTest");
|
||||
envDir.mkdirs();
|
||||
File envDir = new File(getTmpDir(),"ObjectIdentityBdbCacheTest");
|
||||
org.archive.util.FileUtils.ensureWriteableDirectory(envDir);
|
||||
FileUtils.deleteDirectory(envDir);
|
||||
envDir.mkdirs();
|
||||
org.archive.util.FileUtils.ensureWriteableDirectory(envDir);
|
||||
env = EnhancedEnvironment.getTestEnvironment(envDir);
|
||||
this.cache = new ObjectIdentityBdbCache<IdentityCacheableWrapper<HashMap<String,String>>>();
|
||||
this.cache.initialize(env,"setUpCache",IdentityCacheableWrapper.class, env.getClassCatalog());
|
||||
|
||||
@@ -37,10 +37,10 @@ public class ObjectIdentityBdbManualCacheTest extends TmpDirTestCase {
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
File envDir = new File(getTmpDir(),"ObjectIdentityBdbCacheTest");
|
||||
envDir.mkdirs();
|
||||
File envDir = new File(getTmpDir(),"ObjectIdentityBdbCacheTest");
|
||||
org.archive.util.FileUtils.ensureWriteableDirectory(envDir);
|
||||
FileUtils.deleteDirectory(envDir);
|
||||
envDir.mkdirs();
|
||||
org.archive.util.FileUtils.ensureWriteableDirectory(envDir);
|
||||
env = EnhancedEnvironment.getTestEnvironment(envDir);
|
||||
this.cache = new ObjectIdentityBdbManualCache<IdentityCacheableWrapper<HashMap<String,String>>>();
|
||||
this.cache.initialize(env,"setUpCache",IdentityCacheableWrapper.class, env.getClassCatalog());
|
||||
|
||||
Reference in new issue
Block a user