From 6bdba8e69e208731f0155720b6747077e8905de5 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 24 Jun 2024 12:03:13 +0100 Subject: [PATCH] Revert "Enable customization of properties used to create JCache CacheManager" This reverts commit 622c9ed8828ce26d166b0fb8f3c94c06bcb1d910 that was pushed accidentally. --- ...zelcastJCacheCustomizationConfiguration.java | 17 ++++++----------- .../cache/JCacheCacheConfiguration.java | 9 +++++---- .../cache/JCachePropertiesCustomizer.java | 11 +++++------ 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/HazelcastJCacheCustomizationConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/HazelcastJCacheCustomizationConfiguration.java index 7832328506e..ff0206b2b75 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/HazelcastJCacheCustomizationConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/HazelcastJCacheCustomizationConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2024 the original author or authors. + * Copyright 2012-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. @@ -38,26 +38,21 @@ import org.springframework.core.io.Resource; class HazelcastJCacheCustomizationConfiguration { @Bean - HazelcastPropertiesCustomizer hazelcastPropertiesCustomizer(ObjectProvider hazelcastInstance, - CacheProperties cacheProperties) { - return new HazelcastPropertiesCustomizer(hazelcastInstance.getIfUnique(), cacheProperties); + HazelcastPropertiesCustomizer hazelcastPropertiesCustomizer(ObjectProvider hazelcastInstance) { + return new HazelcastPropertiesCustomizer(hazelcastInstance.getIfUnique()); } static class HazelcastPropertiesCustomizer implements JCachePropertiesCustomizer { private final HazelcastInstance hazelcastInstance; - private final CacheProperties cacheProperties; - - HazelcastPropertiesCustomizer(HazelcastInstance hazelcastInstance, CacheProperties cacheProperties) { + HazelcastPropertiesCustomizer(HazelcastInstance hazelcastInstance) { this.hazelcastInstance = hazelcastInstance; - this.cacheProperties = cacheProperties; } @Override - public void customize(Properties properties) { - Resource configLocation = this.cacheProperties - .resolveConfigLocation(this.cacheProperties.getJcache().getConfig()); + public void customize(CacheProperties cacheProperties, Properties properties) { + Resource configLocation = cacheProperties.resolveConfigLocation(cacheProperties.getJcache().getConfig()); if (configLocation != null) { // Hazelcast does not use the URI as a mean to specify a custom config. properties.setProperty("hazelcast.config.location", toUri(configLocation).toString()); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/JCacheCacheConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/JCacheCacheConfiguration.java index e040229da3e..07d9d3c4029 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/JCacheCacheConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/JCacheCacheConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2024 the original author or authors. + * Copyright 2012-2023 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. @@ -95,7 +95,7 @@ class JCacheCacheConfiguration implements BeanClassLoaderAware { private CacheManager createCacheManager(CacheProperties cacheProperties, ObjectProvider cachePropertiesCustomizers) throws IOException { CachingProvider cachingProvider = getCachingProvider(cacheProperties.getJcache().getProvider()); - Properties properties = createCacheManagerProperties(cachePropertiesCustomizers); + Properties properties = createCacheManagerProperties(cachePropertiesCustomizers, cacheProperties); Resource configLocation = cacheProperties.resolveConfigLocation(cacheProperties.getJcache().getConfig()); if (configLocation != null) { return cachingProvider.getCacheManager(configLocation.getURI(), this.beanClassLoader, properties); @@ -111,9 +111,10 @@ class JCacheCacheConfiguration implements BeanClassLoaderAware { } private Properties createCacheManagerProperties( - ObjectProvider cachePropertiesCustomizers) { + ObjectProvider cachePropertiesCustomizers, CacheProperties cacheProperties) { Properties properties = new Properties(); - cachePropertiesCustomizers.orderedStream().forEach((customizer) -> customizer.customize(properties)); + cachePropertiesCustomizers.orderedStream() + .forEach((customizer) -> customizer.customize(cacheProperties, properties)); return properties; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/JCachePropertiesCustomizer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/JCachePropertiesCustomizer.java index 80f942535b4..c18886c17e9 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/JCachePropertiesCustomizer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/JCachePropertiesCustomizer.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2024 the original author or authors. + * Copyright 2012-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. @@ -25,17 +25,16 @@ import javax.cache.spi.CachingProvider; * Callback interface that can be implemented by beans wishing to customize the properties * used by the {@link CachingProvider} to create the {@link CacheManager}. * - * @see CachingProvider#getCacheManager(java.net.URI, ClassLoader, Properties) * @author Stephane Nicoll - * @since 3.3.0 */ -public interface JCachePropertiesCustomizer { +interface JCachePropertiesCustomizer { /** * Customize the properties. + * @param cacheProperties the cache properties * @param properties the current properties - * + * @see CachingProvider#getCacheManager(java.net.URI, ClassLoader, Properties) */ - void customize(Properties properties); + void customize(CacheProperties cacheProperties, Properties properties); }