[QFJ-201] Potential null pointer in DataDictionary.isMsgField Created: 20/Jun/07 Updated: 11/Feb/09 Resolved: 20/Jun/07 |
|
| Status: | Closed |
| Project: | QuickFIX/J |
| Component/s: | Metadata/Specs |
| Affects Version/s: | 1.1.0 |
| Fix Version/s: | 1.2.1 |
| Type: | Bug | Priority: | Trivial |
| Reporter: | Brad Harvey | Assignee: | Steve Bate |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
isMsgField uses single & after a null check - since & doesn't short circuit it throws null pointer if fields is null. Change from: public boolean isMsgField(String msgType, int field) { Set fields = (Set) messageFields.get(msgType); return fields != null & fields.contains(new Integer(field)); }to public boolean isMsgField(String msgType, int field) { Set fields = (Set) messageFields.get(msgType); return fields != null && fields.contains(new Integer(field)); }Unit test - add the following to DataDictionaryTest.testDictionary() assertFalse(dd.isMsgField("UNKNOWN_TYPE", 1)); |
| Comments |
| Comment by Toli Kuznets [ 20/Jun/07 ] |
|
Great catch, Brad! |
| Comment by Brad Harvey [ 21/Jun/07 ] |
|
Credit for the catch goes to IntelliJ IDEA's code analysis |