You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ec...@apache.org on 2012/06/20 20:41:17 UTC

svn commit: r1352260 - /hive/trunk/shims/src/common/java/org/apache/hadoop/hive/thrift/TUGIContainingTransport.java

Author: ecapriolo
Date: Wed Jun 20 18:41:16 2012
New Revision: 1352260

URL: http://svn.apache.org/viewvc?rev=1352260&view=rev
Log:
HIVE-3009 Memory leak in TUGIContainingTransport (Ashutosh Chauhan via egc)

Modified:
    hive/trunk/shims/src/common/java/org/apache/hadoop/hive/thrift/TUGIContainingTransport.java

Modified: hive/trunk/shims/src/common/java/org/apache/hadoop/hive/thrift/TUGIContainingTransport.java
URL: http://svn.apache.org/viewvc/hive/trunk/shims/src/common/java/org/apache/hadoop/hive/thrift/TUGIContainingTransport.java?rev=1352260&r1=1352259&r2=1352260&view=diff
==============================================================================
--- hive/trunk/shims/src/common/java/org/apache/hadoop/hive/thrift/TUGIContainingTransport.java (original)
+++ hive/trunk/shims/src/common/java/org/apache/hadoop/hive/thrift/TUGIContainingTransport.java Wed Jun 20 18:41:16 2012
@@ -36,7 +36,7 @@ public class TUGIContainingTransport ext
 
   private UserGroupInformation ugi;
 
-  public TUGIContainingTransport(TTransport wrapped, UserGroupInformation ugi) {
+  public TUGIContainingTransport(TTransport wrapped) {
     super(wrapped);
   }
 
@@ -65,9 +65,10 @@ public class TUGIContainingTransport ext
 
   public static class Factory extends TTransportFactory {
 
-    // Need a concurrent weak hashmap.
+    // Need a concurrent weakhashmap. WeakKeys() so that when underlying transport gets out of
+    // scope, it still can be GC'ed. Since value of map has a ref to key, need weekValues as well.
     private static final ConcurrentMap<TTransport, TUGIContainingTransport> transMap =
-        new MapMaker().weakKeys().makeMap();
+        new MapMaker().weakKeys().weakValues().makeMap();
 
     /**
      * Get a new <code>TUGIContainingTransport</code> instance, or reuse the
@@ -81,8 +82,8 @@ public class TUGIContainingTransport ext
 
       // UGI information is not available at connection setup time, it will be set later
       // via set_ugi() rpc.
-      transMap.putIfAbsent(trans, new TUGIContainingTransport(trans,null));
+      transMap.putIfAbsent(trans, new TUGIContainingTransport(trans));
       return transMap.get(trans);
     }
   }
-}
\ No newline at end of file
+}