From 6e4562b844dfbbbdc0074323900eb69ee2a3e9c2 Mon Sep 17 00:00:00 2001 From: Xiaoyu Yao Date: Tue, 10 Nov 2015 16:35:06 -0800 Subject: [PATCH] HDFS-9245. Fix findbugs warnings in hdfs-nfs/WriteCtx. Contributed by Mingliang Liu. --- .../apache/hadoop/hdfs/nfs/nfs3/WriteCtx.java | 22 +++++++++++++------ hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs-nfs/src/main/java/org/apache/hadoop/hdfs/nfs/nfs3/WriteCtx.java b/hadoop-hdfs-project/hadoop-hdfs-nfs/src/main/java/org/apache/hadoop/hdfs/nfs/nfs3/WriteCtx.java index 8c2c7ee7b6..f4c32f626a 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-nfs/src/main/java/org/apache/hadoop/hdfs/nfs/nfs3/WriteCtx.java +++ b/hadoop-hdfs-project/hadoop-hdfs-nfs/src/main/java/org/apache/hadoop/hdfs/nfs/nfs3/WriteCtx.java @@ -98,7 +98,7 @@ public static enum DataState { */ private int trimDelta; - public int getOriginalCount() { + public synchronized int getOriginalCount() { return originalCount; } @@ -158,7 +158,7 @@ long dumpData(FileOutputStream dumpOut, RandomAccessFile raf) } // Resized write should not allow dump - Preconditions.checkState(originalCount == INVALID_ORIGINAL_COUNT); + Preconditions.checkState(getOriginalCount() == INVALID_ORIGINAL_COUNT); this.raf = raf; dumpFileOffset = dumpOut.getChannel().position(); @@ -193,6 +193,13 @@ long getOffset() { } } + /** + * @return the offset field + */ + private synchronized long getPlainOffset() { + return offset; + } + int getCount() { synchronized(this) { // See comment "Overlapping Write Request Handling" above @@ -253,8 +260,8 @@ public void writeData(HdfsDataOutputStream fos) throws IOException { try { dataBuffer = getData(); } catch (Exception e1) { - LOG.error("Failed to get request data offset:" + offset + " count:" - + count + " error:" + e1); + LOG.error("Failed to get request data offset:" + getPlainOffset() + " " + + "count:" + count + " error:" + e1); throw new IOException("Can't get WriteCtx.data"); } @@ -311,8 +318,9 @@ void setReplied(boolean replied) { @Override public String toString() { - return "Id:" + handle.getFileId() + " offset:" + offset + " count:" + count - + " originalCount:" + originalCount + " stableHow:" + stableHow - + " replied:" + replied + " dataState:" + dataState + " xid:" + xid; + return "Id:" + handle.getFileId() + " offset:" + getPlainOffset() + " " + + "count:" + count + " originalCount:" + getOriginalCount() + + " stableHow:" + stableHow + " replied:" + replied + " dataState:" + + dataState + " xid:" + xid; } } \ No newline at end of file diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index e55bcd61f5..53d20cc0fc 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -2290,6 +2290,9 @@ Release 2.8.0 - UNRELEASED HDFS-9364. Unnecessary DNS resolution attempts when creating NameNodeProxies. (Xiao Chen via zhz) + HDFS-9245. Fix findbugs warnings in hdfs-nfs/WriteCtx. + (Mingliang Liu via xyao) + Release 2.7.3 - UNRELEASED INCOMPATIBLE CHANGES