YARN-2117. Fixed the issue that secret file reader is potentially not closed in TimelineAuthenticationFilterInitializer. Contributed by Chen He.

svn merge --ignore-ancestry -c 1600994 ../../trunk/


git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1600995 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Zhijie Shen 2014-06-06 20:10:14 +00:00
parent 3ed429bb62
commit 683d4bdbd9
2 changed files with 8 additions and 2 deletions

View File

@ -183,6 +183,9 @@ Release 2.5.0 - UNRELEASED
YARN-2118. Fixed the type mismatch in Map#containsKey check of
TimelineWebServices#injectOwnerInfo. (Ted Yu via zjshen)
YARN-2117. Fixed the issue that secret file reader is potentially not
closed in TimelineAuthenticationFilterInitializer. (Chen He via zjshen)
Release 2.4.1 - UNRELEASED
INCOMPATIBLE CHANGES

View File

@ -28,6 +28,7 @@ import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.http.FilterContainer;
import org.apache.hadoop.http.FilterInitializer;
import org.apache.hadoop.http.HttpServer2;
import org.apache.hadoop.io.IOUtils;
import org.apache.hadoop.security.SecurityUtil;
/**
@ -86,15 +87,15 @@ public class TimelineAuthenticationFilterInitializer extends FilterInitializer {
String signatureSecretFile = filterConfig.get(SIGNATURE_SECRET_FILE);
if (signatureSecretFile != null) {
Reader reader = null;
try {
StringBuilder secret = new StringBuilder();
Reader reader = new FileReader(signatureSecretFile);
reader = new FileReader(signatureSecretFile);
int c = reader.read();
while (c > -1) {
secret.append((char) c);
c = reader.read();
}
reader.close();
filterConfig
.put(TimelineAuthenticationFilter.SIGNATURE_SECRET,
secret.toString());
@ -102,6 +103,8 @@ public class TimelineAuthenticationFilterInitializer extends FilterInitializer {
throw new RuntimeException(
"Could not read HTTP signature secret file: "
+ signatureSecretFile);
} finally {
IOUtils.closeStream(reader);
}
}