INT-957, polishing, also going back to throwing MessageRejectionException from XmlValidatingMessageSelector
This commit is contained in:
@@ -100,24 +100,14 @@ public class MessageFilter extends AbstractReplyProducingMessageHandler {
|
||||
|
||||
@Override
|
||||
protected Object handleRequestMessage(Message<?> message) {
|
||||
Throwable filterException = null;
|
||||
try {
|
||||
if (this.selector.accept(message)) {
|
||||
return message;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
filterException = e;
|
||||
}
|
||||
if (this.selector.accept(message)) {
|
||||
return message;
|
||||
}
|
||||
if (this.discardChannel != null) {
|
||||
this.getMessagingTemplate().send(this.discardChannel, message);
|
||||
}
|
||||
if (this.throwExceptionOnRejection) {
|
||||
if (filterException != null){
|
||||
throw new MessageRejectedException(message, "MessageFilter '" + this.getComponentName() + "' rejected Message", filterException);
|
||||
}
|
||||
else {
|
||||
throw new MessageRejectedException(message, "MessageFilter '" + this.getComponentName() + "' rejected Message");
|
||||
}
|
||||
throw new MessageRejectedException(message, "MessageFilter '" + this.getComponentName() + "' rejected Message");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.integration.xml.selector;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessageHandlingException;
|
||||
import org.springframework.integration.MessageRejectedException;
|
||||
import org.springframework.integration.core.MessageSelector;
|
||||
import org.springframework.integration.xml.AggregatedXmlMessageValidationException;
|
||||
import org.springframework.integration.xml.DefaultXmlPayloadConverter;
|
||||
@@ -76,7 +77,8 @@ public class XmlValidatingMessageSelector implements MessageSelector {
|
||||
}
|
||||
boolean validationSuccess = ObjectUtils.isEmpty(validationExceptions);
|
||||
if (!validationSuccess && throwExceptionOnRejection){
|
||||
throw new AggregatedXmlMessageValidationException(CollectionUtils.arrayToList(validationExceptions));
|
||||
throw new MessageRejectedException(message, "Message was rejected due to XML Validation errors",
|
||||
new AggregatedXmlMessageValidationException(CollectionUtils.arrayToList(validationExceptions)));
|
||||
}
|
||||
return validationSuccess;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user