Fix a resource leak in JobHelper (#10913)

Co-authored-by: Suneet Saldanha <suneet@apache.org>
This commit is contained in:
Benedict Jin 2021-03-20 08:02:31 +08:00 committed by GitHub
parent 8b4f966708
commit 82c4d9dd92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 4 deletions

View File

@ -370,10 +370,12 @@ public class JobHelper
{ {
if (hadoopJobId != null && hadoopJobIdFileName != null) { if (hadoopJobId != null && hadoopJobIdFileName != null) {
try (final OutputStream out = Files.newOutputStream(Paths.get(hadoopJobIdFileName))) { try (final OutputStream out = Files.newOutputStream(Paths.get(hadoopJobIdFileName))) {
HadoopDruidIndexerConfig.JSON_MAPPER.writeValue( try (final OutputStreamWriter osw = new OutputStreamWriter(out, StandardCharsets.UTF_8)) {
new OutputStreamWriter(out, StandardCharsets.UTF_8), HadoopDruidIndexerConfig.JSON_MAPPER.writeValue(
hadoopJobId osw,
); hadoopJobId
);
}
log.info("MR job id [%s] is written to the file [%s]", hadoopJobId, hadoopJobIdFileName); log.info("MR job id [%s] is written to the file [%s]", hadoopJobId, hadoopJobIdFileName);
} }
catch (IOException e) { catch (IOException e) {