From 1ab678a2a3a2fe7a1977600178d1b9776f857870 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Tue, 13 Jun 2017 15:09:09 +0200 Subject: [PATCH] Polish "Refactor iterator of Map with Java8's Map.forEach" Closes gh-1459 --- .../cache/caffeine/CaffeineCacheManager.java | 7 +++++-- .../jdbc/core/namedparam/MapSqlParameterSource.java | 2 +- .../annotation/JmsListenerAnnotationBeanPostProcessor.java | 3 ++- .../messaging/support/NativeMessageHeaderAccessor.java | 3 ++- .../org/springframework/oxm/castor/CastorMarshaller.java | 2 +- .../interceptor/NameMatchTransactionAttributeSource.java | 2 +- 6 files changed, 12 insertions(+), 7 deletions(-) diff --git a/spring-context-support/src/main/java/org/springframework/cache/caffeine/CaffeineCacheManager.java b/spring-context-support/src/main/java/org/springframework/cache/caffeine/CaffeineCacheManager.java index 16b616e5c1..144ef388c7 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/caffeine/CaffeineCacheManager.java +++ b/spring-context-support/src/main/java/org/springframework/cache/caffeine/CaffeineCacheManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -19,6 +19,7 @@ package org.springframework.cache.caffeine; import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; @@ -222,7 +223,9 @@ public class CaffeineCacheManager implements CacheManager { * Create the known caches again with the current state of this manager. */ private void refreshKnownCaches() { - this.cacheMap.forEach((key, value) -> createCaffeineCache(key)); + for (Map.Entry entry : this.cacheMap.entrySet()) { + entry.setValue(createCaffeineCache(entry.getKey())); + } } } diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/MapSqlParameterSource.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/MapSqlParameterSource.java index 886345f40f..a411557bc8 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/MapSqlParameterSource.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/MapSqlParameterSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. diff --git a/spring-jms/src/main/java/org/springframework/jms/annotation/JmsListenerAnnotationBeanPostProcessor.java b/spring-jms/src/main/java/org/springframework/jms/annotation/JmsListenerAnnotationBeanPostProcessor.java index cdec528d39..0ca4e8c63d 100644 --- a/spring-jms/src/main/java/org/springframework/jms/annotation/JmsListenerAnnotationBeanPostProcessor.java +++ b/spring-jms/src/main/java/org/springframework/jms/annotation/JmsListenerAnnotationBeanPostProcessor.java @@ -226,7 +226,8 @@ public class JmsListenerAnnotationBeanPostProcessor else { // Non-empty set of methods annotatedMethods.forEach((method, listeners) -> - listeners.forEach(listener -> processJmsListener(listener, method, bean))); + listeners.forEach(listener -> + processJmsListener(listener, method, bean))); if (logger.isDebugEnabled()) { logger.debug(annotatedMethods.size() + " @JmsListener methods processed on bean '" + beanName + "': " + annotatedMethods); diff --git a/spring-messaging/src/main/java/org/springframework/messaging/support/NativeMessageHeaderAccessor.java b/spring-messaging/src/main/java/org/springframework/messaging/support/NativeMessageHeaderAccessor.java index b82f7138fe..3049f07c15 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/support/NativeMessageHeaderAccessor.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/support/NativeMessageHeaderAccessor.java @@ -197,7 +197,8 @@ public class NativeMessageHeaderAccessor extends MessageHeaderAccessor { if (headers == null) { return; } - headers.forEach((key, values) -> values.forEach(value -> addNativeHeader(key, value))); + headers.forEach((key, values) -> + values.forEach(value -> addNativeHeader(key, value))); } @Nullable diff --git a/spring-oxm/src/main/java/org/springframework/oxm/castor/CastorMarshaller.java b/spring-oxm/src/main/java/org/springframework/oxm/castor/CastorMarshaller.java index 3e6f66c03c..9aed389b63 100644 --- a/spring-oxm/src/main/java/org/springframework/oxm/castor/CastorMarshaller.java +++ b/spring-oxm/src/main/java/org/springframework/oxm/castor/CastorMarshaller.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2017 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. diff --git a/spring-tx/src/main/java/org/springframework/transaction/interceptor/NameMatchTransactionAttributeSource.java b/spring-tx/src/main/java/org/springframework/transaction/interceptor/NameMatchTransactionAttributeSource.java index 3e55ee62ed..9edc18d400 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/interceptor/NameMatchTransactionAttributeSource.java +++ b/spring-tx/src/main/java/org/springframework/transaction/interceptor/NameMatchTransactionAttributeSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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.