Skip to content

Commit

Permalink
Modified FileResolver to return empty if http response code is not 200.
Browse files Browse the repository at this point in the history
  • Loading branch information
csrster committed Jan 11, 2022
1 parent 34952e9 commit cbc5199
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ public void prepareJobInputOutput(FileSystem fileSystem) {
fileCount = filePaths.size();
log.info("{} found {} file(s) matching pattern '{}' to add to input file for {} job {}",
fileResolver.getClass().getName(), fileCount, filenamePattern, jobType, jobID);
if (fileCount == 0) {
log.warn("Zero input files found for job {}, {}. Proceeding with caution.", jobType, jobID);
}
try {
HadoopJobUtils.writeHadoopInputFileLinesToInputFile(filePaths, localInputTempFile);
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ private List<Path> getPaths(Pattern filepattern, boolean exactfilename) {
CloseableHttpClient httpClient = clientBuilder.getHttpsClient();

try (CloseableHttpResponse httpResponse = httpClient.execute(request)) {
int statusCode = httpResponse.getStatusLine().getStatusCode();
if (statusCode != 200) {
log.warn("FileResolver call to {} returned status code {}.", uri, statusCode);
return new ArrayList<>();
}
InputStream istr = httpResponse.getEntity().getContent();
List<String> results = IOUtils.readLines(istr);
return results.stream()
Expand Down

0 comments on commit cbc5199

Please sign in to comment.