Performance issue
-----------------
Key: XERCESJ-1258
URL: https://issues.apache.org/jira/browse/XERCESJ-1258
Project: Xerces2-J
Issue Type: Bug
Components: SAX
Affects Versions: 2.6.2
Environment: AIX
Reporter: Gerardo Corro
Priority: Blocker
Fix For: 2.6.2
The following snippet cuases tremendous CPU consumption, one xml file of 1Mb
size and schema size of 33kb can take up to one hour to be validated.
This problem does not occur in windows, but happens in AIX.
private boolean validateXmlVsSchema(String SchemaUrl, String xmlString) throws
ValidationException, SAXParseException, UnhandleableException {
File schema = new File(SchemaUrl);
log.debug("The schema is being searched at: " + SchemaUrl);
if ( !schema.exists() ) {
throw new UnhandleableException(ValidatorConstants.SCHEMA_NO T_FOUND_EXCEPTION,
new Exception(ValidatorConstants.SCHEMA_NOT_FOUND_EXCE PTION));
}
SAXParser parser = new SAXParser();
try{
parser.setFeature("http://xml.org/sax/features/validation", true);
parser.setFeature("http://apache.org/xml/features/validation/schema", true);
parser.setFeature("http://apache.org/xml/features/validation/schema-full-checking",
true);
parser.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation",
SchemaUrl );
Validator handler = new Validator();
parser.setErrorHandler(handler);
InputStream is = new ByteArrayInputStream( xmlString.getBytes("UTF-8"));
parser.parse(new InputSource(is));
if(handler.validationError==true){
log.error(clazzName + "-> " + ValidatorConstants.SCHEMA_VALIDATION_ERROR + ": "
+ handler.validationError +
"" + handler.saxParseException.getMessage(), handler.saxParseException);
throw handler.saxParseException;
} else {
log.debug(clazzName + "-> " + ValidatorConstants.DOCUMENT_VALIDATED );
return true;
}
} catch( java.io.UTFDataFormatException utfex){
log.info(clazzName + "-> Wrong utf: " + utfex.getMessage(), utfex );
} catch(java.io.IOException ioe){
log.error(clazzName + "-> IOException " + ioe.getMessage(), ioe);
throw new ValidationException(ValidatorConstants.SCHEMA_VALI DATION_EXCEPTION,
ioe);
} catch (SAXParseException e) {
log.error(clazzName + "-> SAXParseException " + e.getMessage(), e);
throw e;
} catch (SAXNotRecognizedException e) {
log.error(clazzName + "-> SAXNotRecognizedException " + e.getMessage(), e);
throw new ValidationException(ValidatorConstants.SCHEMA_VALI DATION_EXCEPTION,
e);
} catch (SAXNotSupportedException e) {
log.error(clazzName + "-> SAXNotSupportedException " + e.getMessage(), e);
throw new ValidationException(ValidatorConstants.SCHEMA_VALI DATION_EXCEPTION,
e);
} catch (SAXException e) {
log.error(clazzName + "-> SAXException " + e.getMessage(), e);
throw new ValidationException(ValidatorConstants.SCHEMA_VALI DATION_EXCEPTION,
e);
}
return true;
}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]