Skip to content

Commit a83e3fc

Browse files
committed
MLE-21542 First batch of null checks
The one in AbstractCommand should knock out a lot of warnings.
1 parent 31fd99d commit a83e3fc

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

ml-app-deployer/src/main/java/com/marklogic/appdeployer/command/AbstractCommand.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,8 @@ protected File[] listFilesInDirectory(File dir) {
478478
if (files != null && files.length > 1) {
479479
Arrays.sort(files);
480480
}
481-
return files;
481+
// dir.listFiles is allowed to return null, so we do this so callers don't have to worry about null.
482+
return files != null ? files : new File[0];
482483
}
483484

484485
protected void logResourceDirectoryNotFound(File dir) {

ml-app-deployer/src/main/java/com/marklogic/appdeployer/command/AbstractResourceCommand.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,11 @@ protected File[] listFilesInDirectory(File resourceDir, CommandContext context)
212212
public void undo(CommandContext context) {
213213
if (deleteResourcesOnUndo) {
214214
setIncrementalMode(false);
215-
for (File resourceDir : getResourceDirs(context)) {
216-
processUndoOnResourceDir(context, resourceDir);
215+
File[] dirs = getResourceDirs(context);
216+
if (dirs != null) {
217+
for (File resourceDir : dirs) {
218+
processUndoOnResourceDir(context, resourceDir);
219+
}
217220
}
218221
}
219222
}

ml-app-deployer/src/main/java/com/marklogic/mgmt/selector/AbstractNameMatchingResourceSelector.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ protected void selectAmps(MapResourceSelection selection, ManageClient manageCli
7474
Namespace ns = Namespace.getNamespace("http://marklogic.com/manage/security");
7575
for (Element amp : amps.getListItems()) {
7676
String nameref = amp.getChildText("nameref", ns);
77-
if (nameMatches(nameref)) {
77+
if (nameref != null && nameMatches(nameref)) {
7878
String uriref = amp.getChildText("uriref", ns);
7979
selection.select(MapResourceSelection.AMPS, uriref);
8080
}

0 commit comments

Comments
 (0)