HADOOP-10541. InputStream in MiniKdc#initKDCServer for minikdc.ldiff is not closed. Contributed by Swarnim Kulkarni.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1592803 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7fe28fc8f9
commit
0ba580e9e3
|
@ -443,6 +443,9 @@ Release 2.5.0 - UNRELEASED
|
||||||
|
|
||||||
HADOOP-10568. Add s3 server-side encryption. (David S. Wang via atm)
|
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
|
Release 2.4.1 - UNRELEASED
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -393,18 +393,22 @@ public class MiniKdc {
|
||||||
map.put("4", bindAddress);
|
map.put("4", bindAddress);
|
||||||
|
|
||||||
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
||||||
InputStream is = cl.getResourceAsStream("minikdc.ldiff");
|
InputStream is1 = cl.getResourceAsStream("minikdc.ldiff");
|
||||||
|
|
||||||
SchemaManager schemaManager = ds.getSchemaManager();
|
SchemaManager schemaManager = ds.getSchemaManager();
|
||||||
final String content = StrSubstitutor.replace(IOUtils.toString(is), map);
|
LdifReader reader = null;
|
||||||
LdifReader reader = new LdifReader(new StringReader(content));
|
|
||||||
try {
|
try {
|
||||||
|
final String content = StrSubstitutor.replace(IOUtils.toString(is1), map);
|
||||||
|
reader = new LdifReader(new StringReader(content));
|
||||||
|
|
||||||
for (LdifEntry ldifEntry : reader) {
|
for (LdifEntry ldifEntry : reader) {
|
||||||
ds.getAdminSession().add(new DefaultEntry(schemaManager,
|
ds.getAdminSession().add(new DefaultEntry(schemaManager,
|
||||||
ldifEntry.getEntry()));
|
ldifEntry.getEntry()));
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
reader.close();
|
IOUtils.closeQuietly(reader);
|
||||||
|
IOUtils.closeQuietly(is1);
|
||||||
}
|
}
|
||||||
|
|
||||||
kdc = new KdcServer();
|
kdc = new KdcServer();
|
||||||
|
@ -429,14 +433,23 @@ public class MiniKdc {
|
||||||
kdc.start();
|
kdc.start();
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
is = cl.getResourceAsStream("minikdc-krb5.conf");
|
InputStream is2 = cl.getResourceAsStream("minikdc-krb5.conf");
|
||||||
BufferedReader r = new BufferedReader(new InputStreamReader(is));
|
|
||||||
String line = r.readLine();
|
BufferedReader r = null;
|
||||||
while (line != null) {
|
|
||||||
sb.append(line).append("{3}");
|
try {
|
||||||
line = r.readLine();
|
r = new BufferedReader(new InputStreamReader(is2));
|
||||||
|
String line = r.readLine();
|
||||||
|
|
||||||
|
while (line != null) {
|
||||||
|
sb.append(line).append("{3}");
|
||||||
|
line = r.readLine();
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
IOUtils.closeQuietly(r);
|
||||||
|
IOUtils.closeQuietly(is2);
|
||||||
}
|
}
|
||||||
r.close();
|
|
||||||
krb5conf = new File(workDir, "krb5.conf").getAbsoluteFile();
|
krb5conf = new File(workDir, "krb5.conf").getAbsoluteFile();
|
||||||
FileUtils.writeStringToFile(krb5conf,
|
FileUtils.writeStringToFile(krb5conf,
|
||||||
MessageFormat.format(sb.toString(), getRealm(), getHost(),
|
MessageFormat.format(sb.toString(), getRealm(), getHost(),
|
||||||
|
@ -555,4 +568,4 @@ public class MiniKdc {
|
||||||
keytab.setEntries(entries);
|
keytab.setEntries(entries);
|
||||||
keytab.write(keytabFile);
|
keytab.write(keytabFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue