(SIGAR-227) fix to prevent missing file(s) from aborting add operation prematurely

This commit is contained in:
Trevor Pounds 2010-09-29 14:22:02 -05:00 committed by Doug MacEachern
parent 87f0aa7f6f
commit 8a4c9f6eb0
1 changed files with 15 additions and 2 deletions

View File

@ -23,6 +23,8 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import org.apache.log4j.Logger;
public abstract class FileWatcher {
private Sigar sigar;
@ -31,6 +33,9 @@ public abstract class FileWatcher {
private Set files =
Collections.synchronizedSet(new HashSet());
private static final Logger log =
SigarLog.getLogger(FileWatcher.class.getName());
public abstract void onChange(FileInfo info);
public void onNotFound(FileInfo info) {
@ -66,14 +71,22 @@ public abstract class FileWatcher {
public void add(File[] files)
throws SigarException {
for (int i=0; i<files.length; i++) {
add(files[i]);
try {
add(files[i]);
} catch (SigarFileNotFoundException e) {
log.error("Cannot add file: " + files[i].getAbsolutePath(), e);
}
}
}
public void add(String[] files)
throws SigarException {
for (int i=0; i<files.length; i++) {
add(files[i]);
try {
add(files[i]);
} catch (SigarFileNotFoundException e) {
log.error("Cannot add file: " + files[i], e);
}
}
}