From: <bo...@us...> - 2008-06-06 14:00:07
|
Revision: 267 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=267&view=rev Author: bodewig Date: 2008-06-06 07:00:14 -0700 (Fri, 06 Jun 2008) Log Message: ----------- Add an explicit null guard for issue 1985229 Modified Paths: -------------- trunk/xmlunit/src/java/org/custommonkey/xmlunit/SimpleXpathEngine.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/exceptions/XpathException.java trunk/xmlunit/src/user-guide/XMLUnit-Java.xml Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/SimpleXpathEngine.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/SimpleXpathEngine.java 2008-06-06 13:45:43 UTC (rev 266) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/SimpleXpathEngine.java 2008-06-06 14:00:14 UTC (rev 267) @@ -1,6 +1,6 @@ /* ****************************************************************** -Copyright (c) 2001-2007, Jeff Martin, Tim Bacon +Copyright (c) 2001-2008, Jeff Martin, Tim Bacon All rights reserved. Redistribution and use in source and binary forms, with or without @@ -123,16 +123,23 @@ * @param xslt * @param document * @param result + * @throws XpathException * @throws TransformerException * @throws ConfigurationException */ private void performTransform(String xslt, Document document, Result result) - throws TransformerException, ConfigurationException { + throws TransformerException, ConfigurationException, XpathException { try { StreamSource source = new StreamSource(new StringReader(xslt)); Transformer transformer = XMLUnit.getTransformerFactory().newTransformer(source); + // Issue 1985229 says Xalan-J 2.7.0 may return null for + // illegal input + if (transformer == null) { + throw new XpathException("failed to obtain an XSLT transformer" + + " for XPath expression."); + } transformer.transform(new DOMSource(document), result); } catch (javax.xml.transform.TransformerConfigurationException ex) { throw new ConfigurationException(ex); @@ -149,7 +156,7 @@ * @return the root node of the Document created by the copy-of transform. */ protected Node getXPathResultNode(String select, Document document) - throws ConfigurationException, TransformerException { + throws ConfigurationException, TransformerException, XpathException { return getXPathResultAsDocument(select, document).getDocumentElement(); } @@ -164,7 +171,7 @@ */ protected Document getXPathResultAsDocument(String select, Document document) - throws ConfigurationException, TransformerException { + throws ConfigurationException, TransformerException, XpathException { DOMResult result = new DOMResult(); performTransform(getCopyTransformation(select), document, result); return (Document) result.getNode(); Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/exceptions/XpathException.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/exceptions/XpathException.java 2008-06-06 13:45:43 UTC (rev 266) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/exceptions/XpathException.java 2008-06-06 14:00:14 UTC (rev 267) @@ -1,6 +1,6 @@ /* ****************************************************************** -Copyright (c) 2006-2007, Jeff Martin, Tim Bacon +Copyright (c) 2006-2008, Jeff Martin, Tim Bacon All rights reserved. Redistribution and use in source and binary forms, with or without @@ -57,6 +57,16 @@ * @param message the detail message * @param cause the root cause of the exception */ + public XpathException(String message) { + this(message, null); + } + + /** + * Inititializes the exeption. + * + * @param message the detail message + * @param cause the root cause of the exception + */ public XpathException(String message, Throwable t) { super(message, t); } Modified: trunk/xmlunit/src/user-guide/XMLUnit-Java.xml =================================================================== --- trunk/xmlunit/src/user-guide/XMLUnit-Java.xml 2008-06-06 13:45:43 UTC (rev 266) +++ trunk/xmlunit/src/user-guide/XMLUnit-Java.xml 2008-06-06 14:00:14 UTC (rev 267) @@ -3429,6 +3429,13 @@ presence of CDATA sections. <ulink href="https://sourceforge.net/tracker/index.php?func=detail&aid=1903923&group_id=23187&atid=377768">Issue 1903923</ulink>.</listitem> + + <listitem> + Two protected methods + in <literal>SimpleXPathEngine</literal> (which you + shouldn't extend anyway) have added XpathException to + their throws list. + </listitem> </itemizedlist> </section> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |