diff --git a/vscode-extensions/commons/commons-util/src/main/java/org/springframework/ide/vscode/commons/util/EnumValueParser.java b/vscode-extensions/commons/commons-util/src/main/java/org/springframework/ide/vscode/commons/util/EnumValueParser.java index e53c11ca3..c54a3761c 100644 --- a/vscode-extensions/commons/commons-util/src/main/java/org/springframework/ide/vscode/commons/util/EnumValueParser.java +++ b/vscode-extensions/commons/commons-util/src/main/java/org/springframework/ide/vscode/commons/util/EnumValueParser.java @@ -41,6 +41,12 @@ public class EnumValueParser implements ValueParser { } public Object parse(String str) { + // IMPORTANT: check the text FIRST before fetching values + // from the hints provider, as the hints provider may be expensive when resolving values + if (!StringUtil.hasText(str)) { + throw new IllegalArgumentException(createBlankTextErrorMessage()); + } + Collection values = this.values.get(); //If values is not known (null) then just assume the str is acceptable. if (values==null || values.contains(str)) { @@ -50,6 +56,10 @@ public class EnumValueParser implements ValueParser { } } + protected String createBlankTextErrorMessage() { + return "'"+typeName+"'" + " cannot be blank."; + } + protected String createErrorMessage(String parseString, Collection values2) { return "'"+parseString+"' is not valid for Enum '"+typeName+"'. Valid values are: "+values; }