HDFS-4034. Remove redundant null checks. Contributed by Eli Collins

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1430588 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Eli Collins 2013-01-08 22:39:40 +00:00
parent 030fc9a0c3
commit de8ec340ca
8 changed files with 13 additions and 23 deletions

View File

@ -169,6 +169,8 @@ Release 2.0.3-alpha - Unreleased
HDFS-4033. Miscellaneous findbugs 2 fixes. (eli) HDFS-4033. Miscellaneous findbugs 2 fixes. (eli)
HDFS-4034. Remove redundant null checks. (eli)
OPTIMIZATIONS OPTIMIZATIONS
BUG FIXES BUG FIXES

View File

@ -1618,8 +1618,7 @@ public class DFSClient implements java.io.Closeable {
if (shouldEncryptData()) { if (shouldEncryptData()) {
synchronized (this) { synchronized (this) {
if (encryptionKey == null || if (encryptionKey == null ||
(encryptionKey != null && encryptionKey.expiryDate < Time.now()) {
encryptionKey.expiryDate < Time.now())) {
LOG.debug("Getting new encryption token from NN"); LOG.debug("Getting new encryption token from NN");
encryptionKey = namenode.getDataEncryptionKey(); encryptionKey = namenode.getDataEncryptionKey();
} }

View File

@ -53,11 +53,7 @@ public abstract class DataTransferProtoUtil {
public static ChecksumProto toProto(DataChecksum checksum) { public static ChecksumProto toProto(DataChecksum checksum) {
ChecksumTypeProto type = HdfsProtoUtil.toProto(checksum.getChecksumType()); ChecksumTypeProto type = HdfsProtoUtil.toProto(checksum.getChecksumType());
if (type == null) { // ChecksumType#valueOf never returns null
throw new IllegalArgumentException(
"Can't convert checksum to protobuf: " + checksum);
}
return ChecksumProto.newBuilder() return ChecksumProto.newBuilder()
.setBytesPerChecksum(checksum.getBytesPerChecksum()) .setBytesPerChecksum(checksum.getBytesPerChecksum())
.setType(type) .setType(type)

View File

@ -1908,10 +1908,11 @@ public class DataNode extends Configured
} }
/** /**
* Get namenode corresponding to a block pool * Get the NameNode corresponding to the given block pool.
*
* @param bpid Block pool Id * @param bpid Block pool Id
* @return Namenode corresponding to the bpid * @return Namenode corresponding to the bpid
* @throws IOException * @throws IOException if unable to get the corresponding NameNode
*/ */
public DatanodeProtocolClientSideTranslatorPB getActiveNamenodeForBP(String bpid) public DatanodeProtocolClientSideTranslatorPB getActiveNamenodeForBP(String bpid)
throws IOException { throws IOException {
@ -1935,11 +1936,6 @@ public class DataNode extends Configured
final String bpid = block.getBlockPoolId(); final String bpid = block.getBlockPoolId();
DatanodeProtocolClientSideTranslatorPB nn = DatanodeProtocolClientSideTranslatorPB nn =
getActiveNamenodeForBP(block.getBlockPoolId()); getActiveNamenodeForBP(block.getBlockPoolId());
if (nn == null) {
throw new IOException(
"Unable to synchronize block " + rBlock + ", since this DN "
+ " has not acknowledged any NN as active.");
}
long recoveryId = rBlock.getNewGenerationStamp(); long recoveryId = rBlock.getNewGenerationStamp();
if (LOG.isDebugEnabled()) { if (LOG.isDebugEnabled()) {

View File

@ -203,9 +203,6 @@ abstract public class ReplicaInfo extends Block implements Replica {
throw new IOException("detachBlock:Block not found. " + this); throw new IOException("detachBlock:Block not found. " + this);
} }
File meta = getMetaFile(); File meta = getMetaFile();
if (meta == null) {
throw new IOException("Meta file not found for block " + this);
}
if (HardLink.getLinkCount(file) > numLinks) { if (HardLink.getLinkCount(file) > numLinks) {
DataNode.LOG.info("CopyOnWrite for block " + this); DataNode.LOG.info("CopyOnWrite for block " + this);

View File

@ -140,10 +140,8 @@ public class EditLogFileOutputStream extends EditLogOutputStream {
fc.close(); fc.close();
fc = null; fc = null;
} }
if (fp != null) { fp.close();
fp.close(); fp = null;
fp = null;
}
} finally { } finally {
IOUtils.cleanup(FSNamesystem.LOG, fc, fp); IOUtils.cleanup(FSNamesystem.LOG, fc, fp);
doubleBuf = null; doubleBuf = null;

View File

@ -164,7 +164,7 @@ public class NameNodeResourceChecker {
CheckedVolume newVolume = new CheckedVolume(dir, required); CheckedVolume newVolume = new CheckedVolume(dir, required);
CheckedVolume volume = volumes.get(newVolume.getVolume()); CheckedVolume volume = volumes.get(newVolume.getVolume());
if (volume == null || (volume != null && !volume.isRequired())) { if (volume == null || !volume.isRequired()) {
volumes.put(newVolume.getVolume(), newVolume); volumes.put(newVolume.getVolume(), newVolume);
} }
} }

View File

@ -605,7 +605,9 @@ public class SecondaryNameNode implements Runnable {
terminate(ret); terminate(ret);
} }
secondary.startCheckpointThread(); if (secondary != null) {
secondary.startCheckpointThread();
}
} }