HADOOP-11368. Fix SSLFactory truststore reloader thread leak in KMSClientProvider. Contributed by Arun Suresh.

This commit is contained in:
Andrew Wang 2014-12-09 10:46:50 -08:00
parent d777a1e4ca
commit 74d4bfded9
3 changed files with 33 additions and 0 deletions

View File

@ -539,6 +539,9 @@ Release 2.7.0 - UNRELEASED
HADOOP-11369. Fix new findbugs warnings in hadoop-mapreduce-client, HADOOP-11369. Fix new findbugs warnings in hadoop-mapreduce-client,
non-core directories. (Li Lu via wheat9) non-core directories. (Li Lu via wheat9)
HADOOP-11368. Fix SSLFactory truststore reloader thread leak in
KMSClientProvider. (Arun Suresh via wang)
Release 2.6.0 - 2014-11-18 Release 2.6.0 - 2014-11-18
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -827,6 +827,10 @@ public void close() throws IOException {
encKeyVersionQueue.shutdown(); encKeyVersionQueue.shutdown();
} catch (Exception e) { } catch (Exception e) {
throw new IOException(e); throw new IOException(e);
} finally {
if (sslFactory != null) {
sslFactory.destroy();
}
} }
} }
} }

View File

@ -303,6 +303,32 @@ public Void call() throws Exception {
url.getProtocol().equals("https")); url.getProtocol().equals("https"));
final URI uri = createKMSUri(getKMSUrl()); final URI uri = createKMSUri(getKMSUrl());
if (ssl) {
KeyProvider testKp = new KMSClientProvider(uri, conf);
ThreadGroup threadGroup = Thread.currentThread().getThreadGroup();
while (threadGroup.getParent() != null) {
threadGroup = threadGroup.getParent();
}
Thread[] threads = new Thread[threadGroup.activeCount()];
threadGroup.enumerate(threads);
Thread reloaderThread = null;
for (Thread thread : threads) {
if ((thread.getName() != null)
&& (thread.getName().contains("Truststore reloader thread"))) {
reloaderThread = thread;
}
}
Assert.assertTrue("Reloader is not alive", reloaderThread.isAlive());
testKp.close();
boolean reloaderStillAlive = true;
for (int i = 0; i < 10; i++) {
reloaderStillAlive = reloaderThread.isAlive();
if (!reloaderStillAlive) break;
Thread.sleep(1000);
}
Assert.assertFalse("Reloader is still alive", reloaderStillAlive);
}
if (kerberos) { if (kerberos) {
for (String user : new String[]{"client", "client/host"}) { for (String user : new String[]{"client", "client/host"}) {
doAs(user, new PrivilegedExceptionAction<Void>() { doAs(user, new PrivilegedExceptionAction<Void>() {