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(); }