geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bschucha...@apache.org
Subject incubator-geode git commit: GEODE-1927: more protection from seeing com.gemstone.gemfire packaged objects
Date Tue, 18 Oct 2016 22:50:25 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/develop 56836e59f -> e130e5b62


GEODE-1927: more protection from seeing com.gemstone.gemfire packaged objects

DeadlockDetector can read an archive of dependencies across the distributed
system.  This adds a small ObjectInputStream modification to its method that
reads these archives to let it handle those created before the package rename.


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

Branch: refs/heads/develop
Commit: e130e5b62bcb2d3c561be90f46407dc49f100b4a
Parents: 56836e5
Author: Bruce Schuchardt <bschuchardt@pivotal.io>
Authored: Tue Oct 18 15:47:20 2016 -0700
Committer: Bruce Schuchardt <bschuchardt@pivotal.io>
Committed: Tue Oct 18 15:49:59 2016 -0700

----------------------------------------------------------------------
 .../internal/deadlock/DeadlockDetector.java     | 33 ++++++++++++++++++--
 1 file changed, 30 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e130e5b6/geode-core/src/main/java/org/apache/geode/distributed/internal/deadlock/DeadlockDetector.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/deadlock/DeadlockDetector.java
b/geode-core/src/main/java/org/apache/geode/distributed/internal/deadlock/DeadlockDetector.java
index 2c70418..65a521a 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/deadlock/DeadlockDetector.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/deadlock/DeadlockDetector.java
@@ -19,7 +19,10 @@ package org.apache.geode.distributed.internal.deadlock;
 import java.io.BufferedInputStream;
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
 import java.io.ObjectInputStream;
+import java.io.ObjectStreamClass;
 import java.io.Serializable;
 import java.lang.management.LockInfo;
 import java.lang.management.ManagementFactory;
@@ -314,13 +317,37 @@ public class DeadlockDetector {
       System.exit(-1);
     }
 
-    ObjectInputStream ois = new ObjectInputStream(new BufferedInputStream(new FileInputStream(file)));
+    ObjectInputStream ois = new DDObjectInputStream(new BufferedInputStream(new FileInputStream(file)));
     DependencyGraph graph = (DependencyGraph) ois.readObject();
 
     return graph;
   }
-  
-  
+
+  private static class DDObjectInputStream extends ObjectInputStream {
+
+    /**
+     * Creates a new <code>DDObjectInputStream</code> that delegates
+     * its behavior to a given <code>InputStream</code>.
+     */
+    public DDObjectInputStream(InputStream stream) throws IOException {
+      super(stream);
+    }
+
+    @Override
+    protected Class resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException
{
+
+      String className = desc.getName();
+      if (className.startsWith("com.gemstone.gemfire")) {
+        className = "org.apache.geode" + className.substring("com.gemstone.gemfire".length());
+      } try {
+        Class clazz = Class.forName(className);
+        return clazz;
+      } catch (ClassNotFoundException ex) {
+        return super.resolveClass(desc);
+      }
+    }
+  }
+
   private static void printHelp() {
     System.out.println("DeadlockDetector reads serialized graphs of the state of the distributed");
     System.out.println("system created by collectDependencies.");


Mime
View raw message