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/18 00:57:45 UTC

[geode] branch develop updated: GEODE-6289: check for null className on createPdxInstanceFactory (#3090)

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

dschneider pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git


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

commit a757ccb87d75b3af6c5da619338297d24cc21519
Author: Darrel Schneider <ds...@pivotal.io>
AuthorDate: Thu Jan 17 16:57:36 2019 -0800

    GEODE-6289: check for null className on createPdxInstanceFactory (#3090)
---
 .../apache/geode/connectors/jdbc/JdbcLoaderIntegrationTest.java    | 3 ++-
 .../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 ++++
 4 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/geode-connectors/src/acceptanceTest/java/org/apache/geode/connectors/jdbc/JdbcLoaderIntegrationTest.java b/geode-connectors/src/acceptanceTest/java/org/apache/geode/connectors/jdbc/JdbcLoaderIntegrationTest.java
index b9295e8..aba445d 100644
--- a/geode-connectors/src/acceptanceTest/java/org/apache/geode/connectors/jdbc/JdbcLoaderIntegrationTest.java
+++ b/geode-connectors/src/acceptanceTest/java/org/apache/geode/connectors/jdbc/JdbcLoaderIntegrationTest.java
@@ -205,7 +205,8 @@ public abstract class JdbcLoaderIntegrationTest {
   @Test
   public void verifySimpleMiss() throws Exception {
     createEmployeeTable();
-    Region<String, PdxInstance> region = createRegionWithJDBCLoader(REGION_TABLE_NAME, null);
+    Region<String, PdxInstance> region =
+        createRegionWithJDBCLoader(REGION_TABLE_NAME, "pdxClassName");
     PdxInstance pdx = region.get("1");
     assertThat(pdx).isNull();
   }
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 dc97aa9..5f3ea52 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);