diff --git a/hadoop-mapreduce-project/CHANGES.txt b/hadoop-mapreduce-project/CHANGES.txt index 5491d1cd5e..835ce61924 100644 --- a/hadoop-mapreduce-project/CHANGES.txt +++ b/hadoop-mapreduce-project/CHANGES.txt @@ -244,6 +244,9 @@ Release 2.5.0 - UNRELEASED MAPREDUCE-5862. Line records longer than 2x split size aren't handled correctly (bc Wong via jlowe) + MAPREDUCE-5895. Close streams properly to avoid leakage in TaskLog. + (Kousuke Saruta via devaraj) + Release 2.4.1 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/TaskLog.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/TaskLog.java index 48640ab79c..a86e76a4ce 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/TaskLog.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/TaskLog.java @@ -199,16 +199,18 @@ void writeToIndexFile(String logLocation, // file first and then rename. File tmpIndexFile = getTmpIndexFile(currentTaskid, isCleanup); - BufferedOutputStream bos = - new BufferedOutputStream( - SecureIOUtils.createForWrite(tmpIndexFile, 0644)); - DataOutputStream dos = new DataOutputStream(bos); - //the format of the index file is - //LOG_DIR: - //STDOUT: - //STDERR: - //SYSLOG: + BufferedOutputStream bos = null; + DataOutputStream dos = null; try{ + bos = new BufferedOutputStream( + SecureIOUtils.createForWrite(tmpIndexFile, 0644)); + dos = new DataOutputStream(bos); + //the format of the index file is + //LOG_DIR: + //STDOUT: + //STDERR: + //SYSLOG: + dos.writeBytes(LogFileDetail.LOCATION + logLocation + "\n" + LogName.STDOUT.toString() + ":"); dos.writeBytes(Long.toString(prevOutLength) + " "); @@ -225,8 +227,10 @@ void writeToIndexFile(String logLocation, + "\n"); dos.close(); dos = null; + bos.close(); + bos = null; } finally { - IOUtils.cleanup(LOG, dos); + IOUtils.cleanup(LOG, dos, bos); } File indexFile = getIndexFile(currentTaskid, isCleanup);