From 112dad8d4ee7ebe6e760cc53db1e79577b446082 Mon Sep 17 00:00:00 2001 From: Oleg Zhurakousky Date: Tue, 1 Jan 2019 11:19:42 +0100 Subject: [PATCH] GH-1570 Made DynamicDestinationsBindable synchronized Made DynamicDestinationsBindable synchronized to preserve consistency to the internal map Resolves #1570 --- .../stream/binding/DynamicDestinationsBindable.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/DynamicDestinationsBindable.java b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/DynamicDestinationsBindable.java index a6cac38cd..8feb319fb 100644 --- a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/DynamicDestinationsBindable.java +++ b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/DynamicDestinationsBindable.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2017 the original author or authors. + * Copyright 2016-2019 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. @@ -27,9 +27,9 @@ import org.springframework.cloud.stream.binder.Binding; * A {@link Bindable} that stores the dynamic destination names and handles their * unbinding. * - * This class is not thread-safe. * * @author Ilayaperumal Gopinathan + * @author Oleg Zhurakousky */ public final class DynamicDestinationsBindable implements Bindable { @@ -38,17 +38,17 @@ public final class DynamicDestinationsBindable implements Bindable { */ private final Map> outputBindings = new HashMap<>(); - public void addOutputBinding(String name, Binding binding) { + public synchronized void addOutputBinding(String name, Binding binding) { this.outputBindings.put(name, binding); } @Override - public Set getOutputs() { + public synchronized Set getOutputs() { return Collections.unmodifiableSet(outputBindings.keySet()); } @Override - public void unbindOutputs(BindingService adapter) { + public synchronized void unbindOutputs(BindingService adapter) { for (Map.Entry> entry : outputBindings.entrySet()) { entry.getValue().unbind(); }