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

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1600994 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Zhijie Shen 2014-06-06 20:07:58 +00:00
parent 40ba8c17c1
commit 08b4aa699a
2 changed files with 8 additions and 2 deletions

View File

@ -198,6 +198,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);
}
}