From 63d52143323015f5672a04d793470a8595d0bc0c 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. (cherry picked from commit d3fef7a5c5b83d27e87b5e49928254a7d1b935e5) --- .../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 f83c1ac346f..ae19b213040 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; }