smallrye-config: Injecting an undefined Config Property value with an Optional Converter returns the wrong value
For the following ConfigProperty Injection:
@Inject
@ConfigProperty(name = "unknown") // where unknown is not defined anywhere
Optional<MyStringObject> unknownOptional; // where MyStringObject is a simple class with a get and set method for a String
Which has the following Converter:
public class MyStringObjectConverter implements Converter<MyStringObject> {
@Override
public MyStringObject convert(String value) {
MyStringObject obj = new MyStringObject();
obj.setValue(value);
return obj;
}
}
The SmallRye implementation returns the following unknownOptional:
unknownOptional.isPresent() -> true
unknownOptional.get().getValue() -> ""
According to the MP Config specification, I think this should be:
unknownOptional.isPresent() -> false
unknownOptional.get().getValue() -> Exception
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 17 (17 by maintainers)
Yes!