Skip to content
Permalink
Browse files
[CXF-5158] Protect from getting an NPE if using a non-file based url
git-svn-id: https://svn.apache.org/repos/asf/cxf/xjc-utils/trunk@1509782 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
dkulp committed Aug 2, 2013
1 parent d699b3f commit d635d84a0ed8da2deb19712ef23c4ab0e039b2ea
Showing 1 changed file with 19 additions and 1 deletion.
@@ -141,11 +141,13 @@ class Listener extends XJCListener {
}

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 @@ private File mapFile(String s) {
//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 void warning(SAXParseException exception) {
}

public void info(SAXParseException exception) {
//System.out.println(mapFile(exception.getSystemId()));
}
}

0 comments on commit d635d84

Please sign in to comment.