diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/AesCtrCryptoCodec.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/AesCtrCryptoCodec.java index b469fddaf2a..8f8bc661db7 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/AesCtrCryptoCodec.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/AesCtrCryptoCodec.java @@ -50,14 +50,10 @@ public abstract class AesCtrCryptoCodec extends CryptoCodec { Preconditions.checkArgument(IV.length == AES_BLOCK_SIZE); System.arraycopy(initIV, 0, IV, 0, CTR_OFFSET); - long l = (initIV[CTR_OFFSET + 0] << 56) - + ((initIV[CTR_OFFSET + 1] & 0xFF) << 48) - + ((initIV[CTR_OFFSET + 2] & 0xFF) << 40) - + ((initIV[CTR_OFFSET + 3] & 0xFF) << 32) - + ((initIV[CTR_OFFSET + 4] & 0xFF) << 24) - + ((initIV[CTR_OFFSET + 5] & 0xFF) << 16) - + ((initIV[CTR_OFFSET + 6] & 0xFF) << 8) - + (initIV[CTR_OFFSET + 7] & 0xFF); + long l = 0; + for (int i = 0; i < 8; i++) { + l = ((l << 8) | (initIV[CTR_OFFSET + i] & 0xff)); + } l += counter; IV[CTR_OFFSET + 0] = (byte) (l >>> 56); IV[CTR_OFFSET + 1] = (byte) (l >>> 48); diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/random/OsSecureRandom.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/random/OsSecureRandom.java index 3fa61fbbdce..c6cb0a80e74 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/random/OsSecureRandom.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/random/OsSecureRandom.java @@ -37,14 +37,15 @@ import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.HADOOP_SECURITY */ @InterfaceAudience.Private public class OsSecureRandom extends Random implements Closeable, Configurable { + private static final long serialVersionUID = 6391500337172057900L; - private Configuration conf; + private transient Configuration conf; private final int RESERVOIR_LENGTH = 8192; private String randomDevPath; - private FileInputStream stream; + private transient FileInputStream stream; private final byte[] reservoir = new byte[RESERVOIR_LENGTH]; @@ -65,7 +66,7 @@ public class OsSecureRandom extends Random implements Closeable, Configurable { } @Override - public void setConf(Configuration conf) { + synchronized public void setConf(Configuration conf) { this.conf = conf; this.randomDevPath = conf.get( HADOOP_SECURITY_SECURE_RANDOM_DEVICE_FILE_PATH_KEY, @@ -80,7 +81,7 @@ public class OsSecureRandom extends Random implements Closeable, Configurable { } @Override - public Configuration getConf() { + synchronized public Configuration getConf() { return conf; } @@ -100,16 +101,15 @@ public class OsSecureRandom extends Random implements Closeable, Configurable { @Override synchronized protected int next(int nbits) { fillReservoir(4); - int n = reservoir[pos] | - (reservoir[pos + 1] << 8) | - (reservoir[pos + 2] << 16) | - (reservoir[pos + 3] << 24); - pos += 4; + int n = 0; + for (int i = 0; i < 4; i++) { + n = ((n << 8) | (reservoir[pos++] & 0xff)); + } return n & (0xffffffff >> (32 - nbits)); } @Override - public void close() throws IOException { + synchronized public void close() throws IOException { stream.close(); } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES-fs-encryption.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES-fs-encryption.txt index 4673fac180f..99613e996af 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES-fs-encryption.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES-fs-encryption.txt @@ -90,3 +90,5 @@ fs-encryption (Unreleased) HDFS-6814. Mistakenly dfs.namenode.list.encryption.zones.num.responses configured as boolean. (umamahesh) + + HDFS-6817. Fix findbugs and other warnings. (yliu) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/EncryptionZoneManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/EncryptionZoneManager.java index 143cc66c3ea..31cb53c40ce 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/EncryptionZoneManager.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/EncryptionZoneManager.java @@ -41,7 +41,7 @@ public class EncryptionZoneManager { * external representation of an EZ is embodied in an EncryptionZone and * contains the EZ's pathname. */ - private class EncryptionZoneInt { + private static class EncryptionZoneInt { private final String keyName; private final long inodeId;