Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/ConfigurationErrorHandler.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/ConfigurationErrorHandler.java (revision 693404)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/ConfigurationErrorHandler.java (working copy)
@@ -37,6 +37,7 @@
*/
public void error(SAXParseException exception) throws SAXException {
logError("Error", exception);
+ throw exception;
}
private void logError(String type, SAXParseException exception) {
@@ -49,6 +50,7 @@
*/
public void fatalError(SAXParseException exception) throws SAXException {
logError("Fatal error", exception);
+ throw exception;
}
/**
Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/ConfigurationParser.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/ConfigurationParser.java (revision 693404)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/ConfigurationParser.java (working copy)
@@ -252,25 +252,31 @@
* @return named child element, or null if not found and
* required is false.
* @throws ConfigurationException if the child element is not found and
- * required is true.
+ * required is true;
+ * or if more than one element with this name exists.
*/
protected Element getElement(Element parent, String name, boolean required)
throws ConfigurationException {
NodeList children = parent.getChildNodes();
+ Element found = null;
for (int i = 0; i < children.getLength(); i++) {
Node child = children.item(i);
if (child.getNodeType() == Node.ELEMENT_NODE
&& name.equals(child.getNodeName())) {
- return (Element) child;
+ if (found != null) {
+ throw new ConfigurationException(
+ "Duplicate configuration element " + name + " in "
+ + parent.getNodeName() + ".");
+ }
+ found = (Element) child;
}
}
- if (required) {
+ if (required && found == null) {
throw new ConfigurationException(
"Configuration element " + name + " not found in "
+ parent.getNodeName() + ".");
- } else {
- return null;
}
+ return found;
}
/**