[CXF-6090] Add some NPE guards in xmlbeans tooling.
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/1f860a92 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/1f860a92 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/1f860a92 Branch: refs/heads/3.0.x-fixes Commit: 1f860a92216fa630e7e3dc9e767a5cb0261d1677 Parents: 3c059f5 Author: Daniel Kulp <[email protected]> Authored: Fri Nov 7 13:16:39 2014 -0500 Committer: Daniel Kulp <[email protected]> Committed: Fri Nov 7 13:58:44 2014 -0500 ---------------------------------------------------------------------- .../cxf/xmlbeans/tools/XMLBeansToolingDataBinding.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/1f860a92/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansToolingDataBinding.java ---------------------------------------------------------------------- diff --git a/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansToolingDataBinding.java b/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansToolingDataBinding.java index a1a99ba..3bbedcf 100644 --- a/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansToolingDataBinding.java +++ b/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansToolingDataBinding.java @@ -42,6 +42,7 @@ import org.w3c.dom.Document; import org.xml.sax.EntityResolver; import org.xml.sax.InputSource; +import org.apache.cxf.common.jaxb.JAXBUtils; import org.apache.cxf.helpers.IOUtils; import org.apache.cxf.staxutils.StaxUtils; import org.apache.cxf.tools.common.ToolConstants; @@ -50,6 +51,7 @@ import org.apache.cxf.tools.common.ToolException; import org.apache.cxf.tools.common.model.DefaultValueWriter; import org.apache.cxf.tools.util.ClassCollector; import org.apache.cxf.tools.wsdlto.core.DataBindingProfile; +import org.apache.ws.commons.schema.constants.Constants; import org.apache.xmlbeans.SchemaGlobalElement; import org.apache.xmlbeans.SchemaProperty; import org.apache.xmlbeans.SchemaType; @@ -144,6 +146,9 @@ public class XMLBeansToolingDataBinding implements DataBindingProfile { if (type == null) { type = typeLoader.findDocumentType(qn); } + if (type == null) { + return null; + } ret = type.getFullJavaName(); if (ret.contains("$")) { @@ -157,6 +162,13 @@ public class XMLBeansToolingDataBinding implements DataBindingProfile { type = typeLoader.findType(qn); } + if (type == null + && Constants.URI_2001_SCHEMA_XSD.equals(qn.getNamespaceURI())) { + return JAXBUtils.builtInTypeToJavaType(qn.getLocalPart()); + } + if (type == null) { + return null; + } ret = type.getFullJavaName(); return ret.replace('$', '.'); }
