Author: dkulp
Date: Thu Nov 12 22:43:06 2009
New Revision: 835615
URL: http://svn.apache.org/viewvc?rev=835615&view=rev
Log:
Add some NPE checks
Modified:
cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLManagerImpl.java
Modified:
cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java?rev=835615&r1=835614&r2=835615&view=diff
==============================================================================
---
cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
(original)
+++
cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
Thu Nov 12 22:43:06 2009
@@ -743,7 +743,9 @@
}
public static Document read(XMLStreamReader reader, boolean recordLoc)
throws XMLStreamException {
Document doc = DOMUtils.createDocument();
- doc.setDocumentURI(new String(reader.getLocation().getSystemId()));
+ if (reader.getLocation().getSystemId() != null) {
+ doc.setDocumentURI(new String(reader.getLocation().getSystemId()));
+ }
readDocElements(doc, doc, reader, true, recordLoc);
return doc;
}
@@ -751,7 +753,9 @@
public static Document read(DocumentBuilder builder, XMLStreamReader
reader, boolean repairing)
throws XMLStreamException {
Document doc = builder.newDocument();
- doc.setDocumentURI(new String(reader.getLocation().getSystemId()));
+ if (reader.getLocation().getSystemId() != null) {
+ doc.setDocumentURI(new String(reader.getLocation().getSystemId()));
+ }
readDocElements(doc, reader, repairing);
return doc;
}
@@ -944,16 +948,18 @@
node.setAttributeNodeNS(attr);
}
public static XMLStreamReader createXMLStreamReader(InputSource src) {
+ String sysId = src.getSystemId() == null ? null : new
String(src.getSystemId());
+ String pubId = src.getPublicId() == null ? null : new
String(src.getPublicId());
if (src.getByteStream() != null) {
if (src.getEncoding() == null) {
- StreamSource ss = new StreamSource(src.getByteStream(),
src.getSystemId());
- ss.setPublicId(src.getPublicId());
+ StreamSource ss = new StreamSource(src.getByteStream(), sysId);
+ ss.setPublicId(pubId);
return createXMLStreamReader(ss);
}
return createXMLStreamReader(src.getByteStream(),
src.getEncoding());
} else if (src.getCharacterStream() != null) {
- StreamSource ss = new StreamSource(src.getCharacterStream(),
src.getSystemId());
- ss.setPublicId(src.getPublicId());
+ StreamSource ss = new StreamSource(src.getCharacterStream(),
sysId);
+ ss.setPublicId(pubId);
return createXMLStreamReader(ss);
}
throw new IllegalArgumentException("InputSource must have a ByteStream
or CharacterStream");
Modified:
cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLManagerImpl.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLManagerImpl.java?rev=835615&r1=835614&r2=835615&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLManagerImpl.java
(original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLManagerImpl.java
Thu Nov 12 22:43:06 2009
@@ -222,7 +222,9 @@
Document doc;
try {
doc = StaxUtils.read(StaxUtils.createXMLStreamReader(src), true);
- doc.setDocumentURI(new String(src.getSystemId()));
+ if (src.getSystemId() != null) {
+ doc.setDocumentURI(new String(src.getSystemId()));
+ }
} catch (Exception e) {
throw new WSDLException(WSDLException.PARSER_ERROR,
e.getMessage(), e);
}