You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ja...@apache.org on 2017/08/17 22:46:43 UTC

[1/2] geode git commit: Added static initializer for Field Throws IllegalState instead of NoSuchElementException

Repository: geode
Updated Branches:
  refs/heads/feature/GEODE-3434 d282ec447 -> 377744b73


Added static initializer for Field
Throws IllegalState instead of NoSuchElementException


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

Branch: refs/heads/feature/GEODE-3434
Commit: 96326feaedc80f08d2a902a94e703ae48083bcb1
Parents: d282ec4
Author: Jason Huynh <hu...@gmail.com>
Authored: Thu Aug 17 15:32:43 2017 -0700
Committer: Jason Huynh <hu...@gmail.com>
Committed: Thu Aug 17 15:32:43 2017 -0700

----------------------------------------------------------------------
 .../modules/session/catalina/DeltaSession.java  | 27 +++++++++++---------
 1 file changed, 15 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/96326fea/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSession.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSession.java b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSession.java
index 669f68a..3037883 100644
--- a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSession.java
+++ b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSession.java
@@ -50,7 +50,6 @@ import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.NoSuchElementException;
 import java.util.concurrent.ConcurrentHashMap;
 
 @SuppressWarnings("serial")
@@ -82,10 +81,21 @@ public class DeltaSession extends StandardSession
 
   private byte[] serializedPrincipal;
 
-  private Field cachedField = null;
+  private static Field cachedField = null;
 
   private final Log LOG = LogFactory.getLog(DeltaSession.class.getName());
 
+  static {
+    try {
+      if (cachedField == null) {
+        cachedField = StandardSession.class.getDeclaredField("attributes");
+        cachedField.setAccessible(true);
+      }
+    }
+    catch (NoSuchFieldException e) {
+     throw new IllegalStateException(e);
+    }
+  }
   /**
    * The string manager for this package.
    */
@@ -562,20 +572,13 @@ public class DeltaSession extends StandardSession
     try {
       Field field = getAttributesFieldObject();
       field.set(this, map);
-    } catch (NoSuchFieldException e) {
-      logError(e);
-      throw new NoSuchElementException(e.getMessage());
     } catch (IllegalAccessException e) {
       logError(e);
       throw new IllegalStateException(e);
     }
   }
 
-  protected Field getAttributesFieldObject() throws NoSuchFieldException {
-    if (cachedField == null) {
-      cachedField = StandardSession.class.getDeclaredField("attributes");
-      cachedField.setAccessible(true);
-    }
+  protected Field getAttributesFieldObject()  {
     return cachedField;
   }
 
@@ -620,10 +623,10 @@ public class DeltaSession extends StandardSession
       Field field = getAttributesFieldObject();
       Map map = (Map) field.get(this);
       return map;
-    } catch (Exception e) {
+    } catch (IllegalAccessException e) {
       logError(e);
     }
-    throw new NoSuchElementException("Unable to access attributes field");
+    throw new IllegalStateException("Unable to access attributes field");
   }
 
   protected byte[] serialize(Object obj) {


[2/2] geode git commit: Using locator name in test

Posted by ja...@apache.org.
Using locator name in test


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

Branch: refs/heads/feature/GEODE-3434
Commit: 377744b7374a8c1b93f60a5e0ece494cd522bf40
Parents: 96326fe
Author: Jason Huynh <hu...@gmail.com>
Authored: Thu Aug 17 15:45:46 2017 -0700
Committer: Jason Huynh <hu...@gmail.com>
Committed: Thu Aug 17 15:45:46 2017 -0700

----------------------------------------------------------------------
 .../geode/modules/session/catalina/DeltaSession.java   | 13 +++++--------
 .../tests/TomcatSessionBackwardsCompatibilityTest.java |  2 +-
 2 files changed, 6 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/377744b7/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSession.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSession.java b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSession.java
index 3037883..27e5bce 100644
--- a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSession.java
+++ b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSession.java
@@ -87,13 +87,10 @@ public class DeltaSession extends StandardSession
 
   static {
     try {
-      if (cachedField == null) {
-        cachedField = StandardSession.class.getDeclaredField("attributes");
-        cachedField.setAccessible(true);
-      }
-    }
-    catch (NoSuchFieldException e) {
-     throw new IllegalStateException(e);
+      cachedField = StandardSession.class.getDeclaredField("attributes");
+      cachedField.setAccessible(true);
+    } catch (NoSuchFieldException e) {
+      throw new IllegalStateException(e);
     }
   }
   /**
@@ -578,7 +575,7 @@ public class DeltaSession extends StandardSession
     }
   }
 
-  protected Field getAttributesFieldObject()  {
+  protected Field getAttributesFieldObject() {
     return cachedField;
   }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/377744b7/geode-assembly/src/test/java/org/apache/geode/session/tests/TomcatSessionBackwardsCompatibilityTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/org/apache/geode/session/tests/TomcatSessionBackwardsCompatibilityTest.java b/geode-assembly/src/test/java/org/apache/geode/session/tests/TomcatSessionBackwardsCompatibilityTest.java
index aac851f..7b23380 100644
--- a/geode-assembly/src/test/java/org/apache/geode/session/tests/TomcatSessionBackwardsCompatibilityTest.java
+++ b/geode-assembly/src/test/java/org/apache/geode/session/tests/TomcatSessionBackwardsCompatibilityTest.java
@@ -102,7 +102,7 @@ public class TomcatSessionBackwardsCompatibilityTest {
 
   protected void startLocator(String name, String classPath, int port) throws Exception {
     CommandStringBuilder locStarter = new CommandStringBuilder(CliStrings.START_LOCATOR);
-    locStarter.addOption(CliStrings.START_LOCATOR__MEMBER_NAME, "loc");
+    locStarter.addOption(CliStrings.START_LOCATOR__MEMBER_NAME, name);
     locStarter.addOption(CliStrings.START_LOCATOR__CLASSPATH, classPath);
     locStarter.addOption(CliStrings.START_LOCATOR__PORT, Integer.toString(port));
     gfsh.executeAndVerifyCommand(locStarter.toString());