Community
Participate
Working Groups
Build Identifier: 3.3.0M6 There are no checking for null at the following line of the method DocumentImpl.getCMAttributes(...): CMElementDeclaration decl = ModelQueryUtil.getModelQuery(this).getCMElementDeclaration(element); Reproducible: Always Steps to Reproduce: 1. Run attached JUnit
Created attachment 192314 [details] JUnit for the bug
Created attachment 192315 [details] JUnit for the bug (as plain text)
Created attachment 192316 [details] Stack trace
Created attachment 192317 [details] Simple patch Did not dig deep this bug, but this helps.
Hi, Thanks for your bug report and the patch. While we should probably guard against the case of the null pointer here there is also some initialization of the model that your test cases misses. In the specific example provided, a lot of the model initialization process has been missed including adding the correct adapters for the ModelQuery. It is this adapter that provides the proper ModelQuery used. Since it's not present, and under most circumstances it would be, you'll get a null ModelQuery. If you wanted to get everything initialized properly, we use this frequently in our unit tests to get an IDOMModel: (IDOMModel) StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(ContentTypeIdForJSP.ContentTypeID_JSP);
Hi Nick, Thank you for the initialization snippet, it has helped me a lot! I think this is OK, if the code throws exceptions in the cases when the model is initialized incorrectly.
I checked in your changes. Thanks.