From 7e251274ee574589d53e98a2042e731de4b8ac9c Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 15 Jun 2017 22:45:06 +0200 Subject: [PATCH] Consistent nullability of headers Map and MessagePostProcessor Issue: SPR-15670 --- ...DestinationResolvingMessagingTemplate.java | 21 +++++++++++-------- .../core/AbstractMessagingTemplate.java | 8 +++++-- ...esolvingMessageRequestReplyOperations.java | 14 ++++++------- ...tionResolvingMessageSendingOperations.java | 6 +++--- .../core/MessageRequestReplyOperations.java | 13 +++++++----- 5 files changed, 36 insertions(+), 26 deletions(-) diff --git a/spring-messaging/src/main/java/org/springframework/messaging/core/AbstractDestinationResolvingMessagingTemplate.java b/spring-messaging/src/main/java/org/springframework/messaging/core/AbstractDestinationResolvingMessagingTemplate.java index 22575b128b8..afc59d20911 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/core/AbstractDestinationResolvingMessagingTemplate.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/core/AbstractDestinationResolvingMessagingTemplate.java @@ -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 extends A } @Override - public void convertAndSend(String destinationName, T payload, Map headers) { + public void convertAndSend(String destinationName, T payload, @Nullable Map headers) { convertAndSend(destinationName, payload, headers, null); } @Override - public void convertAndSend(String destinationName, T payload, MessagePostProcessor postProcessor) { + public void convertAndSend(String destinationName, T payload, @Nullable MessagePostProcessor postProcessor) { convertAndSend(destinationName, payload, null, postProcessor); } @Override - public void convertAndSend(String destinationName, T payload, @Nullable Map headers, @Nullable MessagePostProcessor postProcessor) { + public void convertAndSend(String destinationName, T payload, + @Nullable Map headers, @Nullable MessagePostProcessor postProcessor) { + D destination = resolveDestination(destinationName); super.convertAndSend(destination, payload, headers, postProcessor); } @@ -120,8 +122,8 @@ public abstract class AbstractDestinationResolvingMessagingTemplate extends A } @Override - public T convertSendAndReceive(String destinationName, Object request, Map headers, - Class targetClass) { + public T convertSendAndReceive(String destinationName, Object request, + @Nullable Map headers, Class targetClass) { D destination = resolveDestination(destinationName); return super.convertSendAndReceive(destination, request, headers, targetClass); @@ -129,15 +131,16 @@ public abstract class AbstractDestinationResolvingMessagingTemplate extends A @Override public T convertSendAndReceive(String destinationName, Object request, Class targetClass, - MessagePostProcessor postProcessor) { + @Nullable MessagePostProcessor postProcessor) { D destination = resolveDestination(destinationName); return super.convertSendAndReceive(destination, request, targetClass, postProcessor); } @Override - public T convertSendAndReceive(String destinationName, Object request, Map headers, - Class targetClass, MessagePostProcessor postProcessor) { + public T convertSendAndReceive(String destinationName, Object request, + @Nullable Map headers, Class targetClass, + @Nullable MessagePostProcessor postProcessor) { D destination = resolveDestination(destinationName); return super.convertSendAndReceive(destination, request, headers, targetClass, postProcessor); diff --git a/spring-messaging/src/main/java/org/springframework/messaging/core/AbstractMessagingTemplate.java b/spring-messaging/src/main/java/org/springframework/messaging/core/AbstractMessagingTemplate.java index 8cdadd44702..6783dfb4d97 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/core/AbstractMessagingTemplate.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/core/AbstractMessagingTemplate.java @@ -58,12 +58,16 @@ public abstract class AbstractMessagingTemplate extends AbstractMessageReceiv } @Override - public T convertSendAndReceive(D destination, Object request, @Nullable Map headers, Class targetClass) { + public T convertSendAndReceive( + D destination, Object request, @Nullable Map headers, Class targetClass) { + return convertSendAndReceive(destination, request, headers, targetClass, null); } @Override - public T convertSendAndReceive(Object request, Class targetClass, @Nullable MessagePostProcessor postProcessor) { + public T convertSendAndReceive( + Object request, Class targetClass, @Nullable MessagePostProcessor postProcessor) { + return convertSendAndReceive(getRequiredDefaultDestination(), request, targetClass, postProcessor); } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/core/DestinationResolvingMessageRequestReplyOperations.java b/spring-messaging/src/main/java/org/springframework/messaging/core/DestinationResolvingMessageRequestReplyOperations.java index 4b8d2ca5d81..979143eea5b 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/core/DestinationResolvingMessageRequestReplyOperations.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/core/DestinationResolvingMessageRequestReplyOperations.java @@ -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 extends Me * the message could not be received, for example due to a timeout */ @Nullable - T convertSendAndReceive(String destinationName, Object request, Map headers, - Class targetClass) throws MessagingException; + T convertSendAndReceive(String destinationName, Object request, + @Nullable Map headers, Class targetClass) throws MessagingException; /** * Resolve the given destination name, convert the payload request Object @@ -92,8 +92,8 @@ public interface DestinationResolvingMessageRequestReplyOperations extends Me * the message could not be received, for example due to a timeout */ @Nullable - T convertSendAndReceive(String destinationName, Object request, - Class targetClass, MessagePostProcessor requestPostProcessor) throws MessagingException; + T convertSendAndReceive(String destinationName, Object request, Class targetClass, + @Nullable MessagePostProcessor requestPostProcessor) throws MessagingException; /** * Resolve the given destination name, convert the payload request Object @@ -111,7 +111,7 @@ public interface DestinationResolvingMessageRequestReplyOperations extends Me * the message could not be received, for example due to a timeout */ @Nullable - T convertSendAndReceive(String destinationName, Object request, Map headers, - Class targetClass, MessagePostProcessor requestPostProcessor) throws MessagingException; + T convertSendAndReceive(String destinationName, Object request, @Nullable Map headers, + Class targetClass, @Nullable MessagePostProcessor requestPostProcessor) throws MessagingException; } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/core/DestinationResolvingMessageSendingOperations.java b/spring-messaging/src/main/java/org/springframework/messaging/core/DestinationResolvingMessageSendingOperations.java index e519ff77a07..4530f49bf1d 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/core/DestinationResolvingMessageSendingOperations.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/core/DestinationResolvingMessageSendingOperations.java @@ -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 extends Message * @param payload the Object to use as payload * @param headers headers for the message to send */ - void convertAndSend(String destinationName, T payload, Map headers) + void convertAndSend(String destinationName, T payload, @Nullable Map headers) throws MessagingException; /** @@ -73,7 +73,7 @@ public interface DestinationResolvingMessageSendingOperations extends Message * @param payload the Object to use as payload * @param postProcessor the post processor to apply to the message */ - void convertAndSend(String destinationName, T payload, MessagePostProcessor postProcessor) + void convertAndSend(String destinationName, T payload, @Nullable MessagePostProcessor postProcessor) throws MessagingException; /** diff --git a/spring-messaging/src/main/java/org/springframework/messaging/core/MessageRequestReplyOperations.java b/spring-messaging/src/main/java/org/springframework/messaging/core/MessageRequestReplyOperations.java index 7320a8c7aea..a63b8a239f0 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/core/MessageRequestReplyOperations.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/core/MessageRequestReplyOperations.java @@ -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 { * could not be received, for example due to a timeout */ @Nullable - T convertSendAndReceive(D destination, Object request, @Nullable Map headers, Class targetClass) + T convertSendAndReceive( + D destination, Object request, @Nullable Map headers, Class targetClass) throws MessagingException; /** @@ -108,7 +109,8 @@ public interface MessageRequestReplyOperations { * could not be received, for example due to a timeout */ @Nullable - T convertSendAndReceive(Object request, Class targetClass, @Nullable MessagePostProcessor requestPostProcessor) + T convertSendAndReceive( + Object request, Class targetClass, @Nullable MessagePostProcessor requestPostProcessor) throws MessagingException; /** @@ -142,7 +144,8 @@ public interface MessageRequestReplyOperations { * could not be received, for example due to a timeout */ @Nullable - T convertSendAndReceive(D destination, Object request, @Nullable Map headers, - Class targetClass, @Nullable MessagePostProcessor requestPostProcessor) throws MessagingException; + T convertSendAndReceive( + D destination, Object request, @Nullable Map headers, Class targetClass, + @Nullable MessagePostProcessor requestPostProcessor) throws MessagingException; }