Author: mrglavas
Date: Wed May  1 20:39:04 2013
New Revision: 1478179

URL: http://svn.apache.org/r1478179
Log:
Fixing JIRA Issue #1611: https://issues.apache.org/jira/browse/XERCESJ-1611. 
Adding a null check to guard against an NPE that can occur when the 
content-type returned from the URLconnection is null.

Modified:
    xerces/java/trunk/src/org/apache/xerces/xinclude/XIncludeTextReader.java

Modified: 
xerces/java/trunk/src/org/apache/xerces/xinclude/XIncludeTextReader.java
URL: 
http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/xinclude/XIncludeTextReader.java?rev=1478179&r1=1478178&r2=1478179&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/xinclude/XIncludeTextReader.java 
(original)
+++ xerces/java/trunk/src/org/apache/xerces/xinclude/XIncludeTextReader.java 
Wed May  1 20:39:04 2013
@@ -149,12 +149,12 @@ public class XIncludeTextReader {
                 stream = new BufferedInputStream(urlCon.getInputStream());
                 
                 // content type will be string like "text/xml; charset=UTF-8" 
or "text/xml"
-                String rawContentType = urlCon.getContentType();
+                final String rawContentType = urlCon.getContentType();
                 
                 // text/xml and application/xml offer only one optional 
parameter
-                int index = (rawContentType != null) ? 
rawContentType.indexOf(';') : -1;
+                final int index = (rawContentType != null) ? 
rawContentType.indexOf(';') : -1;
 
-                String contentType = null;
+                final String contentType;
                 String charset = null;
                 if (index != -1) {
                     // this should be something like "text/xml"
@@ -181,7 +181,7 @@ public class XIncludeTextReader {
                     }
                 }
                 else {
-                    contentType = rawContentType.trim();
+                    contentType = (rawContentType != null) ? 
rawContentType.trim() : "";
                 }
 
                 String detectedEncoding = null;



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to