This is an automated email from the ASF dual-hosted git repository. klund pushed a commit to branch support/1.13 in repository https://gitbox.apache.org/repos/asf/geode.git
commit 132103729fe8d67789c691af052d5fc613b1f24c Author: Kirk Lund <kl...@apache.org> AuthorDate: Thu Dec 9 10:15:20 2021 -0800 GEODE-9758: Move SanctionedSerializables to filter package (#7165) Move SanctionedSerializables to new package org.apache.geode.internal.serialization.filter. (cherry picked from commit db64b4948e790d61e82f95ae6163a62adc4c67fb) --- geode-common/build.gradle | 1 + ...ctionedSerializablesServiceIntegrationTest.java | 2 +- .../ConnectorsSanctionedSerializablesService.java | 2 +- ...lization.filter.SanctionedSerializablesService} | 0 geode-core/build.gradle | 2 + ...ctionedSerializablesServiceIntegrationTest.java | 2 +- .../CoreSanctionedSerializablesService.java | 2 +- .../geode/internal/InternalDataSerializer.java | 4 +- .../internal/ObjectInputStreamFilterWrapper.java | 2 +- ...lization.filter.SanctionedSerializablesService} | 0 ...ctionedSerializablesServiceIntegrationTest.java | 2 +- .../internal/CQSanctionedSerializablesService.java | 2 +- ...lization.filter.SanctionedSerializablesService} | 0 ...ctionedSerializablesServiceIntegrationTest.java | 2 +- .../DUnitSanctionedSerializablesService.java | 2 +- ...lization.filter.SanctionedSerializablesService} | 0 .../AnalyzeGfshSerializablesIntegrationTest.java | 2 +- ...ctionedSerializablesServiceIntegrationTest.java | 4 +- .../GfshSanctionedSerializablesService.java | 4 +- ...lization.filter.SanctionedSerializablesService} | 2 +- .../sanctioned-geode-gfsh-serializables.txt | 0 ...ctionedSerializablesServiceIntegrationTest.java | 5 +- ...nedSerializablesServiceIntegrationTestBase.java | 16 ++-- .../categories/SanctionedSerializablesTest.java | 5 +- .../JUnitSanctionedSerializablesService.java | 2 +- ...lization.filter.SanctionedSerializablesService} | 0 ...ctionedSerializablesServiceIntegrationTest.java | 2 +- .../LuceneSanctionedSerializablesService.java | 2 +- ...lization.filter.SanctionedSerializablesService} | 0 ...ctionedSerializablesServiceIntegrationTest.java | 2 +- .../ManagementSanctionedSerializablesService.java | 2 +- ...lization.filter.SanctionedSerializablesService} | 0 .../MembershipDependenciesJUnitTest.java | 1 - ...ctionedSerializablesServiceIntegrationTest.java | 2 +- .../MembershipSanctionedSerializablesService.java | 2 +- ...lization.filter.SanctionedSerializablesService} | 0 ...ctionedSerializablesServiceIntegrationTest.java | 2 +- .../MemcachedSanctionedSerializablesService.java | 2 +- ...lization.filter.SanctionedSerializablesService} | 0 .../RedisSanctionedSerializablesService.java | 2 +- ...lization.filter.SanctionedSerializablesService} | 0 ...ctionedSerializablesServiceIntegrationTest.java | 2 +- ...lization.filter.SanctionedSerializablesService} | 0 geode-serialization/build.gradle | 4 + ...ctionedSerializablesServiceIntegrationTest.java | 1 + .../apache/geode/codeAnalysis/excludedClasses.txt | 0 ...erializationSanctionedSerializablesService.java | 2 + .../{ => filter}/SanctionedSerializables.java | 37 ++++++++- .../SanctionedSerializablesService.java | 2 +- ...lization.filter.SanctionedSerializablesService} | 0 ...est.java => SerializationDependenciesTest.java} | 17 ++-- .../filter/SanctionedSerializablesTest.java | 95 ++++++++++++++++++++++ .../src/test/resources/expected-pom.xml | 10 +++ ...ctionedSerializablesServiceIntegrationTest.java | 4 +- .../AnalyzeWANSerializablesIntegrationTest.java | 2 +- .../WANSanctionedSerializablesService.java | 4 +- ...lization.filter.SanctionedSerializablesService} | 2 +- .../sanctioned-geode-wan-serializables.txt | 0 ...ctionedSerializablesServiceIntegrationTest.java | 2 +- .../WebApiSanctionedSerializablesService.java | 2 +- ...lization.filter.SanctionedSerializablesService} | 0 61 files changed, 212 insertions(+), 58 deletions(-) diff --git a/geode-common/build.gradle b/geode-common/build.gradle index ae1df98..29ecc3d 100755 --- a/geode-common/build.gradle +++ b/geode-common/build.gradle @@ -24,6 +24,7 @@ dependencies { implementation(platform(project(':boms:geode-all-bom'))) implementation('com.fasterxml.jackson.core:jackson-databind') testImplementation('junit:junit') + testImplementation('org.apache.commons:commons-lang3') testImplementation('org.assertj:assertj-core') testImplementation('org.mockito:mockito-core') } diff --git a/geode-connectors/src/integrationTest/java/org/apache/geode/connectors/jdbc/internal/ConnectorsSanctionedSerializablesServiceIntegrationTest.java b/geode-connectors/src/integrationTest/java/org/apache/geode/connectors/jdbc/internal/ConnectorsSanctionedSerializablesServiceIntegrationTest.java index 7a6d11a..9a1be57 100644 --- a/geode-connectors/src/integrationTest/java/org/apache/geode/connectors/jdbc/internal/ConnectorsSanctionedSerializablesServiceIntegrationTest.java +++ b/geode-connectors/src/integrationTest/java/org/apache/geode/connectors/jdbc/internal/ConnectorsSanctionedSerializablesServiceIntegrationTest.java @@ -17,7 +17,7 @@ package org.apache.geode.connectors.jdbc.internal; import org.junit.experimental.categories.Category; import org.apache.geode.codeAnalysis.SanctionedSerializablesServiceIntegrationTestBase; -import org.apache.geode.internal.serialization.SanctionedSerializablesService; +import org.apache.geode.internal.serialization.filter.SanctionedSerializablesService; import org.apache.geode.test.junit.categories.SanctionedSerializablesTest; import org.apache.geode.test.junit.categories.SerializationTest; diff --git a/geode-connectors/src/main/java/org/apache/geode/connectors/jdbc/internal/ConnectorsSanctionedSerializablesService.java b/geode-connectors/src/main/java/org/apache/geode/connectors/jdbc/internal/ConnectorsSanctionedSerializablesService.java index 76b5390..007978b 100644 --- a/geode-connectors/src/main/java/org/apache/geode/connectors/jdbc/internal/ConnectorsSanctionedSerializablesService.java +++ b/geode-connectors/src/main/java/org/apache/geode/connectors/jdbc/internal/ConnectorsSanctionedSerializablesService.java @@ -16,7 +16,7 @@ package org.apache.geode.connectors.jdbc.internal; import java.net.URL; -import org.apache.geode.internal.serialization.SanctionedSerializablesService; +import org.apache.geode.internal.serialization.filter.SanctionedSerializablesService; public class ConnectorsSanctionedSerializablesService implements SanctionedSerializablesService { diff --git a/geode-connectors/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService b/geode-connectors/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.filter.SanctionedSerializablesService similarity index 100% rename from geode-connectors/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService rename to geode-connectors/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.filter.SanctionedSerializablesService diff --git a/geode-core/build.gradle b/geode-core/build.gradle index 143ac46..c7b58de 100755 --- a/geode-core/build.gradle +++ b/geode-core/build.gradle @@ -331,6 +331,7 @@ dependencies { exclude module: 'geode-core' } testImplementation(project(':geode-concurrency-test')) + testImplementation(project(':geode-serialization')) testImplementation('org.apache.bcel:bcel') testImplementation('org.assertj:assertj-core') testImplementation('org.mockito:mockito-core') @@ -362,6 +363,7 @@ dependencies { exclude module: 'geode-core' } integrationTestImplementation(project(':geode-concurrency-test')) + integrationTestImplementation(project(':geode-serialization')) integrationTestImplementation('org.apache.bcel:bcel') integrationTestImplementation('org.apache.logging.log4j:log4j-core') integrationTestImplementation('org.powermock:powermock-core') diff --git a/geode-core/src/integrationTest/java/org/apache/geode/internal/CoreSanctionedSerializablesServiceIntegrationTest.java b/geode-core/src/integrationTest/java/org/apache/geode/internal/CoreSanctionedSerializablesServiceIntegrationTest.java index feeb08d..36e0623 100644 --- a/geode-core/src/integrationTest/java/org/apache/geode/internal/CoreSanctionedSerializablesServiceIntegrationTest.java +++ b/geode-core/src/integrationTest/java/org/apache/geode/internal/CoreSanctionedSerializablesServiceIntegrationTest.java @@ -17,7 +17,7 @@ package org.apache.geode.internal; import org.junit.experimental.categories.Category; import org.apache.geode.codeAnalysis.SanctionedSerializablesServiceIntegrationTestBase; -import org.apache.geode.internal.serialization.SanctionedSerializablesService; +import org.apache.geode.internal.serialization.filter.SanctionedSerializablesService; import org.apache.geode.test.junit.categories.SanctionedSerializablesTest; import org.apache.geode.test.junit.categories.SerializationTest; diff --git a/geode-core/src/main/java/org/apache/geode/internal/CoreSanctionedSerializablesService.java b/geode-core/src/main/java/org/apache/geode/internal/CoreSanctionedSerializablesService.java index 790520e..fa5f1e1 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/CoreSanctionedSerializablesService.java +++ b/geode-core/src/main/java/org/apache/geode/internal/CoreSanctionedSerializablesService.java @@ -16,7 +16,7 @@ package org.apache.geode.internal; import java.net.URL; -import org.apache.geode.internal.serialization.SanctionedSerializablesService; +import org.apache.geode.internal.serialization.filter.SanctionedSerializablesService; public class CoreSanctionedSerializablesService implements SanctionedSerializablesService { diff --git a/geode-core/src/main/java/org/apache/geode/internal/InternalDataSerializer.java b/geode-core/src/main/java/org/apache/geode/internal/InternalDataSerializer.java index 22cb748..08f5de9 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/InternalDataSerializer.java +++ b/geode-core/src/main/java/org/apache/geode/internal/InternalDataSerializer.java @@ -14,7 +14,7 @@ */ package org.apache.geode.internal; -import static org.apache.geode.internal.serialization.SanctionedSerializables.loadSanctionedSerializablesServices; +import static org.apache.geode.internal.serialization.filter.SanctionedSerializables.loadSanctionedSerializablesServices; import java.io.DataInput; import java.io.DataOutput; @@ -114,12 +114,12 @@ import org.apache.geode.internal.serialization.DeserializationContext; import org.apache.geode.internal.serialization.DscodeHelper; import org.apache.geode.internal.serialization.ObjectDeserializer; import org.apache.geode.internal.serialization.ObjectSerializer; -import org.apache.geode.internal.serialization.SanctionedSerializablesService; import org.apache.geode.internal.serialization.SerializationContext; import org.apache.geode.internal.serialization.SerializationVersions; import org.apache.geode.internal.serialization.StaticSerialization; import org.apache.geode.internal.serialization.Version; import org.apache.geode.internal.serialization.VersionedDataStream; +import org.apache.geode.internal.serialization.filter.SanctionedSerializablesService; import org.apache.geode.internal.util.concurrent.CopyOnWriteHashMap; import org.apache.geode.logging.internal.log4j.api.LogService; import org.apache.geode.pdx.NonPortableClassException; diff --git a/geode-core/src/main/java/org/apache/geode/internal/ObjectInputStreamFilterWrapper.java b/geode-core/src/main/java/org/apache/geode/internal/ObjectInputStreamFilterWrapper.java index 184eb9f..25d5e35 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/ObjectInputStreamFilterWrapper.java +++ b/geode-core/src/main/java/org/apache/geode/internal/ObjectInputStreamFilterWrapper.java @@ -30,7 +30,7 @@ import org.apache.logging.log4j.Logger; import org.apache.geode.GemFireConfigException; import org.apache.geode.InternalGemFireError; import org.apache.geode.InternalGemFireException; -import org.apache.geode.internal.serialization.SanctionedSerializablesService; +import org.apache.geode.internal.serialization.filter.SanctionedSerializablesService; import org.apache.geode.logging.internal.log4j.api.LogService; diff --git a/geode-core/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService b/geode-core/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.filter.SanctionedSerializablesService similarity index 100% rename from geode-core/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService rename to geode-core/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.filter.SanctionedSerializablesService diff --git a/geode-cq/src/integrationTest/java/org/apache/geode/cache/query/cq/internal/CQSanctionedSerializablesServiceIntegrationTest.java b/geode-cq/src/integrationTest/java/org/apache/geode/cache/query/cq/internal/CQSanctionedSerializablesServiceIntegrationTest.java index b17a1cf..1d1d09c 100644 --- a/geode-cq/src/integrationTest/java/org/apache/geode/cache/query/cq/internal/CQSanctionedSerializablesServiceIntegrationTest.java +++ b/geode-cq/src/integrationTest/java/org/apache/geode/cache/query/cq/internal/CQSanctionedSerializablesServiceIntegrationTest.java @@ -17,7 +17,7 @@ package org.apache.geode.cache.query.cq.internal; import org.junit.experimental.categories.Category; import org.apache.geode.codeAnalysis.SanctionedSerializablesServiceIntegrationTestBase; -import org.apache.geode.internal.serialization.SanctionedSerializablesService; +import org.apache.geode.internal.serialization.filter.SanctionedSerializablesService; import org.apache.geode.test.junit.categories.SanctionedSerializablesTest; import org.apache.geode.test.junit.categories.SerializationTest; diff --git a/geode-cq/src/main/java/org/apache/geode/cache/query/cq/internal/CQSanctionedSerializablesService.java b/geode-cq/src/main/java/org/apache/geode/cache/query/cq/internal/CQSanctionedSerializablesService.java index 59838f8..b61cbc5 100644 --- a/geode-cq/src/main/java/org/apache/geode/cache/query/cq/internal/CQSanctionedSerializablesService.java +++ b/geode-cq/src/main/java/org/apache/geode/cache/query/cq/internal/CQSanctionedSerializablesService.java @@ -16,7 +16,7 @@ package org.apache.geode.cache.query.cq.internal; import java.net.URL; -import org.apache.geode.internal.serialization.SanctionedSerializablesService; +import org.apache.geode.internal.serialization.filter.SanctionedSerializablesService; public class CQSanctionedSerializablesService implements SanctionedSerializablesService { diff --git a/geode-cq/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService b/geode-cq/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.filter.SanctionedSerializablesService similarity index 100% rename from geode-cq/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService rename to geode-cq/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.filter.SanctionedSerializablesService diff --git a/geode-dunit/src/integrationTest/java/org/apache/geode/test/dunit/internal/DUnitSanctionedSerializablesServiceIntegrationTest.java b/geode-dunit/src/integrationTest/java/org/apache/geode/test/dunit/internal/DUnitSanctionedSerializablesServiceIntegrationTest.java index f70d3c3..d73861e 100644 --- a/geode-dunit/src/integrationTest/java/org/apache/geode/test/dunit/internal/DUnitSanctionedSerializablesServiceIntegrationTest.java +++ b/geode-dunit/src/integrationTest/java/org/apache/geode/test/dunit/internal/DUnitSanctionedSerializablesServiceIntegrationTest.java @@ -17,7 +17,7 @@ package org.apache.geode.test.dunit.internal; import org.junit.experimental.categories.Category; import org.apache.geode.codeAnalysis.SanctionedSerializablesServiceIntegrationTestBase; -import org.apache.geode.internal.serialization.SanctionedSerializablesService; +import org.apache.geode.internal.serialization.filter.SanctionedSerializablesService; import org.apache.geode.test.junit.categories.SanctionedSerializablesTest; import org.apache.geode.test.junit.categories.SerializationTest; diff --git a/geode-dunit/src/main/java/org/apache/geode/test/dunit/internal/DUnitSanctionedSerializablesService.java b/geode-dunit/src/main/java/org/apache/geode/test/dunit/internal/DUnitSanctionedSerializablesService.java index 6ae34d7..beb4daf 100644 --- a/geode-dunit/src/main/java/org/apache/geode/test/dunit/internal/DUnitSanctionedSerializablesService.java +++ b/geode-dunit/src/main/java/org/apache/geode/test/dunit/internal/DUnitSanctionedSerializablesService.java @@ -16,7 +16,7 @@ package org.apache.geode.test.dunit.internal; import java.net.URL; -import org.apache.geode.internal.serialization.SanctionedSerializablesService; +import org.apache.geode.internal.serialization.filter.SanctionedSerializablesService; public class DUnitSanctionedSerializablesService implements SanctionedSerializablesService { diff --git a/geode-dunit/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService b/geode-dunit/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.filter.SanctionedSerializablesService similarity index 100% rename from geode-dunit/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService rename to geode-dunit/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.filter.SanctionedSerializablesService diff --git a/geode-gfsh/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeGfshSerializablesIntegrationTest.java b/geode-gfsh/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeGfshSerializablesIntegrationTest.java index 1de44bf..bac8886 100755 --- a/geode-gfsh/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeGfshSerializablesIntegrationTest.java +++ b/geode-gfsh/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeGfshSerializablesIntegrationTest.java @@ -18,7 +18,7 @@ import java.util.Optional; import org.junit.experimental.categories.Category; -import org.apache.geode.management.internal.GfshSanctionedSerializablesService; +import org.apache.geode.gfsh.internal.management.GfshSanctionedSerializablesService; import org.apache.geode.test.junit.categories.SerializationTest; @Category(SerializationTest.class) diff --git a/geode-gfsh/src/integrationTest/java/org/apache/geode/management/internal/GfshSanctionedSerializablesServiceIntegrationTest.java b/geode-gfsh/src/integrationTest/java/org/apache/geode/gfsh/internal/management/GfshSanctionedSerializablesServiceIntegrationTest.java similarity index 93% rename from geode-gfsh/src/integrationTest/java/org/apache/geode/management/internal/GfshSanctionedSerializablesServiceIntegrationTest.java rename to geode-gfsh/src/integrationTest/java/org/apache/geode/gfsh/internal/management/GfshSanctionedSerializablesServiceIntegrationTest.java index a2d7644..48a414c 100644 --- a/geode-gfsh/src/integrationTest/java/org/apache/geode/management/internal/GfshSanctionedSerializablesServiceIntegrationTest.java +++ b/geode-gfsh/src/integrationTest/java/org/apache/geode/gfsh/internal/management/GfshSanctionedSerializablesServiceIntegrationTest.java @@ -12,7 +12,7 @@ * or implied. See the License for the specific language governing permissions and limitations under * the License. */ -package org.apache.geode.management.internal; +package org.apache.geode.gfsh.internal.management; import static org.assertj.core.api.Assertions.assertThat; @@ -23,7 +23,7 @@ import org.junit.Test; import org.junit.experimental.categories.Category; import org.apache.geode.codeAnalysis.SanctionedSerializablesServiceIntegrationTestBase; -import org.apache.geode.internal.serialization.SanctionedSerializablesService; +import org.apache.geode.internal.serialization.filter.SanctionedSerializablesService; import org.apache.geode.management.cli.CommandProcessingException; import org.apache.geode.test.junit.categories.SanctionedSerializablesTest; import org.apache.geode.test.junit.categories.SerializationTest; diff --git a/geode-gfsh/src/main/java/org/apache/geode/management/internal/GfshSanctionedSerializablesService.java b/geode-gfsh/src/main/java/org/apache/geode/gfsh/internal/management/GfshSanctionedSerializablesService.java similarity index 88% rename from geode-gfsh/src/main/java/org/apache/geode/management/internal/GfshSanctionedSerializablesService.java rename to geode-gfsh/src/main/java/org/apache/geode/gfsh/internal/management/GfshSanctionedSerializablesService.java index 66c9457..867b897 100644 --- a/geode-gfsh/src/main/java/org/apache/geode/management/internal/GfshSanctionedSerializablesService.java +++ b/geode-gfsh/src/main/java/org/apache/geode/gfsh/internal/management/GfshSanctionedSerializablesService.java @@ -12,11 +12,11 @@ * or implied. See the License for the specific language governing permissions and limitations under * the License. */ -package org.apache.geode.management.internal; +package org.apache.geode.gfsh.internal.management; import java.net.URL; -import org.apache.geode.internal.serialization.SanctionedSerializablesService; +import org.apache.geode.internal.serialization.filter.SanctionedSerializablesService; public class GfshSanctionedSerializablesService implements SanctionedSerializablesService { diff --git a/geode-gfsh/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService b/geode-gfsh/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.filter.SanctionedSerializablesService similarity index 90% rename from geode-gfsh/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService rename to geode-gfsh/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.filter.SanctionedSerializablesService index e51ef5e..51b4140 100644 --- a/geode-gfsh/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService +++ b/geode-gfsh/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.filter.SanctionedSerializablesService @@ -12,4 +12,4 @@ # or implied. See the License for the specific language governing permissions and limitations under # the License. # -org.apache.geode.management.internal.GfshSanctionedSerializablesService +org.apache.geode.gfsh.internal.management.GfshSanctionedSerializablesService diff --git a/geode-gfsh/src/main/resources/org/apache/geode/management/internal/sanctioned-geode-gfsh-serializables.txt b/geode-gfsh/src/main/resources/org/apache/geode/gfsh/internal/management/sanctioned-geode-gfsh-serializables.txt similarity index 100% rename from geode-gfsh/src/main/resources/org/apache/geode/management/internal/sanctioned-geode-gfsh-serializables.txt rename to geode-gfsh/src/main/resources/org/apache/geode/gfsh/internal/management/sanctioned-geode-gfsh-serializables.txt diff --git a/geode-junit/src/integrationTest/java/org/apache/geode/test/junit/internal/JUnitSanctionedSerializablesServiceIntegrationTest.java b/geode-junit/src/integrationTest/java/org/apache/geode/test/junit/internal/JUnitSanctionedSerializablesServiceIntegrationTest.java index f317278..2f48af8 100644 --- a/geode-junit/src/integrationTest/java/org/apache/geode/test/junit/internal/JUnitSanctionedSerializablesServiceIntegrationTest.java +++ b/geode-junit/src/integrationTest/java/org/apache/geode/test/junit/internal/JUnitSanctionedSerializablesServiceIntegrationTest.java @@ -17,8 +17,7 @@ package org.apache.geode.test.junit.internal; import org.junit.experimental.categories.Category; import org.apache.geode.codeAnalysis.SanctionedSerializablesServiceIntegrationTestBase; -import org.apache.geode.internal.CoreSanctionedSerializablesService; -import org.apache.geode.internal.serialization.SanctionedSerializablesService; +import org.apache.geode.internal.serialization.filter.SanctionedSerializablesService; import org.apache.geode.test.junit.categories.SanctionedSerializablesTest; import org.apache.geode.test.junit.categories.SerializationTest; @@ -26,7 +25,7 @@ import org.apache.geode.test.junit.categories.SerializationTest; public class JUnitSanctionedSerializablesServiceIntegrationTest extends SanctionedSerializablesServiceIntegrationTestBase { - private final SanctionedSerializablesService service = new CoreSanctionedSerializablesService(); + private final SanctionedSerializablesService service = new JUnitSanctionedSerializablesService(); @Override protected SanctionedSerializablesService getService() { diff --git a/geode-junit/src/main/java/org/apache/geode/codeAnalysis/SanctionedSerializablesServiceIntegrationTestBase.java b/geode-junit/src/main/java/org/apache/geode/codeAnalysis/SanctionedSerializablesServiceIntegrationTestBase.java index 2fd6672..d938769 100644 --- a/geode-junit/src/main/java/org/apache/geode/codeAnalysis/SanctionedSerializablesServiceIntegrationTestBase.java +++ b/geode-junit/src/main/java/org/apache/geode/codeAnalysis/SanctionedSerializablesServiceIntegrationTestBase.java @@ -14,7 +14,7 @@ */ package org.apache.geode.codeAnalysis; -import static org.apache.geode.internal.serialization.SanctionedSerializables.loadSanctionedSerializablesServices; +import static org.apache.geode.internal.serialization.filter.SanctionedSerializables.loadSanctionedSerializablesServices; import static org.assertj.core.api.Assertions.assertThat; import java.io.IOException; @@ -23,7 +23,7 @@ import java.util.Collection; import org.junit.Test; -import org.apache.geode.internal.serialization.SanctionedSerializablesService; +import org.apache.geode.internal.serialization.filter.SanctionedSerializablesService; public abstract class SanctionedSerializablesServiceIntegrationTestBase { @@ -61,13 +61,19 @@ public abstract class SanctionedSerializablesServiceIntegrationTestBase { URL url = service.getSanctionedSerializablesURL(); - switch (getServiceResourceExpectation()) { + ServiceResourceExpectation expectation = getServiceResourceExpectation(); + String description = "Sanctioned serializables URL " + url + " " + expectation; + switch (expectation) { case NULL: - assertThat(url).isNull(); + assertThat(url) + .as(description) + .isNull(); break; case EMPTY: case NON_EMPTY: - assertThat(url).isNotNull(); + assertThat(url) + .as(description) + .isNotNull(); } } diff --git a/geode-junit/src/main/java/org/apache/geode/test/junit/categories/SanctionedSerializablesTest.java b/geode-junit/src/main/java/org/apache/geode/test/junit/categories/SanctionedSerializablesTest.java index 3401da1..ac0d7ac 100644 --- a/geode-junit/src/main/java/org/apache/geode/test/junit/categories/SanctionedSerializablesTest.java +++ b/geode-junit/src/main/java/org/apache/geode/test/junit/categories/SanctionedSerializablesTest.java @@ -14,5 +14,8 @@ */ package org.apache.geode.test.junit.categories; -public interface SanctionedSerializablesTest { +/** + * A test category for SanctionedSerializables. + */ +public interface SanctionedSerializablesTest extends SerializationTest { } diff --git a/geode-junit/src/main/java/org/apache/geode/test/junit/internal/JUnitSanctionedSerializablesService.java b/geode-junit/src/main/java/org/apache/geode/test/junit/internal/JUnitSanctionedSerializablesService.java index 0c3030e..4de5d3a 100644 --- a/geode-junit/src/main/java/org/apache/geode/test/junit/internal/JUnitSanctionedSerializablesService.java +++ b/geode-junit/src/main/java/org/apache/geode/test/junit/internal/JUnitSanctionedSerializablesService.java @@ -16,7 +16,7 @@ package org.apache.geode.test.junit.internal; import java.net.URL; -import org.apache.geode.internal.serialization.SanctionedSerializablesService; +import org.apache.geode.internal.serialization.filter.SanctionedSerializablesService; public class JUnitSanctionedSerializablesService implements SanctionedSerializablesService { diff --git a/geode-junit/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService b/geode-junit/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.filter.SanctionedSerializablesService similarity index 100% rename from geode-junit/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService rename to geode-junit/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.filter.SanctionedSerializablesService diff --git a/geode-lucene/src/integrationTest/java/org/apache/geode/cache/lucene/internal/LuceneSanctionedSerializablesServiceIntegrationTest.java b/geode-lucene/src/integrationTest/java/org/apache/geode/cache/lucene/internal/LuceneSanctionedSerializablesServiceIntegrationTest.java index 2c6ba29..f88e099 100644 --- a/geode-lucene/src/integrationTest/java/org/apache/geode/cache/lucene/internal/LuceneSanctionedSerializablesServiceIntegrationTest.java +++ b/geode-lucene/src/integrationTest/java/org/apache/geode/cache/lucene/internal/LuceneSanctionedSerializablesServiceIntegrationTest.java @@ -17,7 +17,7 @@ package org.apache.geode.cache.lucene.internal; import org.junit.experimental.categories.Category; import org.apache.geode.codeAnalysis.SanctionedSerializablesServiceIntegrationTestBase; -import org.apache.geode.internal.serialization.SanctionedSerializablesService; +import org.apache.geode.internal.serialization.filter.SanctionedSerializablesService; import org.apache.geode.test.junit.categories.SanctionedSerializablesTest; import org.apache.geode.test.junit.categories.SerializationTest; diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneSanctionedSerializablesService.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneSanctionedSerializablesService.java index 918c05d..57db794 100644 --- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneSanctionedSerializablesService.java +++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneSanctionedSerializablesService.java @@ -16,7 +16,7 @@ package org.apache.geode.cache.lucene.internal; import java.net.URL; -import org.apache.geode.internal.serialization.SanctionedSerializablesService; +import org.apache.geode.internal.serialization.filter.SanctionedSerializablesService; public class LuceneSanctionedSerializablesService implements SanctionedSerializablesService { diff --git a/geode-lucene/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService b/geode-lucene/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.filter.SanctionedSerializablesService similarity index 100% rename from geode-lucene/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService rename to geode-lucene/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.filter.SanctionedSerializablesService diff --git a/geode-management/src/integrationTest/java/org/apache/geode/management/internal/ManagementSanctionedSerializablesServiceIntegrationTest.java b/geode-management/src/integrationTest/java/org/apache/geode/management/internal/ManagementSanctionedSerializablesServiceIntegrationTest.java index e2f1c10..7a54d77 100644 --- a/geode-management/src/integrationTest/java/org/apache/geode/management/internal/ManagementSanctionedSerializablesServiceIntegrationTest.java +++ b/geode-management/src/integrationTest/java/org/apache/geode/management/internal/ManagementSanctionedSerializablesServiceIntegrationTest.java @@ -17,7 +17,7 @@ package org.apache.geode.management.internal; import org.junit.experimental.categories.Category; import org.apache.geode.codeAnalysis.SanctionedSerializablesServiceIntegrationTestBase; -import org.apache.geode.internal.serialization.SanctionedSerializablesService; +import org.apache.geode.internal.serialization.filter.SanctionedSerializablesService; import org.apache.geode.test.junit.categories.SanctionedSerializablesTest; import org.apache.geode.test.junit.categories.SerializationTest; diff --git a/geode-management/src/main/java/org/apache/geode/management/internal/ManagementSanctionedSerializablesService.java b/geode-management/src/main/java/org/apache/geode/management/internal/ManagementSanctionedSerializablesService.java index 6e232a5..051cc1d 100644 --- a/geode-management/src/main/java/org/apache/geode/management/internal/ManagementSanctionedSerializablesService.java +++ b/geode-management/src/main/java/org/apache/geode/management/internal/ManagementSanctionedSerializablesService.java @@ -16,7 +16,7 @@ package org.apache.geode.management.internal; import java.net.URL; -import org.apache.geode.internal.serialization.SanctionedSerializablesService; +import org.apache.geode.internal.serialization.filter.SanctionedSerializablesService; public class ManagementSanctionedSerializablesService implements SanctionedSerializablesService { diff --git a/geode-management/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService b/geode-management/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.filter.SanctionedSerializablesService similarity index 100% rename from geode-management/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService rename to geode-management/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.filter.SanctionedSerializablesService diff --git a/geode-membership/src/integrationTest/java/org/apache/geode/distributed/internal/membership/MembershipDependenciesJUnitTest.java b/geode-membership/src/integrationTest/java/org/apache/geode/distributed/internal/membership/MembershipDependenciesJUnitTest.java index 08211f8..d50d2e8 100644 --- a/geode-membership/src/integrationTest/java/org/apache/geode/distributed/internal/membership/MembershipDependenciesJUnitTest.java +++ b/geode-membership/src/integrationTest/java/org/apache/geode/distributed/internal/membership/MembershipDependenciesJUnitTest.java @@ -58,7 +58,6 @@ public class MembershipDependenciesJUnitTest { .or(resideInAPackage("org.apache.geode.internal.inet..")) .or(resideInAPackage("org.apache.geode.internal.lang..")) .or(resideInAPackage("org.apache.geode.codeAnalysis..")) - .or(not(resideInAPackage("org.apache.geode.."))) .or(type(AvailablePortHelper.class)) diff --git a/geode-membership/src/integrationTest/java/org/apache/geode/distributed/internal/membership/gms/MembershipSanctionedSerializablesServiceIntegrationTest.java b/geode-membership/src/integrationTest/java/org/apache/geode/distributed/internal/membership/gms/MembershipSanctionedSerializablesServiceIntegrationTest.java index cc1e6e9..1758efc 100644 --- a/geode-membership/src/integrationTest/java/org/apache/geode/distributed/internal/membership/gms/MembershipSanctionedSerializablesServiceIntegrationTest.java +++ b/geode-membership/src/integrationTest/java/org/apache/geode/distributed/internal/membership/gms/MembershipSanctionedSerializablesServiceIntegrationTest.java @@ -17,7 +17,7 @@ package org.apache.geode.distributed.internal.membership.gms; import org.junit.experimental.categories.Category; import org.apache.geode.codeAnalysis.SanctionedSerializablesServiceIntegrationTestBase; -import org.apache.geode.internal.serialization.SanctionedSerializablesService; +import org.apache.geode.internal.serialization.filter.SanctionedSerializablesService; import org.apache.geode.test.junit.categories.SanctionedSerializablesTest; import org.apache.geode.test.junit.categories.SerializationTest; diff --git a/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/MembershipSanctionedSerializablesService.java b/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/MembershipSanctionedSerializablesService.java index b611b75..9311b06 100644 --- a/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/MembershipSanctionedSerializablesService.java +++ b/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/MembershipSanctionedSerializablesService.java @@ -16,7 +16,7 @@ package org.apache.geode.distributed.internal.membership.gms; import java.net.URL; -import org.apache.geode.internal.serialization.SanctionedSerializablesService; +import org.apache.geode.internal.serialization.filter.SanctionedSerializablesService; public class MembershipSanctionedSerializablesService implements SanctionedSerializablesService { diff --git a/geode-membership/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService b/geode-membership/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.filter.SanctionedSerializablesService similarity index 100% rename from geode-membership/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService rename to geode-membership/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.filter.SanctionedSerializablesService diff --git a/geode-memcached/src/integrationTest/java/org/apache/geode/internal/memcached/MemcachedSanctionedSerializablesServiceIntegrationTest.java b/geode-memcached/src/integrationTest/java/org/apache/geode/internal/memcached/MemcachedSanctionedSerializablesServiceIntegrationTest.java index 536b61b..9badf90 100644 --- a/geode-memcached/src/integrationTest/java/org/apache/geode/internal/memcached/MemcachedSanctionedSerializablesServiceIntegrationTest.java +++ b/geode-memcached/src/integrationTest/java/org/apache/geode/internal/memcached/MemcachedSanctionedSerializablesServiceIntegrationTest.java @@ -17,7 +17,7 @@ package org.apache.geode.internal.memcached; import org.junit.experimental.categories.Category; import org.apache.geode.codeAnalysis.SanctionedSerializablesServiceIntegrationTestBase; -import org.apache.geode.internal.serialization.SanctionedSerializablesService; +import org.apache.geode.internal.serialization.filter.SanctionedSerializablesService; import org.apache.geode.test.junit.categories.SanctionedSerializablesTest; import org.apache.geode.test.junit.categories.SerializationTest; diff --git a/geode-memcached/src/main/java/org/apache/geode/internal/memcached/MemcachedSanctionedSerializablesService.java b/geode-memcached/src/main/java/org/apache/geode/internal/memcached/MemcachedSanctionedSerializablesService.java index ab04e2d..014a234 100644 --- a/geode-memcached/src/main/java/org/apache/geode/internal/memcached/MemcachedSanctionedSerializablesService.java +++ b/geode-memcached/src/main/java/org/apache/geode/internal/memcached/MemcachedSanctionedSerializablesService.java @@ -16,7 +16,7 @@ package org.apache.geode.internal.memcached; import java.net.URL; -import org.apache.geode.internal.serialization.SanctionedSerializablesService; +import org.apache.geode.internal.serialization.filter.SanctionedSerializablesService; public class MemcachedSanctionedSerializablesService implements SanctionedSerializablesService { diff --git a/geode-memcached/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService b/geode-memcached/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.filter.SanctionedSerializablesService similarity index 100% rename from geode-memcached/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService rename to geode-memcached/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.filter.SanctionedSerializablesService diff --git a/geode-redis/src/main/java/org/apache/geode/redis/internal/RedisSanctionedSerializablesService.java b/geode-redis/src/main/java/org/apache/geode/redis/internal/RedisSanctionedSerializablesService.java index d9853ef..59842e1 100644 --- a/geode-redis/src/main/java/org/apache/geode/redis/internal/RedisSanctionedSerializablesService.java +++ b/geode-redis/src/main/java/org/apache/geode/redis/internal/RedisSanctionedSerializablesService.java @@ -16,7 +16,7 @@ package org.apache.geode.redis.internal; import java.net.URL; -import org.apache.geode.internal.serialization.SanctionedSerializablesService; +import org.apache.geode.internal.serialization.filter.SanctionedSerializablesService; public class RedisSanctionedSerializablesService implements SanctionedSerializablesService { diff --git a/geode-redis/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService b/geode-redis/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.filter.SanctionedSerializablesService similarity index 100% copy from geode-redis/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService copy to geode-redis/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.filter.SanctionedSerializablesService diff --git a/geode-redis/src/test/java/org/apache/geode/redis/internal/executor/RedisSanctionedSerializablesServiceIntegrationTest.java b/geode-redis/src/test/java/org/apache/geode/redis/internal/executor/RedisSanctionedSerializablesServiceIntegrationTest.java index 420db71..82f8cf9 100644 --- a/geode-redis/src/test/java/org/apache/geode/redis/internal/executor/RedisSanctionedSerializablesServiceIntegrationTest.java +++ b/geode-redis/src/test/java/org/apache/geode/redis/internal/executor/RedisSanctionedSerializablesServiceIntegrationTest.java @@ -17,7 +17,7 @@ package org.apache.geode.redis.internal; import org.junit.experimental.categories.Category; import org.apache.geode.codeAnalysis.SanctionedSerializablesServiceIntegrationTestBase; -import org.apache.geode.internal.serialization.SanctionedSerializablesService; +import org.apache.geode.internal.serialization.filter.SanctionedSerializablesService; import org.apache.geode.test.junit.categories.SanctionedSerializablesTest; import org.apache.geode.test.junit.categories.SerializationTest; diff --git a/geode-redis/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService b/geode-redis/src/test/resources/META-INF/services/org.apache.geode.internal.serialization.filter.SanctionedSerializablesService similarity index 100% rename from geode-redis/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService rename to geode-redis/src/test/resources/META-INF/services/org.apache.geode.internal.serialization.filter.SanctionedSerializablesService diff --git a/geode-serialization/build.gradle b/geode-serialization/build.gradle index 54620c7..581b424 100755 --- a/geode-serialization/build.gradle +++ b/geode-serialization/build.gradle @@ -25,10 +25,14 @@ dependencies { //Geode-common has annotations and other pieces used by geode-serialization implementation(project(':geode-common')) + implementation(project(':geode-logging')) //FastUtil contains optimized collections that are used in multiple places in core implementation('it.unimi.dsi:fastutil') + // serialization filtering uses Apache Commons + implementation('org.apache.commons:commons-lang3') + //Log4j is used everywhere implementation('org.apache.logging.log4j:log4j-api') diff --git a/geode-serialization/src/integrationTest/java/org/apache/geode/internal/serialization/SerializationSanctionedSerializablesServiceIntegrationTest.java b/geode-serialization/src/integrationTest/java/org/apache/geode/internal/serialization/SerializationSanctionedSerializablesServiceIntegrationTest.java index f733ee7..5c54d94 100644 --- a/geode-serialization/src/integrationTest/java/org/apache/geode/internal/serialization/SerializationSanctionedSerializablesServiceIntegrationTest.java +++ b/geode-serialization/src/integrationTest/java/org/apache/geode/internal/serialization/SerializationSanctionedSerializablesServiceIntegrationTest.java @@ -17,6 +17,7 @@ package org.apache.geode.internal.serialization; import org.junit.experimental.categories.Category; import org.apache.geode.codeAnalysis.SanctionedSerializablesServiceIntegrationTestBase; +import org.apache.geode.internal.serialization.filter.SanctionedSerializablesService; import org.apache.geode.test.junit.categories.SanctionedSerializablesTest; import org.apache.geode.test.junit.categories.SerializationTest; diff --git a/geode-wan/src/main/resources/org/apache/geode/internal/cache/wan/sanctioned-geode-wan-serializables.txt b/geode-serialization/src/integrationTest/resources/org/apache/geode/codeAnalysis/excludedClasses.txt old mode 100755 new mode 100644 similarity index 100% copy from geode-wan/src/main/resources/org/apache/geode/internal/cache/wan/sanctioned-geode-wan-serializables.txt copy to geode-serialization/src/integrationTest/resources/org/apache/geode/codeAnalysis/excludedClasses.txt diff --git a/geode-serialization/src/main/java/org/apache/geode/internal/serialization/SerializationSanctionedSerializablesService.java b/geode-serialization/src/main/java/org/apache/geode/internal/serialization/SerializationSanctionedSerializablesService.java index 52827f2..5957db6 100644 --- a/geode-serialization/src/main/java/org/apache/geode/internal/serialization/SerializationSanctionedSerializablesService.java +++ b/geode-serialization/src/main/java/org/apache/geode/internal/serialization/SerializationSanctionedSerializablesService.java @@ -16,6 +16,8 @@ package org.apache.geode.internal.serialization; import java.net.URL; +import org.apache.geode.internal.serialization.filter.SanctionedSerializablesService; + public class SerializationSanctionedSerializablesService implements SanctionedSerializablesService { @Override diff --git a/geode-serialization/src/main/java/org/apache/geode/internal/serialization/SanctionedSerializables.java b/geode-serialization/src/main/java/org/apache/geode/internal/serialization/filter/SanctionedSerializables.java similarity index 64% rename from geode-serialization/src/main/java/org/apache/geode/internal/serialization/SanctionedSerializables.java rename to geode-serialization/src/main/java/org/apache/geode/internal/serialization/filter/SanctionedSerializables.java index 7b9a77f..a493c58 100644 --- a/geode-serialization/src/main/java/org/apache/geode/internal/serialization/SanctionedSerializables.java +++ b/geode-serialization/src/main/java/org/apache/geode/internal/serialization/filter/SanctionedSerializables.java @@ -12,7 +12,7 @@ * or implied. See the License for the specific language governing permissions and limitations under * the License. */ -package org.apache.geode.internal.serialization; +package org.apache.geode.internal.serialization.filter; import static java.util.Collections.emptyList; @@ -20,20 +20,33 @@ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.io.UncheckedIOException; import java.net.URL; import java.util.ArrayList; import java.util.Collection; +import java.util.HashSet; import java.util.ServiceLoader; +import java.util.Set; + +import org.apache.logging.log4j.Logger; + +import org.apache.geode.logging.internal.log4j.api.LogService; public class SanctionedSerializables { + private static final Logger logger = LogService.getLogger(); + + private SanctionedSerializables() { + // do not instantiate + } + /** * Loads all SanctionedSerializablesServices on the classpath. */ - public static Collection<SanctionedSerializablesService> loadSanctionedSerializablesServices() { + public static Set<SanctionedSerializablesService> loadSanctionedSerializablesServices() { ServiceLoader<SanctionedSerializablesService> loader = ServiceLoader.load(SanctionedSerializablesService.class); - Collection<SanctionedSerializablesService> services = new ArrayList<>(); + Set<SanctionedSerializablesService> services = new HashSet<>(); for (SanctionedSerializablesService service : loader) { services.add(service); } @@ -62,4 +75,22 @@ public class SanctionedSerializables { } return result; } + + public static Set<String> loadSanctionedClassNames( + Iterable<SanctionedSerializablesService> services) { + Set<String> sanctionedClasses = new HashSet<>(650); + for (SanctionedSerializablesService service : services) { + try { + Collection<String> classNames = service.getSerializationAcceptlist(); + logger.info("loaded {} sanctioned serializables from {}", classNames.size(), + service.getClass().getSimpleName()); + sanctionedClasses.addAll(classNames); + } catch (IOException e) { + throw new UncheckedIOException( + "Unable to initialize serialization filter for " + service, + e); + } + } + return sanctionedClasses; + } } diff --git a/geode-serialization/src/main/java/org/apache/geode/internal/serialization/SanctionedSerializablesService.java b/geode-serialization/src/main/java/org/apache/geode/internal/serialization/filter/SanctionedSerializablesService.java similarity index 95% rename from geode-serialization/src/main/java/org/apache/geode/internal/serialization/SanctionedSerializablesService.java rename to geode-serialization/src/main/java/org/apache/geode/internal/serialization/filter/SanctionedSerializablesService.java index ad40721..1d139ce 100644 --- a/geode-serialization/src/main/java/org/apache/geode/internal/serialization/SanctionedSerializablesService.java +++ b/geode-serialization/src/main/java/org/apache/geode/internal/serialization/filter/SanctionedSerializablesService.java @@ -12,7 +12,7 @@ * or implied. See the License for the specific language governing permissions and limitations under * the License. */ -package org.apache.geode.internal.serialization; +package org.apache.geode.internal.serialization.filter; import java.io.IOException; import java.net.URL; diff --git a/geode-serialization/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService b/geode-serialization/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.filter.SanctionedSerializablesService similarity index 100% rename from geode-serialization/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService rename to geode-serialization/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.filter.SanctionedSerializablesService diff --git a/geode-serialization/src/test/java/org/apache/geode/internal/serialization/SerializationDependenciesJUnitTest.java b/geode-serialization/src/test/java/org/apache/geode/internal/serialization/SerializationDependenciesTest.java similarity index 75% rename from geode-serialization/src/test/java/org/apache/geode/internal/serialization/SerializationDependenciesJUnitTest.java rename to geode-serialization/src/test/java/org/apache/geode/internal/serialization/SerializationDependenciesTest.java index f10845b..199cb0f 100644 --- a/geode-serialization/src/test/java/org/apache/geode/internal/serialization/SerializationDependenciesJUnitTest.java +++ b/geode-serialization/src/test/java/org/apache/geode/internal/serialization/SerializationDependenciesTest.java @@ -18,7 +18,8 @@ import static com.tngtech.archunit.base.DescribedPredicate.not; import static com.tngtech.archunit.core.domain.JavaClass.Predicates.resideInAPackage; import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.classes; -import com.tngtech.archunit.core.importer.ImportOption; +import com.tngtech.archunit.core.importer.ImportOption.DoNotIncludeArchives; +import com.tngtech.archunit.core.importer.ImportOption.DoNotIncludeTests; import com.tngtech.archunit.junit.AnalyzeClasses; import com.tngtech.archunit.junit.ArchTest; import com.tngtech.archunit.junit.ArchUnitRunner; @@ -26,22 +27,22 @@ import com.tngtech.archunit.junit.CacheMode; import com.tngtech.archunit.lang.ArchRule; import org.junit.runner.RunWith; - @RunWith(ArchUnitRunner.class) -@AnalyzeClasses(packages = "org.apache.geode.internal.serialization..", +@AnalyzeClasses( + packages = "org.apache.geode.internal.serialization..", cacheMode = CacheMode.PER_CLASS, - importOptions = {ImportOption.DoNotIncludeArchives.class, ImportOption.DoNotIncludeTests.class}) -public class SerializationDependenciesJUnitTest { + importOptions = {DoNotIncludeArchives.class, DoNotIncludeTests.class}) +public class SerializationDependenciesTest { @ArchTest - public static final ArchRule serializationDoesntDependOnCoreProvisional = classes() + public static final ArchRule serializationDoesNotDependOnCore = classes() .that() .resideInAPackage("org.apache.geode.internal.serialization..") - .should() .onlyDependOnClassesThat( resideInAPackage("org.apache.geode.internal.serialization..") .or(not(resideInAPackage("org.apache.geode.."))) + .or(resideInAPackage("org.apache.geode.annotations..")) + .or(resideInAPackage("org.apache.geode.logging..")) .or(resideInAPackage("org.apache.geode.test.."))); - } diff --git a/geode-serialization/src/test/java/org/apache/geode/internal/serialization/filter/SanctionedSerializablesTest.java b/geode-serialization/src/test/java/org/apache/geode/internal/serialization/filter/SanctionedSerializablesTest.java new file mode 100644 index 0000000..33c4684 --- /dev/null +++ b/geode-serialization/src/test/java/org/apache/geode/internal/serialization/filter/SanctionedSerializablesTest.java @@ -0,0 +1,95 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package org.apache.geode.internal.serialization.filter; + +import static java.util.Arrays.asList; +import static java.util.Collections.emptySet; +import static org.apache.geode.internal.serialization.filter.SanctionedSerializables.loadSanctionedClassNames; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.catchThrowable; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.io.IOException; +import java.io.UncheckedIOException; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import org.junit.Test; + +public class SanctionedSerializablesTest { + + @Test + public void returnsAcceptListFromSanctionedSerializablesService() { + Collection<SanctionedSerializablesService> services = new HashSet<>(); + services.add(serviceWithSanctionedSerializablesOf("foo", "bar")); + + Set<String> result = loadSanctionedClassNames(services); + + assertThat(result).containsExactlyInAnyOrder("foo", "bar"); + } + + @Test + public void returnsAcceptListsFromManySanctionedSerializablesServices() { + Collection<SanctionedSerializablesService> services = new HashSet<>(); + services.add(serviceWithSanctionedSerializablesOf("foo", "bar")); + services.add(serviceWithSanctionedSerializablesOf("the", "fox")); + services.add(serviceWithSanctionedSerializablesOf("a", "bear")); + + Set<String> result = loadSanctionedClassNames(services); + + assertThat(result).containsExactlyInAnyOrder("foo", "bar", "the", "fox", "a", "bear"); + } + + @Test + public void nullThrowsNullPointerException() { + Throwable thrown = catchThrowable(() -> { + loadSanctionedClassNames(null); + }); + + assertThat(thrown).isInstanceOf(NullPointerException.class); + } + + @Test + public void emptyServicesReturnsEmptySet() { + Set<String> result = loadSanctionedClassNames(emptySet()); + + assertThat(result).isEmpty(); + } + + @Test + public void servicesWithEmptyAcceptListsReturnsEmptySet() { + Collection<SanctionedSerializablesService> services = new HashSet<>(); + services.add(serviceWithSanctionedSerializablesOf()); + services.add(serviceWithSanctionedSerializablesOf()); + services.add(serviceWithSanctionedSerializablesOf()); + + Set<String> result = loadSanctionedClassNames(services); + + assertThat(result).isEmpty(); + } + + private static SanctionedSerializablesService serviceWithSanctionedSerializablesOf( + String... classNames) { + try { + SanctionedSerializablesService service = mock(SanctionedSerializablesService.class); + when(service.getSerializationAcceptlist()).thenReturn(asList(classNames)); + return service; + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } +} diff --git a/geode-serialization/src/test/resources/expected-pom.xml b/geode-serialization/src/test/resources/expected-pom.xml index 3da2a5a..ae1f34e 100644 --- a/geode-serialization/src/test/resources/expected-pom.xml +++ b/geode-serialization/src/test/resources/expected-pom.xml @@ -52,11 +52,21 @@ <scope>runtime</scope> </dependency> <dependency> + <groupId>org.apache.geode</groupId> + <artifactId>geode-logging</artifactId> + <scope>runtime</scope> + </dependency> + <dependency> <groupId>it.unimi.dsi</groupId> <artifactId>fastutil</artifactId> <scope>runtime</scope> </dependency> <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> + <scope>runtime</scope> + </dependency> + <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-api</artifactId> <scope>runtime</scope> diff --git a/geode-wan/src/integrationTest/java/org/apache/geode/internal/cache/wan/WANSanctionedSerializablesServiceIntegrationTest.java b/geode-wan/src/integrationTest/java/org/apache/geode/cache/wan/internal/WANSanctionedSerializablesServiceIntegrationTest.java similarity index 92% rename from geode-wan/src/integrationTest/java/org/apache/geode/internal/cache/wan/WANSanctionedSerializablesServiceIntegrationTest.java rename to geode-wan/src/integrationTest/java/org/apache/geode/cache/wan/internal/WANSanctionedSerializablesServiceIntegrationTest.java index 49749d4..a6bacf7 100644 --- a/geode-wan/src/integrationTest/java/org/apache/geode/internal/cache/wan/WANSanctionedSerializablesServiceIntegrationTest.java +++ b/geode-wan/src/integrationTest/java/org/apache/geode/cache/wan/internal/WANSanctionedSerializablesServiceIntegrationTest.java @@ -12,12 +12,12 @@ * or implied. See the License for the specific language governing permissions and limitations under * the License. */ -package org.apache.geode.internal.cache.wan; +package org.apache.geode.cache.wan.internal; import org.junit.experimental.categories.Category; import org.apache.geode.codeAnalysis.SanctionedSerializablesServiceIntegrationTestBase; -import org.apache.geode.internal.serialization.SanctionedSerializablesService; +import org.apache.geode.internal.serialization.filter.SanctionedSerializablesService; import org.apache.geode.test.junit.categories.SanctionedSerializablesTest; import org.apache.geode.test.junit.categories.SerializationTest; diff --git a/geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesIntegrationTest.java b/geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesIntegrationTest.java index 0f42cb5..cd02f06 100644 --- a/geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesIntegrationTest.java +++ b/geode-wan/src/integrationTest/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesIntegrationTest.java @@ -18,7 +18,7 @@ import java.util.Optional; import org.junit.experimental.categories.Category; -import org.apache.geode.internal.cache.wan.WANSanctionedSerializablesService; +import org.apache.geode.cache.wan.internal.WANSanctionedSerializablesService; import org.apache.geode.test.junit.categories.SerializationTest; import org.apache.geode.test.junit.categories.WanTest; diff --git a/geode-wan/src/main/java/org/apache/geode/internal/cache/wan/WANSanctionedSerializablesService.java b/geode-wan/src/main/java/org/apache/geode/cache/wan/internal/WANSanctionedSerializablesService.java similarity index 88% rename from geode-wan/src/main/java/org/apache/geode/internal/cache/wan/WANSanctionedSerializablesService.java rename to geode-wan/src/main/java/org/apache/geode/cache/wan/internal/WANSanctionedSerializablesService.java index 0c92c02..6513569 100644 --- a/geode-wan/src/main/java/org/apache/geode/internal/cache/wan/WANSanctionedSerializablesService.java +++ b/geode-wan/src/main/java/org/apache/geode/cache/wan/internal/WANSanctionedSerializablesService.java @@ -12,11 +12,11 @@ * or implied. See the License for the specific language governing permissions and limitations under * the License. */ -package org.apache.geode.internal.cache.wan; +package org.apache.geode.cache.wan.internal; import java.net.URL; -import org.apache.geode.internal.serialization.SanctionedSerializablesService; +import org.apache.geode.internal.serialization.filter.SanctionedSerializablesService; public class WANSanctionedSerializablesService implements SanctionedSerializablesService { diff --git a/geode-wan/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService b/geode-wan/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.filter.SanctionedSerializablesService similarity index 92% rename from geode-wan/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService rename to geode-wan/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.filter.SanctionedSerializablesService index c6090ca..6ad149d 100644 --- a/geode-wan/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService +++ b/geode-wan/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.filter.SanctionedSerializablesService @@ -12,4 +12,4 @@ # or implied. See the License for the specific language governing permissions and limitations under # the License. # -org.apache.geode.internal.cache.wan.WANSanctionedSerializablesService +org.apache.geode.cache.wan.internal.WANSanctionedSerializablesService diff --git a/geode-wan/src/main/resources/org/apache/geode/internal/cache/wan/sanctioned-geode-wan-serializables.txt b/geode-wan/src/main/resources/org/apache/geode/cache/wan/internal/sanctioned-geode-wan-serializables.txt similarity index 100% rename from geode-wan/src/main/resources/org/apache/geode/internal/cache/wan/sanctioned-geode-wan-serializables.txt rename to geode-wan/src/main/resources/org/apache/geode/cache/wan/internal/sanctioned-geode-wan-serializables.txt diff --git a/geode-web-api/src/integrationTest/java/org/apache/geode/rest/internal/WebApiSanctionedSerializablesServiceIntegrationTest.java b/geode-web-api/src/integrationTest/java/org/apache/geode/rest/internal/WebApiSanctionedSerializablesServiceIntegrationTest.java index 8408c24..05ab52b 100644 --- a/geode-web-api/src/integrationTest/java/org/apache/geode/rest/internal/WebApiSanctionedSerializablesServiceIntegrationTest.java +++ b/geode-web-api/src/integrationTest/java/org/apache/geode/rest/internal/WebApiSanctionedSerializablesServiceIntegrationTest.java @@ -17,7 +17,7 @@ package org.apache.geode.rest.internal; import org.junit.experimental.categories.Category; import org.apache.geode.codeAnalysis.SanctionedSerializablesServiceIntegrationTestBase; -import org.apache.geode.internal.serialization.SanctionedSerializablesService; +import org.apache.geode.internal.serialization.filter.SanctionedSerializablesService; import org.apache.geode.test.junit.categories.SanctionedSerializablesTest; import org.apache.geode.test.junit.categories.SerializationTest; diff --git a/geode-web-api/src/main/java/org/apache/geode/rest/internal/WebApiSanctionedSerializablesService.java b/geode-web-api/src/main/java/org/apache/geode/rest/internal/WebApiSanctionedSerializablesService.java index 846a02e..9d24c0b 100644 --- a/geode-web-api/src/main/java/org/apache/geode/rest/internal/WebApiSanctionedSerializablesService.java +++ b/geode-web-api/src/main/java/org/apache/geode/rest/internal/WebApiSanctionedSerializablesService.java @@ -16,7 +16,7 @@ package org.apache.geode.rest.internal; import java.net.URL; -import org.apache.geode.internal.serialization.SanctionedSerializablesService; +import org.apache.geode.internal.serialization.filter.SanctionedSerializablesService; public class WebApiSanctionedSerializablesService implements SanctionedSerializablesService { diff --git a/geode-web-api/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService b/geode-web-api/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.filter.SanctionedSerializablesService similarity index 100% rename from geode-web-api/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.SanctionedSerializablesService rename to geode-web-api/src/main/resources/META-INF/services/org.apache.geode.internal.serialization.filter.SanctionedSerializablesService