[NEUTRON-54] Null Pointer Exception while converting from Boolean to boolean Created: 09/Jul/15 Updated: 11/Feb/16 Resolved: 11/Feb/16 |
|
| Status: | Resolved |
| Project: | neutron |
| Component/s: | neutron-spi |
| Affects Version/s: | master |
| Fix Version/s: | None |
| Type: | Bug | ||
| Reporter: | Ruijing Guo | Assignee: | Ruijing Guo |
| Resolution: | Won't Do | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Operating System: All |
||
| External issue ID: | 3968 |
| Description |
|
in neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronNetwork.java, Null Pointer Exception while converting from Boolean to Boolean as: example: public boolean isAdminStateUp() { return adminStateUp; }//Null Pointer Exception when adminStateUp is null. Test Case: vagrant@node1:~/neutron$ cat TestA.java; javac TestA.java ; java TestA public boolean isAdminStateUp() { return adminStateUp; } public static void main(String[] args) { } |
| Comments |
| Comment by Isaku Yamahata [ 09/Jul/15 ] |
|
This applies to other classes in the directory. There is two interfaces
possible approach I can think of would be
This changes the semantics of Boolean getXXX(). it doesn't return null anymore.
thoughts? |
| Comment by Ruijing Guo [ 10/Jul/15 ] |
|
in NeutronNetwork.java, I like to change: 1. Change public initDefaults to private function and construction call initDefaults 2. deprecated instead of drop isXXX or getXXX. |
| Comment by Robert Varga [ 21/Nov/15 ] |
|
The following would work, too: public boolean isAdminStateUp() { return Boolean.TRUE.equals(adminStateUp); }The question is whether you need to differentiate the tri-state nature (up, down, unknown?). If not, I would suggest also changing the field type to 'boolean', as that is more memory-efficient. |
| Comment by Isaku Yamahata [ 11/Feb/16 ] |
|
Since this issue was hit during Ruijing was working on his modification and there is no actual impact on the existing code. If this is hit as actual bug, please re-open this bug. |