You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2013/08/02 19:18:10 UTC

svn commit: r1509782 - /cxf/xjc-utils/trunk/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractXSDToJavaMojo.java

Author: dkulp
Date: Fri Aug  2 17:18:09 2013
New Revision: 1509782

URL: http://svn.apache.org/r1509782
Log:
[CXF-5158] Protect from getting an NPE if using a non-file based url

Modified:
    cxf/xjc-utils/trunk/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractXSDToJavaMojo.java

Modified: cxf/xjc-utils/trunk/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractXSDToJavaMojo.java
URL: http://svn.apache.org/viewvc/cxf/xjc-utils/trunk/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractXSDToJavaMojo.java?rev=1509782&r1=1509781&r2=1509782&view=diff
==============================================================================
--- cxf/xjc-utils/trunk/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractXSDToJavaMojo.java (original)
+++ cxf/xjc-utils/trunk/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractXSDToJavaMojo.java Fri Aug  2 17:18:09 2013
@@ -141,11 +141,13 @@ public abstract class AbstractXSDToJavaM
         }
 
         public void error(SAXParseException exception) {
-            File file = mapFile(exception.getSystemId());
+            final String sysId = exception.getSystemId();
+            File file = mapFile(sysId);
             if (file != null && !errorfiles.contains(file)) {
                 buildContext.removeMessages(file);
                 errorfiles.add(file);
             }
+            
             buildContext.addMessage(file, exception.getLineNumber(), exception.getColumnNumber(),
                                     mapMessage(exception.getLocalizedMessage()),
                                     BuildContext.SEVERITY_ERROR, exception);
@@ -169,6 +171,21 @@ public abstract class AbstractXSDToJavaM
                     //ignore
                 }
             }
+            if (file == null) {
+                //Cannot pass a null into buildContext.addMessage.  Create a pointless
+                //File object that maps to the systemId
+                if (s == null) {
+                    file = new File("null");
+                } else {
+                    final String s2 = s;
+                    file = new File(s2) {
+                        private static final long serialVersionUID = 1L;
+                        public String getAbsolutePath() {
+                            return s2;
+                        }
+                    };
+                }
+            }                        
             return file;
         }
 
@@ -188,6 +205,7 @@ public abstract class AbstractXSDToJavaM
         }
 
         public void info(SAXParseException exception) {
+            //System.out.println(mapFile(exception.getSystemId()));
         }
     }