Skip to content

Commit

Permalink
HADOOP-16881. KerberosAuthentication does not disconnect HttpURLConne…
Browse files Browse the repository at this point in the history
…ction leading to CLOSE_WAIT cnxns. Contributed by Attila Magyar.

Signed-off-by: Wei-Chiu Chuang <weichiu@apache.org>
  • Loading branch information
Attila Magyar authored and jojochuang committed Dec 3, 2020
1 parent f94e927 commit db73e99
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,9 @@ public void authenticate(URL url, AuthenticatedURL.Token token)
if (!token.isSet()) {
this.url = url;
base64 = new Base64(0);
HttpURLConnection conn = null;
try {
HttpURLConnection conn = token.openConnection(url, connConfigurator);
conn = token.openConnection(url, connConfigurator);
conn.setRequestMethod(AUTH_HTTP_METHOD);
conn.connect();

Expand Down Expand Up @@ -218,6 +219,10 @@ public void authenticate(URL url, AuthenticatedURL.Token token)
} catch (AuthenticationException ex){
throw wrapExceptionWithMessage(ex,
"Error while authenticating with endpoint: " + url);
} finally {
if (conn != null) {
conn.disconnect();
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,9 @@ private Map doDelegationTokenOperation(URL url,
dt = ((DelegationTokenAuthenticatedURL.Token) token).getDelegationToken();
((DelegationTokenAuthenticatedURL.Token) token).setDelegationToken(null);
}
HttpURLConnection conn = null;
try {
HttpURLConnection conn = aUrl.openConnection(url, token);
conn = aUrl.openConnection(url, token);
conn.setRequestMethod(operation.getHttpMethod());
HttpExceptionUtils.validateResponse(conn, HttpURLConnection.HTTP_OK);
if (hasResponse) {
Expand All @@ -339,6 +340,9 @@ private Map doDelegationTokenOperation(URL url,
if (dt != null) {
((DelegationTokenAuthenticatedURL.Token) token).setDelegationToken(dt);
}
if (conn != null) {
conn.disconnect();
}
}
return ret;
}
Expand Down

0 comments on commit db73e99

Please sign in to comment.