From 080cc123b63f4431aed3421cd79be47aa34cd3ee Mon Sep 17 00:00:00 2001 From: Oleg Zhurakousky Date: Fri, 21 Apr 2023 11:34:43 +0200 Subject: [PATCH] Made deprecated method private in OutputDestination --- .../stream/binder/test/OutputDestination.java | 43 +++++++++++-------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/core/spring-cloud-stream-test-binder/src/main/java/org/springframework/cloud/stream/binder/test/OutputDestination.java b/core/spring-cloud-stream-test-binder/src/main/java/org/springframework/cloud/stream/binder/test/OutputDestination.java index 86bc51c3f..9d45a55a0 100644 --- a/core/spring-cloud-stream-test-binder/src/main/java/org/springframework/cloud/stream/binder/test/OutputDestination.java +++ b/core/spring-cloud-stream-test-binder/src/main/java/org/springframework/cloud/stream/binder/test/OutputDestination.java @@ -78,34 +78,26 @@ public class OutputDestination extends AbstractDestination { } return false; } - /** - * Allows to access {@link Message}s received by this {@link OutputDestination}. - * @param timeout how long to wait before giving up - * @return received message - * @deprecated since 3.0.2 in favor of {@link #receive(long, String)} where you should use the actual binding name (e.g., "foo-in-0") - */ - @Deprecated - public Message receive(long timeout, int bindingIndex) { - log.warn("!!!While 'receive(long timeout, int bindingIndex)' method may still work it is deprecated no longer supported. " - + "It will be removed after 3.1.3 release. Please use 'receive(long timeout, String bindingName)'"); - try { - BlockingQueue> destinationQueue = (new ArrayList<>(this.messageQueues.values())).get(bindingIndex); - return destinationQueue.poll(timeout, TimeUnit.MILLISECONDS); - } - catch (Exception e) { - Thread.currentThread().interrupt(); - } - return null; - } /** * Allows to access {@link Message}s received by this {@link OutputDestination}. + * This is a convenience method for cases when you only have one binding. + * For all other cases use {@link #receive(long, String)} method. + * * @return received message */ public Message receive() { return this.receive(0, 0); } + /** + * Allows to access {@link Message}s received by this {@link OutputDestination}. + * This is a convenience method for cases when you only have one binding. + * For all other cases use {@link #receive(long, String)} method. + * + * @param timeout timeout for receiving message + * @return received message + */ public Message receive(long timeout) { return this.receive(timeout, 0); } @@ -122,4 +114,17 @@ public class OutputDestination extends AbstractDestination { this.messageQueues.putIfAbsent(bindingName, new LinkedTransferQueue<>()); return this.messageQueues.get(bindingName); } + + private Message receive(long timeout, int bindingIndex) { + log.warn("!!!While 'receive(long timeout, int bindingIndex)' method may still work it is deprecated no longer supported. " + + "It will be removed after 3.1.3 release. Please use 'receive(long timeout, String bindingName)'"); + try { + BlockingQueue> destinationQueue = (new ArrayList<>(this.messageQueues.values())).get(bindingIndex); + return destinationQueue.poll(timeout, TimeUnit.MILLISECONDS); + } + catch (Exception e) { + Thread.currentThread().interrupt(); + } + return null; + } }