Skip to content

Commit 539b1bd

Browse files
committed
Fix bug with cache data import when using @EnableClusterAware.
Resolves spring-projectsgh-90.
1 parent 952c65f commit 539b1bd

File tree

2 files changed

+10
-19
lines changed

2 files changed

+10
-19
lines changed

spring-geode-autoconfigure/src/main/java/org/springframework/geode/boot/autoconfigure/DataImportExportAutoConfiguration.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@
3939
import org.springframework.geode.boot.autoconfigure.support.PdxInstanceWrapperRegionAspect;
4040
import org.springframework.geode.cache.SimpleCacheResolver;
4141
import org.springframework.geode.data.AbstractCacheDataImporterExporter;
42+
import org.springframework.geode.data.CacheDataImporterExporter;
4243
import org.springframework.geode.data.json.JsonCacheDataImporterExporter;
44+
import org.springframework.geode.data.support.LifecycleAwareCacheDataImporterExporter;
4345
import org.springframework.lang.NonNull;
4446
import org.springframework.lang.Nullable;
4547

@@ -78,8 +80,8 @@ public class DataImportExportAutoConfiguration {
7880
"spring.boot.data.gemfire.cache.region.advice.enabled";
7981

8082
@Bean
81-
JsonCacheDataImporterExporter jsonCacheDataImporterExporter() {
82-
return new JsonCacheDataImporterExporter();
83+
CacheDataImporterExporter jsonCacheDataImporterExporter() {
84+
return new LifecycleAwareCacheDataImporterExporter(new JsonCacheDataImporterExporter());
8385
}
8486

8587
@Bean

spring-geode-autoconfigure/src/test/java/org/springframework/geode/boot/autoconfigure/data/ClientCacheDataImportExportAutoConfigurationIntegrationTests.java

+6-17
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,18 @@
3232
import org.junit.runner.RunWith;
3333

3434
import org.apache.geode.cache.DataPolicy;
35-
import org.apache.geode.cache.GemFireCache;
3635

3736
import org.springframework.beans.factory.annotation.Autowired;
3837
import org.springframework.boot.autoconfigure.SpringBootApplication;
3938
import org.springframework.boot.test.context.SpringBootTest;
4039
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
41-
import org.springframework.context.annotation.Bean;
4240
import org.springframework.context.annotation.Profile;
4341
import org.springframework.data.gemfire.GemfireTemplate;
44-
import org.springframework.data.gemfire.LocalRegionFactoryBean;
4542
import org.springframework.data.gemfire.config.annotation.CacheServerApplication;
4643
import org.springframework.data.gemfire.config.annotation.EnableEntityDefinedRegions;
4744
import org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport;
4845
import org.springframework.geode.boot.autoconfigure.DataImportExportAutoConfiguration;
46+
import org.springframework.geode.config.annotation.EnableClusterAware;
4947
import org.springframework.geode.core.util.ObjectUtils;
5048
import org.springframework.geode.util.CacheUtils;
5149
import org.springframework.test.context.ActiveProfiles;
@@ -76,12 +74,13 @@
7674
* @see org.springframework.test.context.junit4.SpringRunner
7775
* @since 1.3.0
7876
*/
79-
@ActiveProfiles("IMPORT")
77+
@ActiveProfiles("IMPORT-CLIENT")
8078
@RunWith(SpringRunner.class)
8179
@SpringBootTest(
8280
classes = ClientCacheDataImportExportAutoConfigurationIntegrationTests.TestGeodeClientConfiguration.class,
8381
properties = {
84-
"spring.boot.data.gemfire.cache.data.import.active-profiles=IMPORT",
82+
"spring.data.gemfire.management.use-http=false",
83+
"spring.boot.data.gemfire.cache.data.import.active-profiles=IMPORT-CLIENT",
8584
"spring.boot.data.gemfire.cache.region.advice.enabled=true"
8685
}
8786
)
@@ -163,8 +162,9 @@ public void booksWereLoaded() {
163162
ISBN.of("978-1-492-04034-7"), Author.newAuthor("Alex Petrov").identifiedBy(2L));
164163
}
165164

166-
@Profile("IMPORT")
165+
@Profile("IMPORT-CLIENT")
167166
@SpringBootApplication
167+
@EnableClusterAware
168168
@EnableEntityDefinedRegions(basePackageClasses = Book.class)
169169
static class TestGeodeClientConfiguration { }
170170

@@ -179,16 +179,5 @@ public static void main(String[] args) {
179179

180180
applicationContext.registerShutdownHook();
181181
}
182-
183-
@Bean("Books")
184-
LocalRegionFactoryBean<Object, Object> booksRegion(GemFireCache cache) {
185-
186-
LocalRegionFactoryBean<Object, Object> booksRegion = new LocalRegionFactoryBean<>();
187-
188-
booksRegion.setCache(cache);
189-
booksRegion.setPersistent(false);
190-
191-
return booksRegion;
192-
}
193182
}
194183
}

0 commit comments

Comments
 (0)