directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From plusplusjia...@apache.org
Subject [03/50] [abbrv] directory-kerby git commit: DIRKRB-536 KrbClient leaks sockets. Contributed by Alexander Haskell.
Date Tue, 29 Mar 2016 08:14:29 GMT
DIRKRB-536 KrbClient leaks sockets. Contributed by Alexander Haskell.


Project: http://git-wip-us.apache.org/repos/asf/directory-kerby/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-kerby/commit/bbddb6f8
Tree: http://git-wip-us.apache.org/repos/asf/directory-kerby/tree/bbddb6f8
Diff: http://git-wip-us.apache.org/repos/asf/directory-kerby/diff/bbddb6f8

Branch: refs/heads/kadmin-remote
Commit: bbddb6f87a877dee7ff77be1e982f6616e1aec4d
Parents: a020b11
Author: plusplusjiajia <jiajia.li@intel.com>
Authored: Thu Feb 25 14:36:50 2016 +0800
Committer: plusplusjiajia <jiajia.li@intel.com>
Committed: Thu Feb 25 14:36:50 2016 +0800

----------------------------------------------------------------------
 .../client/impl/DefaultInternalKrbClient.java   | 24 ++++++++++++--------
 1 file changed, 15 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/bbddb6f8/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/impl/DefaultInternalKrbClient.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/impl/DefaultInternalKrbClient.java
b/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/impl/DefaultInternalKrbClient.java
index e2c18d3..df4ed10 100644
--- a/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/impl/DefaultInternalKrbClient.java
+++ b/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/impl/DefaultInternalKrbClient.java
@@ -23,6 +23,7 @@ import org.apache.kerby.kerberos.kerb.KrbException;
 import org.apache.kerby.kerberos.kerb.client.ClientUtil;
 import org.apache.kerby.kerberos.kerb.client.KrbSetting;
 import org.apache.kerby.kerberos.kerb.client.request.AsRequest;
+import org.apache.kerby.kerberos.kerb.client.request.KdcRequest;
 import org.apache.kerby.kerberos.kerb.client.request.TgsRequest;
 import org.apache.kerby.kerberos.kerb.transport.KrbNetwork;
 import org.apache.kerby.kerberos.kerb.transport.KrbTransport;
@@ -53,14 +54,23 @@ public class DefaultInternalKrbClient extends AbstractInternalKrbClient
{
 
         this.krbHandler = new DefaultKrbHandler();
         krbHandler.init(getContext());
+    }
 
-        TransportPair tpair = ClientUtil.getTransportPair(getSetting());
-        KrbNetwork network = new KrbNetwork();
-        network.setSocketTimeout(getSetting().getTimeout());
+    private void doRequest(KdcRequest request) throws KrbException {
         try {
+            TransportPair tpair = ClientUtil.getTransportPair(getSetting());
+            KrbNetwork network = new KrbNetwork();
+
+            network.setSocketTimeout(getSetting().getTimeout());
+
             transport = network.connect(tpair);
+
+            request.setSessionData(transport);
+            krbHandler.handleRequest(request);
         } catch (IOException e) {
             throw new KrbException("Failed to create transport", e);
+        } finally {
+            transport.release();
         }
     }
 
@@ -69,9 +79,7 @@ public class DefaultInternalKrbClient extends AbstractInternalKrbClient
{
      */
     @Override
     protected TgtTicket doRequestTgt(AsRequest tgtTktReq) throws KrbException {
-        tgtTktReq.setSessionData(transport);
-
-        krbHandler.handleRequest(tgtTktReq);
+        doRequest(tgtTktReq);
 
         return tgtTktReq.getTicket();
     }
@@ -81,9 +89,7 @@ public class DefaultInternalKrbClient extends AbstractInternalKrbClient
{
      */
     @Override
     protected SgtTicket doRequestSgt(TgsRequest ticketReq) throws KrbException {
-        ticketReq.setSessionData(transport);
-
-        krbHandler.handleRequest(ticketReq);
+        doRequest(ticketReq);
 
         return ticketReq.getSgt();
     }


Mime
View raw message