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

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1430585 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Eli Collins 2013-01-08 22:38:36 +00:00
parent 7c91f59ee5
commit 6d4a091567
8 changed files with 13 additions and 23 deletions

View File

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

View File

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

View File

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

View File

@ -1904,10 +1904,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
* @return Namenode corresponding to the bpid
* @throws IOException
* @throws IOException if unable to get the corresponding NameNode
*/
public DatanodeProtocolClientSideTranslatorPB getActiveNamenodeForBP(String bpid)
throws IOException {
@ -1931,11 +1932,6 @@ public class DataNode extends Configured
final String bpid = block.getBlockPoolId();
DatanodeProtocolClientSideTranslatorPB nn =
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();
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);
}
File meta = getMetaFile();
if (meta == null) {
throw new IOException("Meta file not found for block " + this);
}
if (HardLink.getLinkCount(file) > numLinks) {
DataNode.LOG.info("CopyOnWrite for block " + this);

View File

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

View File

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

View File

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