Merge pull request #2198 from viniciusbds/master

Dealing with a possible null pointer dereference
This commit is contained in:
Antonin Delpeuch 2019-12-25 11:42:34 +01:00 committed by GitHub
commit 0bd6a0fbd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 8 deletions

View File

@ -86,13 +86,15 @@ public class SetProjectTagsCommand extends Command {
tag = tag.trim();
if (!tag.isEmpty()) {
if (allProjectTags!= null && allProjectTags.containsKey(tag)) {
allProjectTags.put(tag, allProjectTags.get(tag) + 1);
} else {
allProjectTags.put(tag, 1);
if (allProjectTags != null) {
if (allProjectTags.containsKey(tag)) {
allProjectTags.put(tag, allProjectTags.get(tag) + 1);
} else {
allProjectTags.put(tag, 1);
}
}
polishedTags.add(tag);
}
}
}
// Lets update the project tags
@ -101,4 +103,4 @@ public class SetProjectTagsCommand extends Command {
respond(response, "{ \"code\" : \"ok\" }");
}
}
}

View File

@ -194,7 +194,9 @@ public class FileProjectManager extends ProjectManager {
protected void tarDir(String relative, File dir, TarOutputStream tos) throws IOException{
File[] files = dir.listFiles();
if (files == null) return;
for (File file : files) {
if (file == null) continue;
if (!file.isHidden()) {
String path = relative + file.getName();
@ -333,7 +335,10 @@ public class FileProjectManager extends ProjectManager {
}
static protected void deleteDir(File dir) {
for (File file : dir.listFiles()) {
File[] files = dir.listFiles();
if (files == null) return;
for (File file : files) {
if (file == null) continue;
if (file.isDirectory()) {
deleteDir(file);
} else {
@ -377,7 +382,10 @@ public class FileProjectManager extends ProjectManager {
protected void recover() {
boolean recovered = false;
for (File file : _workspaceDir.listFiles()) {
File[] files = _workspaceDir.listFiles();
if (files == null) return;
for (File file : files) {
if (file == null) continue;
if (file.isDirectory() && !file.isHidden()) {
String dirName = file.getName();
if (file.getName().endsWith(PROJECT_DIR_SUFFIX)) {