ValidatingProcessor not thread-safe
-----------------------------------

                 Key: CAMEL-803
                 URL: https://issues.apache.org/activemq/browse/CAMEL-803
             Project: Apache Camel
          Issue Type: Bug
          Components: camel-core
    Affects Versions: 1.4.0
            Reporter: Martin Krasser


The method org.apache.camel.processor.validation.ValidatingProcessor.process() 
is executed concurrently but error information is stored in a shared 
errorHandler. Because each thread calls errorHandler.reset() it may clean 
errors written by another thread. The easiest way to fix this issue would be a 
synchronized block:

{code:java|title=ValidatingProcessor.java}
...
synchronized (errorHandler) {
    errorHandler.reset();
    validator.setErrorHandler(errorHandler);
    
    DOMResult result = new DOMResult();
    validator.validate(source, result);
    
    errorHandler.handleErrors(exchange, schema, result);
}
... 
{code}

The disadvantage of this solution is that is serializes threads. A locally 
created error handler would be preferrable ...


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to