From d3fef7a5c5b83d27e87b5e49928254a7d1b935e5 Mon Sep 17 00:00:00 2001 From: Rohith Sharma K S Date: Tue, 21 Aug 2018 11:58:07 +0530 Subject: [PATCH] YARN-8129. Improve error message for invalid value in fields attribute. Contributed by Abhishek Modi. --- .../reader/TimelineReaderWebServicesUtils.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/reader/TimelineReaderWebServicesUtils.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/reader/TimelineReaderWebServicesUtils.java index efaecd22bb4..63529a4a28a 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/reader/TimelineReaderWebServicesUtils.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/reader/TimelineReaderWebServicesUtils.java @@ -214,7 +214,11 @@ public final class TimelineReaderWebServicesUtils { String[] strs = str.split(delimiter); EnumSet fieldList = EnumSet.noneOf(Field.class); for (String s : strs) { - fieldList.add(Field.valueOf(s.trim().toUpperCase())); + try { + fieldList.add(Field.valueOf(s.trim().toUpperCase())); + } catch (IllegalArgumentException e) { + throw new IllegalArgumentException(s + " is not a valid field."); + } } return fieldList; }