Consistent nullability of headers Map and MessagePostProcessor

Issue: SPR-15670
This commit is contained in:
Juergen Hoeller 2017-06-15 22:45:06 +02:00
parent 4a21fb27fc
commit 7e251274ee
5 changed files with 36 additions and 26 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -80,17 +80,19 @@ public abstract class AbstractDestinationResolvingMessagingTemplate<D> extends A
}
@Override
public <T> void convertAndSend(String destinationName, T payload, Map<String, Object> headers) {
public <T> void convertAndSend(String destinationName, T payload, @Nullable Map<String, Object> headers) {
convertAndSend(destinationName, payload, headers, null);
}
@Override
public <T> void convertAndSend(String destinationName, T payload, MessagePostProcessor postProcessor) {
public <T> void convertAndSend(String destinationName, T payload, @Nullable MessagePostProcessor postProcessor) {
convertAndSend(destinationName, payload, null, postProcessor);
}
@Override
public <T> void convertAndSend(String destinationName, T payload, @Nullable Map<String, Object> headers, @Nullable MessagePostProcessor postProcessor) {
public <T> void convertAndSend(String destinationName, T payload,
@Nullable Map<String, Object> headers, @Nullable MessagePostProcessor postProcessor) {
D destination = resolveDestination(destinationName);
super.convertAndSend(destination, payload, headers, postProcessor);
}
@ -120,8 +122,8 @@ public abstract class AbstractDestinationResolvingMessagingTemplate<D> extends A
}
@Override
public <T> T convertSendAndReceive(String destinationName, Object request, Map<String, Object> headers,
Class<T> targetClass) {
public <T> T convertSendAndReceive(String destinationName, Object request,
@Nullable Map<String, Object> headers, Class<T> targetClass) {
D destination = resolveDestination(destinationName);
return super.convertSendAndReceive(destination, request, headers, targetClass);
@ -129,15 +131,16 @@ public abstract class AbstractDestinationResolvingMessagingTemplate<D> extends A
@Override
public <T> T convertSendAndReceive(String destinationName, Object request, Class<T> targetClass,
MessagePostProcessor postProcessor) {
@Nullable MessagePostProcessor postProcessor) {
D destination = resolveDestination(destinationName);
return super.convertSendAndReceive(destination, request, targetClass, postProcessor);
}
@Override
public <T> T convertSendAndReceive(String destinationName, Object request, Map<String, Object> headers,
Class<T> targetClass, MessagePostProcessor postProcessor) {
public <T> T convertSendAndReceive(String destinationName, Object request,
@Nullable Map<String, Object> headers, Class<T> targetClass,
@Nullable MessagePostProcessor postProcessor) {
D destination = resolveDestination(destinationName);
return super.convertSendAndReceive(destination, request, headers, targetClass, postProcessor);

View File

@ -58,12 +58,16 @@ public abstract class AbstractMessagingTemplate<D> extends AbstractMessageReceiv
}
@Override
public <T> T convertSendAndReceive(D destination, Object request, @Nullable Map<String, Object> headers, Class<T> targetClass) {
public <T> T convertSendAndReceive(
D destination, Object request, @Nullable Map<String, Object> headers, Class<T> targetClass) {
return convertSendAndReceive(destination, request, headers, targetClass, null);
}
@Override
public <T> T convertSendAndReceive(Object request, Class<T> targetClass, @Nullable MessagePostProcessor postProcessor) {
public <T> T convertSendAndReceive(
Object request, Class<T> targetClass, @Nullable MessagePostProcessor postProcessor) {
return convertSendAndReceive(getRequiredDefaultDestination(), request, targetClass, postProcessor);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -74,8 +74,8 @@ public interface DestinationResolvingMessageRequestReplyOperations<D> extends Me
* the message could not be received, for example due to a timeout
*/
@Nullable
<T> T convertSendAndReceive(String destinationName, Object request, Map<String, Object> headers,
Class<T> targetClass) throws MessagingException;
<T> T convertSendAndReceive(String destinationName, Object request,
@Nullable Map<String, Object> headers, Class<T> targetClass) throws MessagingException;
/**
* Resolve the given destination name, convert the payload request Object
@ -92,8 +92,8 @@ public interface DestinationResolvingMessageRequestReplyOperations<D> extends Me
* the message could not be received, for example due to a timeout
*/
@Nullable
<T> T convertSendAndReceive(String destinationName, Object request,
Class<T> targetClass, MessagePostProcessor requestPostProcessor) throws MessagingException;
<T> T convertSendAndReceive(String destinationName, Object request, Class<T> targetClass,
@Nullable MessagePostProcessor requestPostProcessor) throws MessagingException;
/**
* Resolve the given destination name, convert the payload request Object
@ -111,7 +111,7 @@ public interface DestinationResolvingMessageRequestReplyOperations<D> extends Me
* the message could not be received, for example due to a timeout
*/
@Nullable
<T> T convertSendAndReceive(String destinationName, Object request, Map<String, Object> headers,
Class<T> targetClass, MessagePostProcessor requestPostProcessor) throws MessagingException;
<T> T convertSendAndReceive(String destinationName, Object request, @Nullable Map<String, Object> headers,
Class<T> targetClass, @Nullable MessagePostProcessor requestPostProcessor) throws MessagingException;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -60,7 +60,7 @@ public interface DestinationResolvingMessageSendingOperations<D> extends Message
* @param payload the Object to use as payload
* @param headers headers for the message to send
*/
<T> void convertAndSend(String destinationName, T payload, Map<String, Object> headers)
<T> void convertAndSend(String destinationName, T payload, @Nullable Map<String, Object> headers)
throws MessagingException;
/**
@ -73,7 +73,7 @@ public interface DestinationResolvingMessageSendingOperations<D> extends Message
* @param payload the Object to use as payload
* @param postProcessor the post processor to apply to the message
*/
<T> void convertAndSend(String destinationName, T payload, MessagePostProcessor postProcessor)
<T> void convertAndSend(String destinationName, T payload, @Nullable MessagePostProcessor postProcessor)
throws MessagingException;
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -92,7 +92,8 @@ public interface MessageRequestReplyOperations<D> {
* could not be received, for example due to a timeout
*/
@Nullable
<T> T convertSendAndReceive(D destination, Object request, @Nullable Map<String, Object> headers, Class<T> targetClass)
<T> T convertSendAndReceive(
D destination, Object request, @Nullable Map<String, Object> headers, Class<T> targetClass)
throws MessagingException;
/**
@ -108,7 +109,8 @@ public interface MessageRequestReplyOperations<D> {
* could not be received, for example due to a timeout
*/
@Nullable
<T> T convertSendAndReceive(Object request, Class<T> targetClass, @Nullable MessagePostProcessor requestPostProcessor)
<T> T convertSendAndReceive(
Object request, Class<T> targetClass, @Nullable MessagePostProcessor requestPostProcessor)
throws MessagingException;
/**
@ -142,7 +144,8 @@ public interface MessageRequestReplyOperations<D> {
* could not be received, for example due to a timeout
*/
@Nullable
<T> T convertSendAndReceive(D destination, Object request, @Nullable Map<String, Object> headers,
Class<T> targetClass, @Nullable MessagePostProcessor requestPostProcessor) throws MessagingException;
<T> T convertSendAndReceive(
D destination, Object request, @Nullable Map<String, Object> headers, Class<T> targetClass,
@Nullable MessagePostProcessor requestPostProcessor) throws MessagingException;
}