Reviewers: MikeSamuel,
Description:
DOMImplementationRegistry.getDOMImplementation is documented to return
null if no implementation is available; handle that case with an
explicit error rather than continuing until NullPointerException.
Also standardize formatting of the related nearby code.
Please review this at http://codereview.appspot.com/1763041/show
Affected files:
M src/com/google/caja/parser/html/DomParser.java
Index: src/com/google/caja/parser/html/DomParser.java
===================================================================
--- src/com/google/caja/parser/html/DomParser.java (revision 4167)
+++ src/com/google/caja/parser/html/DomParser.java (working copy)
@@ -160,14 +160,19 @@
.getDOMImplementation(features);
} catch (ClassNotFoundException ex) {
throw new SomethingWidgyHappenedError(
- "Missing DOM implementation. Is Xerces on the classpath?",
ex);
+ "Missing DOM implementation. Is Xerces on the classpath?",
ex);
} catch (IllegalAccessException ex) {
- throw new SomethingWidgyHappenedError(
- "Missing DOM implementation. Is Xerces on the classpath?",
ex);
+ throw new SomethingWidgyHappenedError(
+ "Missing DOM implementation. Is Xerces on the classpath?",
ex);
} catch (InstantiationException ex) {
- throw new SomethingWidgyHappenedError(
- "Missing DOM implementation. Is Xerces on the classpath?",
ex);
+ throw new SomethingWidgyHappenedError(
+ "Missing DOM implementation. Is Xerces on the classpath?",
ex);
}
+ if (domImpl == null) {
+ throw new SomethingWidgyHappenedError(
+ "Missing DOM implementation. Is Xerces on the classpath? " +
+ "(DOMImplementationRegistry.getDOMImplementation returned
null.)");
+ }
}
DocumentType doctype = doctypeMaker != null