diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/unix/DomainSocket.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/unix/DomainSocket.java index 9c37db3d4fb..034ac3b62da 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/unix/DomainSocket.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/unix/DomainSocket.java @@ -254,7 +254,7 @@ public class DomainSocket implements Closeable { private void fdUnref(boolean checkClosed) throws AsynchronousCloseException { int newCount = status.decrementAndGet(); assert (newCount & ~STATUS_CLOSED_MASK) >= 0; - if (checkClosed & ((newCount & STATUS_CLOSED_MASK) != 0)) { + if (checkClosed && ((newCount & STATUS_CLOSED_MASK) != 0)) { throw new AsynchronousCloseException(); } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-347.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-347.txt index 96afb6a9847..afc04b4ff4c 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-347.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-347.txt @@ -22,3 +22,6 @@ HDFS-4400. DFSInputStream#getBlockReader: last retries should ignore the cache HDFS-4401. Fix bug in DomainSocket path validation (Colin Patrick McCabe via todd) + +HDFS-4402. Some small DomainSocket fixes: avoid findbugs warning, change log level, etc. +(Colin Patrick McCabe via todd) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/BlockReaderLocal.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/BlockReaderLocal.java index 1c34a71c26d..ca9ce080f64 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/BlockReaderLocal.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/BlockReaderLocal.java @@ -19,6 +19,8 @@ package org.apache.hadoop.hdfs; import java.io.DataInputStream; import org.apache.hadoop.conf.Configuration; + +import java.io.BufferedInputStream; import java.io.FileInputStream; import java.io.IOException; import java.nio.ByteBuffer; @@ -118,7 +120,9 @@ class BlockReaderLocal implements BlockReader { // read and handle the common header here. For now just a version checksumIn.getChannel().position(0); BlockMetadataHeader header = BlockMetadataHeader - .readHeader(new DataInputStream(checksumIn)); + .readHeader(new DataInputStream( + new BufferedInputStream(checksumIn, + BlockMetadataHeader.getHeaderSize()))); short version = header.getVersion(); if (version != BlockMetadataHeader.VERSION) { throw new IOException("Wrong version (" + version + ") of the " + diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DomainSocketFactory.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DomainSocketFactory.java index 50b60521070..db9afc1c40c 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DomainSocketFactory.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DomainSocketFactory.java @@ -62,7 +62,7 @@ class DomainSocketFactory { LOG.warn(feature + " is disabled because you have not set " + DFSConfigKeys.DFS_DATANODE_DOMAIN_SOCKET_PATH_KEY); } else if (DomainSocket.getLoadingFailureReason() != null) { - LOG.error(feature + " is disabled because " + + LOG.warn(feature + " is disabled because " + DomainSocket.getLoadingFailureReason()); } else { LOG.debug(feature + "is enabled."); @@ -113,7 +113,7 @@ class DomainSocketFactory { sock.setAttribute(DomainSocket.RCV_TIMEO, conf.socketTimeout); success = true; } catch (IOException e) { - LOG.error("error creating DomainSocket", e); + LOG.warn("error creating DomainSocket", e); // fall through } finally { if (!success) { @@ -134,4 +134,4 @@ class DomainSocketFactory { public void disableDomainSocketPath(String path) { pathInfo.put(path, PathStatus.UNUSABLE); } -} \ No newline at end of file +} diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/FileInputStreamCache.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/FileInputStreamCache.java index d9045f0cf2c..ac0af814362 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/FileInputStreamCache.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/FileInputStreamCache.java @@ -22,7 +22,6 @@ import java.util.Iterator; import java.util.List; import java.util.Map.Entry; import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.ThreadFactory; import java.util.concurrent.TimeUnit; import org.apache.commons.logging.Log;