Commit ccb8c5c2 authored by Fabien Viale's avatar Fabien Viale
Browse files

SchedulerBackup: handle null value returned by listFiles

additionally, improve logging
parent 3f89eab2
......@@ -145,12 +145,16 @@ public class ZipUtils extends FileUtils {
if (dirobject.isDirectory()) {
File[] fileList = dirobject.listFiles();
// Loop through the files
for (int i = 0; i < fileList.length; i++) {
if (fileList[i].isDirectory()) {
zipDirectory(fileList[i].getPath(), iBaseFolderLength, zos, crc);
} else if (fileList[i].isFile()) {
zipFile(fileList[i].getPath(), iBaseFolderLength, zos, crc);
if (fileList != null) {
for (int i = 0; i < fileList.length; i++) {
if (fileList[i].isDirectory()) {
zipDirectory(fileList[i].getPath(), iBaseFolderLength, zos, crc);
} else if (fileList[i].isFile()) {
zipFile(fileList[i].getPath(), iBaseFolderLength, zos, crc);
}
}
} else {
logger.warn("Problem accessing folder: " + dirobject);
}
} else {
throw new IOException(directoryName + " is not a directory.");
......
......@@ -128,7 +128,12 @@ public class SchedulerBackupRunner implements Runnable {
.map(target -> (new File(PASchedulerProperties.SCHEDULER_HOME.getValueAsString(),
target)).getAbsolutePath())
.toArray(String[]::new);
ZipUtils.zip(foldersToZip, backupFile, null);
LOGGER.info("Backup of the following folders : " + Arrays.toString(foldersToZip));
try {
ZipUtils.zip(foldersToZip, backupFile, null);
} catch (Exception e) {
LOGGER.error("Error when performing backup", e);
}
} else {
LOGGER.error("Cannot save a backup because backup configuredDestination folder does not exist: " +
configuredDestination);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment