Skip to content

Commit be56324

Browse files
committed
Fix handling of empty option names
1 parent 523daa6 commit be56324

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

spring-shell-core/src/main/java/org/springframework/shell/core/command/adapter/MethodInvokerCommandAdapter.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ private List<Object> prepareArguments(CommandContext commandContext) {
135135
log.debug("Processing option for parameter: " + parameters[i].getName());
136136
char shortName = optionAnnotation.shortName();
137137
String longName = optionAnnotation.longName();
138+
if (shortName == ' ' && longName.isEmpty()) {
139+
throw new IllegalArgumentException(
140+
"Either shortName or longName (or both) must be provided for option on parameter '"
141+
+ parameters[i].getName() + "'");
142+
}
138143
boolean required = optionAnnotation.required();
139144
CommandOption commandOption = commandContext
140145
.getOptionByName(longName.isEmpty() ? String.valueOf(shortName) : longName);

0 commit comments

Comments
 (0)