check if sandbox is present before trying to read files from it
@@ -180,22 +180,26 @@ public class ModuleBuildResource {
Optional<SingularitySandbox> sandboxOptional = singularityClient.browseTaskSandBox(taskId.get(), taskId.get());
- java.util.Optional<SingularitySandboxFile> buildLogFile = sandboxOptional.get().getFiles().stream().filter(l -> Objects.equals(l.getName(), BUILD_LOG_NAME)).findFirst();
+
+ java.util.Optional<SingularitySandboxFile> buildLogFile = java.util.Optional.empty();
+ if (sandboxOptional.isPresent()) {
+ sandboxOptional.get().getFiles().stream().filter(l -> Objects.equals(l.getName(), BUILD_LOG_NAME)).findFirst();
+ }
+
if (buildLogFile.isPresent()) {
String host = sandboxOptional.get().getSlaveHostname();
int port = singularityConfiguration.getSlaveHttpPort();
String path = sandboxOptional.get().getFullPathToRoot() + "/" + sandboxOptional.get().getCurrentDirectory() + "/" + buildLogFile.get().getName();
String downloadEndpointPath = "/files/download.json";
URI uri = new URI("http", null, host, port, downloadEndpointPath, "?path=" + path, null);
- return Response.temporaryRedirect(uri)
- .build();
+ return Response.temporaryRedirect(uri).build();
}
+
try {
SingularityS3Log urlData = findS3ServiceLog(taskId.get());
String logUrl = urlData.getDownloadUrl();
URI uri = new URI(logUrl);
- return Response.temporaryRedirect(uri)
- .build();
+ return Response.temporaryRedirect(uri).build();
} catch (NotFoundException e) {
return Response.status(Response.Status.NOT_FOUND).build();
}
