Commit c54ea4da authored by Matija Obreza's avatar Matija Obreza
Browse files

Avoid potential NPE

parent 00adbe9f
......@@ -87,12 +87,10 @@ public class FilesystemStorageServiceImpl implements BytesStorageService {
/*
* (non-Javadoc)
*
* @see org.genesys2.server.filerepository.service.BytesStorageService#upsert( java.lang.String, java.lang.String,
* byte[])
* @see org.genesys2.server.filerepository.service.BytesStorageService#upsert( java.lang.String, java.lang.String, byte[])
*/
@Override
public void upsert(final String path, final String filename, final byte[] data)
throws FileNotFoundException, IOException {
public void upsert(final String path, final String filename, final byte[] data) throws FileNotFoundException, IOException {
final File destinationDir = new File(repoDir, path);
if (!destinationDir.getCanonicalPath().startsWith(repoDir.getCanonicalPath()))
......@@ -127,11 +125,15 @@ public class FilesystemStorageServiceImpl implements BytesStorageService {
}
// Delete empty dir
if (destinationDir.exists() && destinationDir.isDirectory() && destinationDir.list().length == 0) {
if (LOG.isDebugEnabled()) {
LOG.debug("DELETING " + destinationDir.getAbsolutePath());
if (destinationDir.exists() && destinationDir.isDirectory()) {
String[] dirContents = destinationDir.list();
if (dirContents != null && dirContents.length == 0) {
if (LOG.isDebugEnabled()) {
LOG.debug("DELETING " + destinationDir.getAbsolutePath());
}
destinationDir.delete();
}
destinationDir.delete();
}
}
......@@ -195,7 +197,6 @@ public class FilesystemStorageServiceImpl implements BytesStorageService {
final File[] files = destinationDir.listFiles();
if (files == null)
return Collections.emptyList();
return Arrays.stream(files).filter(file -> !file.isDirectory()).map(file -> file.getName())
.collect(Collectors.toList());
return Arrays.stream(files).filter(file -> !file.isDirectory()).map(file -> file.getName()).collect(Collectors.toList());
}
}
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