You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ds...@apache.org on 2019/01/17 20:02:33 UTC

[geode] branch feature/GEODE-6289 updated: GEODE-6289: check for null className on createPdxInstanceFactory

This is an automated email from the ASF dual-hosted git repository.

dschneider pushed a commit to branch feature/GEODE-6289
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/feature/GEODE-6289 by this push:
     new aba102e  GEODE-6289: check for null className on createPdxInstanceFactory
aba102e is described below

commit aba102e719ecc4a9b5ebf34f3bf3757add677059
Author: Darrel Schneider <ds...@pivotal.io>
AuthorDate: Thu Jan 17 12:01:47 2019 -0800

    GEODE-6289: check for null className on createPdxInstanceFactory
---
 .../java/org/apache/geode/pdx/PdxInstanceFactoryJUnitTest.java     | 7 +++++++
 geode-core/src/main/java/org/apache/geode/cache/RegionService.java | 1 +
 .../java/org/apache/geode/pdx/internal/PdxInstanceFactoryImpl.java | 4 ++++
 3 files changed, 12 insertions(+)

diff --git a/geode-core/src/integrationTest/java/org/apache/geode/pdx/PdxInstanceFactoryJUnitTest.java b/geode-core/src/integrationTest/java/org/apache/geode/pdx/PdxInstanceFactoryJUnitTest.java
index 3138854..15f9ee2 100644
--- a/geode-core/src/integrationTest/java/org/apache/geode/pdx/PdxInstanceFactoryJUnitTest.java
+++ b/geode-core/src/integrationTest/java/org/apache/geode/pdx/PdxInstanceFactoryJUnitTest.java
@@ -1321,6 +1321,13 @@ public class PdxInstanceFactoryJUnitTest {
   }
 
   @Test
+  public void createPdxInstanceFactoryWithNullClassNameThrowsException() {
+    assertThatThrownBy(() -> cache.createPdxInstanceFactory(null))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessage("Class name can not be null when creating a PdxInstanceFactory");
+  }
+
+  @Test
   public void normalPdxInstanceAddedToRegionWithPdxReadSerializedFalseAndABadClassThrowsClassNotFoundWhenRegionGet() {
     // make sure the cache has pdx-read-serialized set to false
     this.cache.close();
diff --git a/geode-core/src/main/java/org/apache/geode/cache/RegionService.java b/geode-core/src/main/java/org/apache/geode/cache/RegionService.java
index 01e60c6..cdf1535 100644
--- a/geode-core/src/main/java/org/apache/geode/cache/RegionService.java
+++ b/geode-core/src/main/java/org/apache/geode/cache/RegionService.java
@@ -76,6 +76,7 @@ public interface RegionService extends AutoCloseable {
    * @param className the fully qualified class name that the PdxInstance will become when it is
    *        fully deserialized.
    * @return the factory
+   * @throws IllegalArgumentException if className is <code>null</code>.
    * @since GemFire 6.6.2
    */
   PdxInstanceFactory createPdxInstanceFactory(String className);
diff --git a/geode-core/src/main/java/org/apache/geode/pdx/internal/PdxInstanceFactoryImpl.java b/geode-core/src/main/java/org/apache/geode/pdx/internal/PdxInstanceFactoryImpl.java
index 8ccc330..3a9163c 100644
--- a/geode-core/src/main/java/org/apache/geode/pdx/internal/PdxInstanceFactoryImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/pdx/internal/PdxInstanceFactoryImpl.java
@@ -38,6 +38,10 @@ public class PdxInstanceFactoryImpl implements PdxInstanceFactory {
   private boolean created = false;
 
   private PdxInstanceFactoryImpl(String name, boolean expectDomainClass, TypeRegistry pdxRegistry) {
+    if (name == null) {
+      throw new IllegalArgumentException(
+          "Class name can not be null when creating a PdxInstanceFactory");
+    }
     PdxOutputStream pdxOutputStream = new PdxOutputStream();
     this.pdxType = new PdxType(name, expectDomainClass);
     this.writer = new PdxWriterImpl(pdxType, pdxRegistry, pdxOutputStream);