History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: QB-3653
Type: Improvement Improvement
Status: Open Open
Priority: Minor Minor
Assignee: Robin Shen
Reporter: Jerry Lee
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
QuickBuild

Improve "getBooleanValue" function in 'VariableWrapper.java'

Created: 28/Dec/20 07:27 AM   Updated: 28/Dec/20 07:27 AM
Component/s: None
Affects Version/s: 10.0.30
Fix Version/s: None

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown
Environment: All platform


 Description  « Hide
In case of 'getBooleanValue' function, it may raise Null Pointer Exception because of 'equalsIgnoreCase' withtou null check.
```
public boolean getBooleanValue() {
String value = getValue();
if (value.equalsIgnoreCase("y") || value.equalsIgnoreCase("t") ||
value.equalsIgnoreCase("yes") || value.equalsIgnoreCase("true")) {
return true;
} else {
return false;
}
}
```

Therefore, "value" should be checked if null before 'equalsIgnoreCase' to avoid Null Pointer Exception.
It would be better like shown below according to your coding style, I think.
```
public boolean getBooleanValue() {
String value = getValue();
        if (value == null)
            return false;

if (value.equalsIgnoreCase("y") || value.equalsIgnoreCase("t") ||
value.equalsIgnoreCase("yes") || value.equalsIgnoreCase("true")) {
return true;
} else {
return false;
}
}
```

 All   Comments   Work Log   Change History      Sort Order:
There are no comments yet on this issue.