
| Key: |
QB-3653
|
| Type: |
Improvement
|
| Status: |
Resolved
|
| Resolution: |
Fixed
|
| Priority: |
Minor
|
| Assignee: |
Unassigned
|
| Reporter: |
Jerry Lee
|
| Votes: |
0
|
| Watchers: |
1
|
|
If you were logged in you would be able to see more operations.
|
|
|
QuickBuild
Created: 28/Dec/20 07:27 AM
Updated: 02/Feb/21 02:03 AM
|
|
| Component/s: |
None
|
| Affects Version/s: |
10.0.30
|
| Fix Version/s: |
10.0.31
|
|
|
Original Estimate:
|
Unknown
|
Remaining Estimate:
|
Unknown
|
Time Spent:
|
Unknown
|
|
Environment:
|
All platform
|
|
|
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;
}
}
```
|
|
Description
|
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;
}
}
``` |
Show » |
| There are no comments yet on this issue.
|
|