You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by jl...@apache.org on 2017/03/10 17:08:47 UTC
hadoop git commit: YARN-6310. OutputStreams in
AggregatedLogFormat.LogWriter can be left open upon exceptions. Contributed
by Haibo Chen
Repository: hadoop
Updated Branches:
refs/heads/trunk e06ff18ab -> deb9f5694
YARN-6310. OutputStreams in AggregatedLogFormat.LogWriter can be left open upon exceptions. Contributed by Haibo Chen
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/deb9f569
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/deb9f569
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/deb9f569
Branch: refs/heads/trunk
Commit: deb9f569465bb760e661e60a313dad1605635236
Parents: e06ff18
Author: Jason Lowe <jl...@yahoo-inc.com>
Authored: Fri Mar 10 11:07:19 2017 -0600
Committer: Jason Lowe <jl...@yahoo-inc.com>
Committed: Fri Mar 10 11:08:33 2017 -0600
----------------------------------------------------------------------
.../logaggregation/AggregatedLogFormat.java | 52 ++++++++++----------
1 file changed, 26 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/deb9f569/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/AggregatedLogFormat.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/AggregatedLogFormat.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/AggregatedLogFormat.java
index 02f7782..1b46007 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/AggregatedLogFormat.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/AggregatedLogFormat.java
@@ -486,34 +486,34 @@ public class AggregatedLogFormat {
}
private void writeVersion() throws IOException {
- DataOutputStream out = this.writer.prepareAppendKey(-1);
- VERSION_KEY.write(out);
- out.close();
- out = this.writer.prepareAppendValue(-1);
- out.writeInt(VERSION);
- out.close();
+ try (DataOutputStream out = this.writer.prepareAppendKey(-1)) {
+ VERSION_KEY.write(out);
+ }
+ try (DataOutputStream out = this.writer.prepareAppendValue(-1)) {
+ out.writeInt(VERSION);
+ }
}
public void writeApplicationOwner(String user) throws IOException {
- DataOutputStream out = this.writer.prepareAppendKey(-1);
- APPLICATION_OWNER_KEY.write(out);
- out.close();
- out = this.writer.prepareAppendValue(-1);
- out.writeUTF(user);
- out.close();
+ try (DataOutputStream out = this.writer.prepareAppendKey(-1)) {
+ APPLICATION_OWNER_KEY.write(out);
+ }
+ try (DataOutputStream out = this.writer.prepareAppendValue(-1)) {
+ out.writeUTF(user);
+ }
}
public void writeApplicationACLs(Map<ApplicationAccessType, String> appAcls)
throws IOException {
- DataOutputStream out = this.writer.prepareAppendKey(-1);
- APPLICATION_ACL_KEY.write(out);
- out.close();
- out = this.writer.prepareAppendValue(-1);
- for (Entry<ApplicationAccessType, String> entry : appAcls.entrySet()) {
- out.writeUTF(entry.getKey().toString());
- out.writeUTF(entry.getValue());
+ try (DataOutputStream out = this.writer.prepareAppendKey(-1)) {
+ APPLICATION_ACL_KEY.write(out);
+ }
+ try (DataOutputStream out = this.writer.prepareAppendValue(-1)) {
+ for (Entry<ApplicationAccessType, String> entry : appAcls.entrySet()) {
+ out.writeUTF(entry.getKey().toString());
+ out.writeUTF(entry.getValue());
+ }
}
- out.close();
}
public void append(LogKey logKey, LogValue logValue) throws IOException {
@@ -522,12 +522,12 @@ public class AggregatedLogFormat {
if (pendingUploadFiles.size() == 0) {
return;
}
- DataOutputStream out = this.writer.prepareAppendKey(-1);
- logKey.write(out);
- out.close();
- out = this.writer.prepareAppendValue(-1);
- logValue.write(out, pendingUploadFiles);
- out.close();
+ try (DataOutputStream out = this.writer.prepareAppendKey(-1)) {
+ logKey.write(out);
+ }
+ try (DataOutputStream out = this.writer.prepareAppendValue(-1)) {
+ logValue.write(out, pendingUploadFiles);
+ }
}
public void close() {
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org