MAPREDUCE-7494. File stream leak when LineRecordReader is interrupted (#7117)

Contributed by Davin Tjong
This commit is contained in:
Davin Tjong 2024-10-16 03:41:18 -07:00 committed by GitHub
parent 9321e322d2
commit 78a08b3b78
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 44 additions and 37 deletions

View File

@ -302,6 +302,8 @@ public synchronized void close() throws IOException {
try { try {
if (in != null) { if (in != null) {
in.close(); in.close();
} else if (fileIn != null) {
fileIn.close();
} }
} finally { } finally {
if (decompressor != null) { if (decompressor != null) {

View File

@ -99,6 +99,7 @@ public void initialize(InputSplit genericSplit,
MRJobConfig.INPUT_FILE_MANDATORY_PREFIX); MRJobConfig.INPUT_FILE_MANDATORY_PREFIX);
fileIn = FutureIO.awaitFuture(builder.build()); fileIn = FutureIO.awaitFuture(builder.build());
try {
CompressionCodec codec = new CompressionCodecFactory(job).getCodec(file); CompressionCodec codec = new CompressionCodecFactory(job).getCodec(file);
if (null!=codec) { if (null!=codec) {
isCompressedInput = true; isCompressedInput = true;
@ -138,6 +139,10 @@ public void initialize(InputSplit genericSplit,
start += in.readLine(new Text(), 0, maxBytesToConsume(start)); start += in.readLine(new Text(), 0, maxBytesToConsume(start));
} }
this.pos = start; this.pos = start;
} catch (Exception e) {
fileIn.close();
throw e;
}
} }