|
18 | 18 |
|
19 | 19 | import static java.util.Objects.requireNonNull; |
20 | 20 |
|
21 | | -import java.util.ArrayList; |
22 | 21 | import java.util.Collection; |
23 | 22 | import java.util.Collections; |
24 | 23 | import java.util.HashMap; |
|
28 | 27 | import java.util.concurrent.locks.Lock; |
29 | 28 | import java.util.concurrent.locks.ReadWriteLock; |
30 | 29 | import java.util.concurrent.locks.ReentrantReadWriteLock; |
| 30 | +import java.util.stream.Collectors; |
31 | 31 | import org.apache.logging.log4j.Logger; |
32 | 32 | import org.apache.logging.log4j.message.MessageFactory; |
33 | 33 | import org.apache.logging.log4j.message.ParameterizedMessageFactory; |
@@ -158,19 +158,19 @@ public LoggerRegistry(final MapFactory<T> mapFactory) { |
158 | 158 | } |
159 | 159 |
|
160 | 160 | public Collection<T> getLoggers() { |
161 | | - return getLoggers(new ArrayList<>()); |
162 | | - } |
163 | | - |
164 | | - public Collection<T> getLoggers(final Collection<T> destination) { |
165 | | - requireNonNull(destination, "destination"); |
166 | 161 | readLock.lock(); |
167 | 162 | try { |
168 | | - loggerByMessageFactoryByName.values().stream() |
| 163 | + return loggerByMessageFactoryByName.values().stream() |
169 | 164 | .flatMap(loggerByMessageFactory -> loggerByMessageFactory.values().stream()) |
170 | | - .forEach(destination::add); |
| 165 | + .collect(Collectors.toList()); |
171 | 166 | } finally { |
172 | 167 | readLock.unlock(); |
173 | 168 | } |
| 169 | + } |
| 170 | + |
| 171 | + public Collection<T> getLoggers(final Collection<T> destination) { |
| 172 | + requireNonNull(destination, "destination"); |
| 173 | + destination.addAll(getLoggers()); |
174 | 174 | return destination; |
175 | 175 | } |
176 | 176 |
|
|
0 commit comments