From eff11f566db45f97d8ec2fee12cdcef4cd4b14c7 Mon Sep 17 00:00:00 2001 From: John Blum Date: Fri, 8 Jun 2018 00:35:18 -0700 Subject: [PATCH] SGF-755 - Add serializable-object-filter and validate-serializable-objects attributes to EnableGemFireProperties. --- .../annotation/EnableGemFireProperties.java | 6 ++--- .../GemFirePropertiesConfiguration.java | 6 +++-- ...ableGemFirePropertiesIntegrationTests.java | 25 +++++++++++++++++++ 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/springframework/data/gemfire/config/annotation/EnableGemFireProperties.java b/src/main/java/org/springframework/data/gemfire/config/annotation/EnableGemFireProperties.java index b6b61b18..7a5dce68 100644 --- a/src/main/java/org/springframework/data/gemfire/config/annotation/EnableGemFireProperties.java +++ b/src/main/java/org/springframework/data/gemfire/config/annotation/EnableGemFireProperties.java @@ -362,15 +362,15 @@ public @interface EnableGemFireProperties { boolean removeUnresponsiveClient() default GemFirePropertiesConfiguration.DEFAULT_REMOVE_UNRESPONSIVE_CLIENT; /** - * A semicolon-separated list of items that become full class names of objects that the system will serialize - * when the property {@link #validateSerializableObjects()} is set to {@literal true}. + * A List of items that become full class names of objects that the system will serialize when the property + * {@link #validateSerializableObjects()} is set to {@literal true}. * * The list is expanded using the patterns specified in the createFilter method at * Class ObjectInputFilter.Config. * * Defaults to unset. */ - String serializableObjectFilter() default GemFirePropertiesConfiguration.DEFAULT_SERIALIZABLE_OBJECT_FILTER; + String[] serializableObjectFilter() default {}; /** * Receive buffer sizes in bytes of the TCP/IP connections used for data transmission. To minimize the buffer size diff --git a/src/main/java/org/springframework/data/gemfire/config/annotation/GemFirePropertiesConfiguration.java b/src/main/java/org/springframework/data/gemfire/config/annotation/GemFirePropertiesConfiguration.java index 1ae5c1a3..bcb615ba 100644 --- a/src/main/java/org/springframework/data/gemfire/config/annotation/GemFirePropertiesConfiguration.java +++ b/src/main/java/org/springframework/data/gemfire/config/annotation/GemFirePropertiesConfiguration.java @@ -74,12 +74,14 @@ public class GemFirePropertiesConfiguration extends EmbeddedServiceConfiguration public static final String DEFAULT_NAME = ""; public static final String DEFAULT_REDUNDANCY_ZONE = ""; public static final String DEFAULT_REMOTE_LOCATORS = ""; - public static final String DEFAULT_SERIALIZABLE_OBJECT_FILTER = ""; public static final String DEFAULT_USER_COMMAND_PACKAGES = ""; @SuppressWarnings("unused") public static final String[] DEFAULT_GROUPS = {}; + @SuppressWarnings("unused") + public static final String[] DEFAULT_SERIALIZABLE_OBJECT_FILTER = {}; + /** * {@inheritDoc} */ @@ -173,7 +175,7 @@ public class GemFirePropertiesConfiguration extends EmbeddedServiceConfiguration annotationAttributes.get("removeUnresponsiveClient"), DEFAULT_REMOVE_UNRESPONSIVE_CLIENT); gemfireProperties.setProperty("serializable-object-filter", - annotationAttributes.get("serializableObjectFilter")); + (String[]) annotationAttributes.get("serializableObjectFilter")); gemfireProperties.setPropertyIfNotDefault("socket-buffer-size", annotationAttributes.get("socketBufferSize"), DEFAULT_SOCKET_BUFFER_SIZE); diff --git a/src/test/java/org/springframework/data/gemfire/config/annotation/EnableGemFirePropertiesIntegrationTests.java b/src/test/java/org/springframework/data/gemfire/config/annotation/EnableGemFirePropertiesIntegrationTests.java index 503c9cc1..d85cb81c 100644 --- a/src/test/java/org/springframework/data/gemfire/config/annotation/EnableGemFirePropertiesIntegrationTests.java +++ b/src/test/java/org/springframework/data/gemfire/config/annotation/EnableGemFirePropertiesIntegrationTests.java @@ -375,6 +375,25 @@ public class EnableGemFirePropertiesIntegrationTests { assertThat(gemfireProperties.getProperty("security-shiro-init")).isEqualTo("/path/to/shiro.ini"); } + @Test + public void serializableObjectFilterAndValidateSerializableObjectsGemFirePropertiesConfiguration() { + + this.applicationContext = + newApplicationContext(TestSerializableObjectFilterAndValidateSerializableObjectsGemFirePropertiesConfiguration.class); + + assertThat(this.applicationContext).isNotNull(); + assertThat(this.applicationContext.containsBean("gemfireProperties")).isTrue(); + + Properties gemfireProperties = this.applicationContext.getBean("gemfireProperties", Properties.class); + + assertThat(gemfireProperties).isNotNull(); + assertThat(gemfireProperties.containsKey("serializable-object-filter")).isTrue(); + assertThat(gemfireProperties.getProperty("serializable-object-filter")) + .isEqualTo("example.app.model.TypeOne,example.app.model.TypeTwo"); + assertThat(gemfireProperties.containsKey("validate-serializable-objects")).isTrue(); + assertThat(gemfireProperties.getProperty("validate-serializable-objects")).isEqualTo("true"); + } + @Test public void sslGemFirePropertiesConfiguration() { @@ -516,6 +535,12 @@ public class EnableGemFirePropertiesIntegrationTests { @EnableSecurity static class TestSecurityGemFirePropertiesConfiguration { } + @EnableGemFireMockObjects + @PeerCacheApplication + @EnableGemFireProperties(serializableObjectFilter = { "example.app.model.TypeOne", "example.app.model.TypeTwo" }, + validateSerializableObjects = true) + static class TestSerializableObjectFilterAndValidateSerializableObjectsGemFirePropertiesConfiguration { } + @EnableGemFireMockObjects @PeerCacheApplication @EnableGemFireProperties