Skip to content

Commit

Permalink
HIVE-3008: Memory leak in TUGIContainingTransport. Backported from tr…
Browse files Browse the repository at this point in the history
…unk.

git-svn-id: https://svn.apache.org/repos/asf/hive/branches/branch-0.9@1354165 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
ashutoshc committed Jun 26, 2012
1 parent 5984d26 commit a4959ed
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class TUGIContainingTransport extends TFilterTransport {

private UserGroupInformation ugi;

public TUGIContainingTransport(TTransport wrapped, UserGroupInformation ugi) {
public TUGIContainingTransport(TTransport wrapped) {
super(wrapped);
}

Expand Down Expand Up @@ -65,9 +65,10 @@ public Socket getSocket() {

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
Expand All @@ -81,8 +82,8 @@ public TUGIContainingTransport getTransport(TTransport trans) {

// 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);
}
}
}
}

0 comments on commit a4959ed

Please sign in to comment.