From ed9ac261f4a4c00417d610574df44fdb9660de6c Mon Sep 17 00:00:00 2001 From: John Blum Date: Wed, 17 Jun 2020 15:07:25 -0700 Subject: [PATCH] Set default GemFire Gargabe Collector event type to AfterTestClassEvent.class. Add accessor methods for gemfireGarbageCollectorEventTypes and tryCleanDiskStoreFiles configuration settings. Resolves gh-21. --- .../GemFireGarbageCollectorConfiguration.java | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/spring-data-geode-test/src/main/java/org/springframework/data/gemfire/tests/integration/annotation/GemFireGarbageCollectorConfiguration.java b/spring-data-geode-test/src/main/java/org/springframework/data/gemfire/tests/integration/annotation/GemFireGarbageCollectorConfiguration.java index 4f4ae23..34d469f 100644 --- a/spring-data-geode-test/src/main/java/org/springframework/data/gemfire/tests/integration/annotation/GemFireGarbageCollectorConfiguration.java +++ b/spring-data-geode-test/src/main/java/org/springframework/data/gemfire/tests/integration/annotation/GemFireGarbageCollectorConfiguration.java @@ -25,8 +25,10 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.ImportAware; import org.springframework.core.type.AnnotationMetadata; import org.springframework.data.gemfire.config.annotation.support.AbstractAnnotationConfigSupport; -import org.springframework.data.gemfire.tests.mock.context.event.GemFireGarbageCollectorApplicationListener; +import org.springframework.data.gemfire.tests.integration.context.event.GemFireGarbageCollectorApplicationListener; +import org.springframework.data.gemfire.util.ArrayUtils; import org.springframework.lang.NonNull; +import org.springframework.test.context.event.AfterTestClassEvent; /** * Spring {@link Configuration} class used to register beans that collect garbage irresponsibly left behind by @@ -41,7 +43,7 @@ import org.springframework.lang.NonNull; * @see org.springframework.context.annotation.ImportAware * @see org.springframework.core.type.AnnotationMetadata * @see org.springframework.data.gemfire.config.annotation.support.AbstractAnnotationConfigSupport - * @see org.springframework.data.gemfire.tests.mock.context.event.GemFireGarbageCollectorApplicationListener + * @see GemFireGarbageCollectorApplicationListener * @since 0.0.17 */ @Configuration @@ -53,7 +55,8 @@ public class GemFireGarbageCollectorConfiguration extends AbstractAnnotationConf private boolean tryCleanDiskStoreFiles = DEFAULT_CLEAN_DISK_STORE_FILES; @SuppressWarnings("unchecked") - private Class[] gemfireGarbageCollectorEventTypes = new Class[0]; + private Class[] gemfireGarbageCollectorEventTypes = + new Class[] { AfterTestClassEvent.class }; @Override protected Class getAnnotationType() { @@ -77,9 +80,18 @@ public class GemFireGarbageCollectorConfiguration extends AbstractAnnotationConf }); } + @SuppressWarnings("unchecked") + protected @NonNull Class[] getGemFireGarbageCollectorEventTypes() { + return ArrayUtils.nullSafeArray(this.gemfireGarbageCollectorEventTypes, Class.class); + } + + protected boolean isTryCleanDiskStoreFiles() { + return this.tryCleanDiskStoreFiles; + } + @Bean ApplicationListener gemfireGarbageCollectorApplicationListener() { - return GemFireGarbageCollectorApplicationListener.create(this.gemfireGarbageCollectorEventTypes) - .tryCleanDiskStoreFiles(this.tryCleanDiskStoreFiles); + return GemFireGarbageCollectorApplicationListener.create(getGemFireGarbageCollectorEventTypes()) + .tryCleanDiskStoreFiles(isTryCleanDiskStoreFiles()); } }