diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/timeline/security/TimelineAuthenticationFilterInitializer.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/timeline/security/TimelineAuthenticationFilterInitializer.java index 53b27fb..cccdff5 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/timeline/security/TimelineAuthenticationFilterInitializer.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/timeline/security/TimelineAuthenticationFilterInitializer.java @@ -86,22 +86,31 @@ public void initFilter(FilterContainer container, Configuration conf) { 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()); } catch (IOException ex) { - throw new RuntimeException( - "Could not read HTTP signature secret file: " + throw new RuntimeException( + "Could not read HTTP signature secret file: " + + signatureSecretFile); + } finally { + if (reader != null) { + try { + reader.close(); + } catch (IOException e) { + throw new RuntimeException("Could not close FileReader: " + signatureSecretFile); + } + } } }