|
1 | 1 | /* |
2 | | - * Copyright 2015-2017 the original author or authors. |
| 2 | + * Copyright 2015-2020 the original author or authors. |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
@@ -92,16 +92,20 @@ public void setConcurrency(int concurrency) { |
92 | 92 | * this container. |
93 | 93 | */ |
94 | 94 | public List<KafkaMessageListenerContainer<K, V>> getContainers() { |
95 | | - return Collections.unmodifiableList(this.containers); |
| 95 | + synchronized (this.lifecycleMonitor) { |
| 96 | + return Collections.unmodifiableList(new ArrayList<>(this.containers)); |
| 97 | + } |
96 | 98 | } |
97 | 99 |
|
98 | 100 | @Override |
99 | 101 | public Map<String, Map<MetricName, ? extends Metric>> metrics() { |
100 | | - Map<String, Map<MetricName, ? extends Metric>> metrics = new HashMap<>(); |
101 | | - for (KafkaMessageListenerContainer<K, V> container : this.containers) { |
102 | | - metrics.putAll(container.metrics()); |
| 102 | + synchronized (this.lifecycleMonitor) { |
| 103 | + Map<String, Map<MetricName, ? extends Metric>> metrics = new HashMap<>(); |
| 104 | + for (KafkaMessageListenerContainer<K, V> container : this.containers) { |
| 105 | + metrics.putAll(container.metrics()); |
| 106 | + } |
| 107 | + return Collections.unmodifiableMap(metrics); |
103 | 108 | } |
104 | | - return Collections.unmodifiableMap(metrics); |
105 | 109 | } |
106 | 110 |
|
107 | 111 | /* |
|
0 commit comments