MAPREDUCE-6693. ArrayIndexOutOfBoundsException occurs when the length of the job name is equal to mapreduce.jobhistory.jobname.limit. Contributed by Ajith S.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/b3579305 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/b3579305 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/b3579305 Branch: refs/heads/YARN-3368 Commit: b3579305268bffc44a8041c5b75f15f01ebb9ce4 Parents: 9fe5828 Author: Akira Ajisaka <aajis...@apache.org> Authored: Tue May 17 20:19:01 2016 +0900 Committer: Akira Ajisaka <aajis...@apache.org> Committed: Tue May 17 20:19:01 2016 +0900 ---------------------------------------------------------------------- .../v2/jobhistory/FileNameIndexUtils.java | 2 +- .../v2/jobhistory/TestFileNameIndexUtils.java | 25 ++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/b3579305/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapreduce/v2/jobhistory/FileNameIndexUtils.java ---------------------------------------------------------------------- diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapreduce/v2/jobhistory/FileNameIndexUtils.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapreduce/v2/jobhistory/FileNameIndexUtils.java index 284fe80..aac3cb2 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapreduce/v2/jobhistory/FileNameIndexUtils.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapreduce/v2/jobhistory/FileNameIndexUtils.java @@ -311,7 +311,7 @@ public class FileNameIndexUtils { String encodedString, int limitLength) { assert(limitLength >= 0) : "limitLength should be positive integer"; - if (encodedString.length() < limitLength) { + if (encodedString.length() <= limitLength) { return encodedString; } http://git-wip-us.apache.org/repos/asf/hadoop/blob/b3579305/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/src/test/java/org/apache/hadoop/mapreduce/v2/jobhistory/TestFileNameIndexUtils.java ---------------------------------------------------------------------- diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/src/test/java/org/apache/hadoop/mapreduce/v2/jobhistory/TestFileNameIndexUtils.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/src/test/java/org/apache/hadoop/mapreduce/v2/jobhistory/TestFileNameIndexUtils.java index 6fa7dbc..f9322d8 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/src/test/java/org/apache/hadoop/mapreduce/v2/jobhistory/TestFileNameIndexUtils.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/src/test/java/org/apache/hadoop/mapreduce/v2/jobhistory/TestFileNameIndexUtils.java @@ -481,4 +481,29 @@ public class TestFileNameIndexUtils { Assert.assertNull("Queue name incorrect after decoding old history file", info.getQueueName()); } + + @Test + public void testTrimJobNameEqualsLimitLength() throws IOException { + int jobNameTrimLength = 9; + JobIndexInfo info = new JobIndexInfo(); + JobID oldJobId = JobID.forName(JOB_ID); + JobId jobId = TypeConverter.toYarn(oldJobId); + info.setJobId(jobId); + info.setSubmitTime(Long.parseLong(SUBMIT_TIME)); + info.setUser(USER_NAME); + info.setJobName(JOB_NAME); + info.setFinishTime(Long.parseLong(FINISH_TIME)); + info.setNumMaps(Integer.parseInt(NUM_MAPS)); + info.setNumReduces(Integer.parseInt(NUM_REDUCES)); + info.setJobStatus(JOB_STATUS); + info.setQueueName(QUEUE_NAME); + info.setJobStartTime(Long.parseLong(JOB_START_TIME)); + + String jobHistoryFile = FileNameIndexUtils.getDoneFileName(info, + jobNameTrimLength); + JobIndexInfo parsedInfo = FileNameIndexUtils.getIndexInfo(jobHistoryFile); + + Assert.assertEquals("Job name did not get trimmed correctly", info + .getJobName().substring(0, jobNameTrimLength), parsedInfo.getJobName()); + } } --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-commits-h...@hadoop.apache.org