'Why Boolean is not accepting null value?
public Map<String, BigDecimal> getData(Set<String> ids, Boolean flag) {
Map<String, BigDecimal> data = new HashMap<>();
if(flag == null){
try {
data = *code logic*
} catch (RuntimeException e) {
log.error("Error occurred while fetching data : {}", e.getMessage());
}
}
else{
try {
data = *code logic*;
} catch (RuntimeException e) {
log.error("Error occurred while fetching data : {}", e.getMessage());
}
}
return data;
Whenever the value of flag is passed as null I am getting this error :
Failed to convert value of type 'java.lang.String' to required type 'java.lang.Boolean'; nested exception is java.lang.IllegalArgumentException: Invalid boolean value [null]
Why is this happening? Isn't the wrapper class Boolean supposed to hold values true, false and null?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
