[jbosstools-issues] [JBoss JIRA] (ERT-319) NewXMLGenerator NPE [EBZ#459013]
Friendly Jira Robot (JIRA)
issues at jboss.org
Wed Jun 22 12:10:00 EDT 2016
[ https://issues.jboss.org/browse/ERT-319?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Friendly Jira Robot resolved ERT-319.
-------------------------------------
Resolution: Done
> NewXMLGenerator NPE [EBZ#459013]
> --------------------------------
>
> Key: ERT-319
> URL: https://issues.jboss.org/browse/ERT-319
> Project: Eclipse Release Train
> Issue Type: Task
> Components: WTP Source Editing
> Reporter: Friendly Jira Robot
> Labels: 3.8_M7, bzira, wst.xml
> Fix For: Neon (4.6) M7
>
>
> We use some WTP internal classes in our unit tests. We are experiencing an NPE in wst.xml code:
> The offending method reads as follows, with my own comments inline:
> public void createNamespaceInfoList() {
> List result = new Vector();
> if (cmDocument != null) {
> // result is set to null here
> result = (List) cmDocument.getProperty("http://org.eclipse.wst/cm/properties/completeNamespaceInfo"); //$NON-NLS-1$
> if (result != null) {
> // cut out for brevity
> }
> NamespaceInfoContentBuilder builder = new NamespaceInfoContentBuilder();
> builder.setBuildPolicy(ContentBuilder.BUILD_ONLY_REQUIRED_CONTENT);
> builder.visitCMNode(cmDocument);
> result.addAll(builder.list); // NPE HERE
> }
> namespaceInfoList = result;
> }
> result is initialized as a new Vector(); It then gets set to null when performing cmDocument.getProperty(etc). Later, an attempt to result.addAll(etc) fails because result is null.
> A possible rewriting of this code would be:
> public void createNamespaceInfoList() {
> List result = new Vector();
> if (cmDocument != null) {
> List result2 = (List) cmDocument.getProperty("http://org.eclipse.wst/cm/properties/completeNamespaceInfo"); //$NON-NLS-1$
> if (result2 != null) {
> result = result2;
> // cut out for brevity
> }
> NamespaceInfoContentBuilder builder = new NamespaceInfoContentBuilder();
> builder.setBuildPolicy(ContentBuilder.BUILD_ONLY_REQUIRED_CONTENT);
> builder.visitCMNode(cmDocument);
> result.addAll(builder.list); // NPE HERE
> }
> namespaceInfoList = result;
> }
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
More information about the jbosstools-issues
mailing list