HADOOP-10541. Merging change r1592803 from trunk to branch-2.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1592804 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Chris Nauroth 2014-05-06 16:56:24 +00:00
parent 7ac359f389
commit bfe689c00b
2 changed files with 28 additions and 12 deletions

View File

@ -113,6 +113,9 @@ Release 2.5.0 - UNRELEASED
HADOOP-10568. Add s3 server-side encryption. (David S. Wang via atm)
HADOOP-10541. InputStream in MiniKdc#initKDCServer for minikdc.ldiff is not
closed. (Swarnim Kulkarni via cnauroth)
Release 2.4.1 - UNRELEASED
INCOMPATIBLE CHANGES

View File

@ -393,18 +393,22 @@ public class MiniKdc {
map.put("4", bindAddress);
ClassLoader cl = Thread.currentThread().getContextClassLoader();
InputStream is = cl.getResourceAsStream("minikdc.ldiff");
InputStream is1 = cl.getResourceAsStream("minikdc.ldiff");
SchemaManager schemaManager = ds.getSchemaManager();
final String content = StrSubstitutor.replace(IOUtils.toString(is), map);
LdifReader reader = new LdifReader(new StringReader(content));
LdifReader reader = null;
try {
final String content = StrSubstitutor.replace(IOUtils.toString(is1), map);
reader = new LdifReader(new StringReader(content));
for (LdifEntry ldifEntry : reader) {
ds.getAdminSession().add(new DefaultEntry(schemaManager,
ldifEntry.getEntry()));
}
} finally {
reader.close();
IOUtils.closeQuietly(reader);
IOUtils.closeQuietly(is1);
}
kdc = new KdcServer();
@ -429,14 +433,23 @@ public class MiniKdc {
kdc.start();
StringBuilder sb = new StringBuilder();
is = cl.getResourceAsStream("minikdc-krb5.conf");
BufferedReader r = new BufferedReader(new InputStreamReader(is));
InputStream is2 = cl.getResourceAsStream("minikdc-krb5.conf");
BufferedReader r = null;
try {
r = new BufferedReader(new InputStreamReader(is2));
String line = r.readLine();
while (line != null) {
sb.append(line).append("{3}");
line = r.readLine();
}
r.close();
} finally {
IOUtils.closeQuietly(r);
IOUtils.closeQuietly(is2);
}
krb5conf = new File(workDir, "krb5.conf").getAbsoluteFile();
FileUtils.writeStringToFile(krb5conf,
MessageFormat.format(sb.toString(), getRealm(), getHost(),