Hello Xindice developers, I just found a bug in org.apache.xindice.core.Collection, that resulted in a wrong "not a document" Exception.
Versions:
The error occurs in cvs- and 1.1b4-release.
What was wrong:
When inserting binary and xml-documents into the same collection, a
query results in an exception.
What did i fix:
I changed "Document getDocument(Object key)" to first have a look if
the ressource is a binary ressource, and then just returning null
instead of an XMLDocument, like if the ressource wasn't there at all.
How to test it:
I appended a small test class, and my change (not in diff-format, but
just replace the corresponding function, please.)
Ciao,
Mig-O
------------------------
public final Document getDocument(Object key) throws DBException {
if (log.isDebugEnabled()) {
log.debug(debugHeader() + "Get document: " + key);
}
Object entry = getEntry(key);
if (entry == null) {
return null;
}
if( entry instanceof byte[] ) {
return null;
}
if (!(entry instanceof Document)) {
throw new DBException(FaultCodes.COL_INVALID_RESULT,
"Resource '" + key + "' in collection '" +
getCanonicalName() + "' is not a document");
}
return (Document) entry;
}
EmbeddedXindiceTests.java
Description: Binary data
server.xml
Description: application/xml
