Skip to content

Commit

Permalink
vault: handle exception in childIterator
Browse files Browse the repository at this point in the history
fix NPE on first run of DataNodeSizeWorkerSync
fix no content check in files GetAction
  • Loading branch information
pdowler committed Sep 24, 2024
1 parent 9cbbdbb commit 71fc17d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ public ResourceIterator<Node> iterator(ContainerNode parent, Integer limit, Stri
private class ChildNodeWrapper implements ResourceIterator<Node> {

private final ContainerNode parent;
private final ResourceIterator<Node> childIter;
private ResourceIterator<Node> childIter;
private boolean closedForException = false;

private final IdentityManager identityManager = AuthenticationUtil.getIdentityManager();
Expand Down
10 changes: 9 additions & 1 deletion vault/src/main/java/org/opencadc/vault/files/GetAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public void doAction() throws Exception {
boolean noArtifact = node.bytesUsed == null || node.bytesUsed == 0L;
noArtifact = noArtifact && nodePersistence.preventNotFound && rn.artifact == null;
if (noArtifact) {
// no file
// no artifact found by preventNotFound
syncOutput.setCode(HttpURLConnection.HTTP_NO_CONTENT);
return;
}
Expand All @@ -126,6 +126,14 @@ public void doAction() throws Exception {
rn.protos = tg.getEndpoints(targetURI, pullTransfer, null);
rn.artifact = tg.resolvedArtifact; // currently unused at this point
}
// check artifact again (!preventNotFound)
noArtifact = node.bytesUsed == null || node.bytesUsed == 0L;
noArtifact = noArtifact && rn.artifact == null;
if (noArtifact) {
// no file
syncOutput.setCode(HttpURLConnection.HTTP_NO_CONTENT);
return;
}

if (rn.protos.isEmpty()) {
throw new TransientException("No location found for file " + Utils.getPath(node));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,11 @@ public void setOperation(String op) {
}

public void setLastModified(Date ts) {
DateFormat df = DateUtil.getDateFormat(DateUtil.IVOA_DATE_FORMAT, DateUtil.UTC);
this.lastmodified = df.format(ts);
if (ts != null) {
DateFormat df = DateUtil.getDateFormat(DateUtil.IVOA_DATE_FORMAT, DateUtil.UTC);
this.lastmodified = df.format(ts);
} else {
this.lastmodified = null;
}
}


}

0 comments on commit 71fc17d

Please sign in to comment.