geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From u..@apache.org
Subject [10/11] incubator-geode git commit: GEODE-1809: Fix NPE in GemFireVersion
Date Mon, 12 Sep 2016 19:30:51 GMT
GEODE-1809: Fix NPE in GemFireVersion

Add a unit test to validate behavior when properties file is not
present.


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/71c863b5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/71c863b5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/71c863b5

Branch: refs/heads/feature/GEODE-420
Commit: 71c863b5c6ffda7fc212a13b05ff3c47b6e13d3f
Parents: e4a09a6
Author: Anthony Baker <abaker@apache.org>
Authored: Wed Sep 7 11:48:34 2016 -0700
Committer: Anthony Baker <abaker@apache.org>
Committed: Mon Sep 12 07:11:40 2016 -0700

----------------------------------------------------------------------
 .../com/gemstone/gemfire/internal/GemFireVersion.java     |  2 +-
 .../gemfire/internal/GemFireVersionJUnitTest.java         | 10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/71c863b5/geode-core/src/main/java/com/gemstone/gemfire/internal/GemFireVersion.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/GemFireVersion.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/GemFireVersion.java
index d8fa21b..73c36c5 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/GemFireVersion.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/GemFireVersion.java
@@ -207,7 +207,7 @@ public class GemFireVersion {
     }
 
     public String getProperty(String key) {
-      return error.orElse(description.getProperty(key));
+      return error.orElseGet(() -> description.getProperty(key));
     }
     
     public String getNativeCodeVersion() {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/71c863b5/geode-core/src/test/java/com/gemstone/gemfire/internal/GemFireVersionJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/GemFireVersionJUnitTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/internal/GemFireVersionJUnitTest.java
index 850172a..44df2ca 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/GemFireVersionJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/GemFireVersionJUnitTest.java
@@ -17,6 +17,7 @@
 package com.gemstone.gemfire.internal;
 
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
 
 import java.io.PrintWriter;
 import java.io.StringWriter;
@@ -64,4 +65,13 @@ public class GemFireVersionJUnitTest {
     String noFileOutput = sw.toString();
     assertTrue(noFileOutput.contains(LocalizedStrings.GemFireVersion_COULD_NOT_FIND_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_0.toLocalizedString(noFile)));
   }
+  
+  @Test
+  public void testNoFileGetProperty() {
+    String noFile = "not a property file";
+    VersionDescription noVersion = new VersionDescription(noFile);
+
+    String err = LocalizedStrings.GemFireVersion_COULD_NOT_FIND_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_0.toLocalizedString(noFile);
+    assertEquals(err, noVersion.getProperty(VersionDescription.GEMFIRE_VERSION));
+  }
 }


Mime
View raw message