(SIGAR-227) fix to prevent missing file(s) from aborting add operation prematurely
This commit is contained in:
parent
87f0aa7f6f
commit
8a4c9f6eb0
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue