From 286ae1edd09987444644c13dec3b55ab783ec33e Mon Sep 17 00:00:00 2001 From: Chris Nauroth Date: Mon, 7 Jul 2014 19:56:44 +0000 Subject: [PATCH] MAPREDUCE-5866. TestFixedLengthInputFormat fails in windows. Contributed by Varun Vasudev. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1608585 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-mapreduce-project/CHANGES.txt | 3 +++ .../hadoop/mapred/TestFixedLengthInputFormat.java | 9 ++++++--- .../lib/input/TestFixedLengthInputFormat.java | 15 +++++++++------ 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/hadoop-mapreduce-project/CHANGES.txt b/hadoop-mapreduce-project/CHANGES.txt index ffe834fa49..e9732b8922 100644 --- a/hadoop-mapreduce-project/CHANGES.txt +++ b/hadoop-mapreduce-project/CHANGES.txt @@ -157,6 +157,9 @@ Release 2.6.0 - UNRELEASED BUG FIXES + MAPREDUCE-5866. TestFixedLengthInputFormat fails in windows. + (Varun Vasudev via cnauroth) + Release 2.5.0 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/TestFixedLengthInputFormat.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/TestFixedLengthInputFormat.java index c922842448..8013feb1ba 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/TestFixedLengthInputFormat.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/TestFixedLengthInputFormat.java @@ -372,10 +372,13 @@ public class TestFixedLengthInputFormat { format.getRecordReader(split, job, voidReporter); LongWritable key = reader.createKey(); BytesWritable value = reader.createValue(); - while (reader.next(key, value)) { - result.add(new String(value.getBytes(), 0, value.getLength())); + try { + while (reader.next(key, value)) { + result.add(new String(value.getBytes(), 0, value.getLength())); + } + } finally { + reader.close(); } - reader.close(); return result; } diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapreduce/lib/input/TestFixedLengthInputFormat.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapreduce/lib/input/TestFixedLengthInputFormat.java index dc3a1db9ac..b82b495f1c 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapreduce/lib/input/TestFixedLengthInputFormat.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapreduce/lib/input/TestFixedLengthInputFormat.java @@ -417,15 +417,18 @@ public class TestFixedLengthInputFormat { new MapContextImpl(job.getConfiguration(), context.getTaskAttemptID(), reader, null, null, MapReduceTestUtil.createDummyReporter(), split); - reader.initialize(split, mcontext); LongWritable key; BytesWritable value; - while (reader.nextKeyValue()) { - key = reader.getCurrentKey(); - value = reader.getCurrentValue(); - result.add(new String(value.getBytes(), 0, value.getLength())); + try { + reader.initialize(split, mcontext); + while (reader.nextKeyValue()) { + key = reader.getCurrentKey(); + value = reader.getCurrentValue(); + result.add(new String(value.getBytes(), 0, value.getLength())); + } + } finally { + reader.close(); } - reader.close(); return result; }