Use correct type with set

- When target is set and only one option argument is given,
  we should not convert to list as user expects string to xxx
  Converter to work.
- This is how it used to work and previous changes caused
  regression.
- Bug is actually in an old parser and new parser works fine.
- Backport #667
- Fixes #669
This commit is contained in:
Janne Valkealahti
2023-02-18 14:21:08 +00:00
parent 3c44c7c976
commit 7ec5c194ff
2 changed files with 202 additions and 2 deletions

View File

@@ -478,9 +478,16 @@ public interface CommandParser {
// if it looks like type is a collection just get as list
// as conversion will happen later. we just need to know
// if user has Set, List, Collection, etc without worrying
// about generics.
// about generics. handle explicit size 1 so that we're
// able to handle string to xxx converter as that what
// user expects.
else if (type != null && type.asCollection() != ResolvableType.NONE) {
value = arguments.stream().collect(Collectors.toList());
if (arguments.size() == 1) {
value = arguments.get(0);
}
else {
value = arguments.stream().collect(Collectors.toList());
}
}
else {
if (!arguments.isEmpty()) {