log WARN message for irrelevant extractPayload

Added a WARN log message to HttpRequestExecutingMessageHandler.
The warn message will let the user know that the 'extractPayload' attribute is meaningless if the provided 'httpMethod' will not send a request body.
This commit is contained in:
Oleg Zhurakousky
2011-10-14 09:25:14 -04:00
committed by Mark Fisher
parent d9d3c14a6c
commit bb8409f96f
2 changed files with 39 additions and 1 deletions

View File

@@ -83,6 +83,8 @@ public class HttpRequestExecutingMessageHandler extends AbstractReplyProducingMe
private volatile Class<?> expectedResponseType;
private volatile boolean extractPayload = true;
private volatile boolean extractPayloadExplicitlySet = false;
private volatile String charset = "UTF-8";
@@ -93,7 +95,7 @@ public class HttpRequestExecutingMessageHandler extends AbstractReplyProducingMe
private final RestTemplate restTemplate;
private final StandardEvaluationContext evaluationContext;
/**
* Create a handler that will send requests to the provided URI.
@@ -139,6 +141,7 @@ public class HttpRequestExecutingMessageHandler extends AbstractReplyProducingMe
*/
public void setExtractPayload(boolean extractPayload) {
this.extractPayload = extractPayload;
this.extractPayloadExplicitlySet = true;
}
/**
@@ -223,6 +226,12 @@ public class HttpRequestExecutingMessageHandler extends AbstractReplyProducingMe
if (conversionService != null) {
this.evaluationContext.setTypeConverter(new StandardTypeConverter(conversionService));
}
if (!this.shouldIncludeRequestBody() && this.extractPayloadExplicitlySet){
if (logger.isWarnEnabled()){
logger.warn("The 'extractPayload' attribute has no meaning in the context of this handler since the provided HTTP Method is '" +
this.httpMethod + "', and no request body will be sent for that method.");
}
}
}
@Override