HDFS-7516. Fix findbugs warnings in hdfs-nfs project. Contributed by Brandon Li
This commit is contained in:
parent
a4f2995b9e
commit
42d8858c5d
@ -19,6 +19,7 @@
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.io.Charsets;
|
||||
import org.apache.hadoop.nfs.NfsExports;
|
||||
import org.apache.hadoop.oncrpc.RpcAcceptedReply;
|
||||
import org.apache.hadoop.oncrpc.XDR;
|
||||
@ -76,7 +77,7 @@ public static XDR writeExportList(XDR xdr, int xid, List<String> exports,
|
||||
if (hostGroups.length > 0) {
|
||||
for (int j = 0; j < hostGroups.length; j++) {
|
||||
xdr.writeBoolean(true); // Value follows - yes
|
||||
xdr.writeVariableOpaque(hostGroups[j].getBytes());
|
||||
xdr.writeVariableOpaque(hostGroups[j].getBytes(Charsets.UTF_8));
|
||||
}
|
||||
}
|
||||
xdr.writeBoolean(false); // Value follows - no more group
|
||||
|
@ -22,6 +22,7 @@
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.apache.commons.io.Charsets;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.hadoop.oncrpc.XDR;
|
||||
@ -72,10 +73,8 @@ public FileHandle(String s) {
|
||||
return;
|
||||
}
|
||||
|
||||
byte[] in = s.getBytes();
|
||||
for (int i = 0; i < in.length; i++) {
|
||||
digest.update(in[i]);
|
||||
}
|
||||
byte[] in = s.getBytes(Charsets.UTF_8);
|
||||
digest.update(in);
|
||||
|
||||
byte[] digestbytes = digest.digest();
|
||||
for (int i = 0; i < 16; i++) {
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.commons.io.Charsets;
|
||||
import org.apache.hadoop.nfs.nfs3.FileHandle;
|
||||
import org.apache.hadoop.nfs.nfs3.Nfs3Constant;
|
||||
import org.apache.hadoop.oncrpc.XDR;
|
||||
@ -78,7 +79,7 @@ public long getVerf() {
|
||||
public void serialize(XDR xdr) {
|
||||
handle.serialize(xdr);
|
||||
xdr.writeInt(name.length());
|
||||
xdr.writeFixedOpaque(name.getBytes(), name.length());
|
||||
xdr.writeFixedOpaque(name.getBytes(Charsets.UTF_8), name.length());
|
||||
xdr.writeInt(mode);
|
||||
objAttr.serialize(xdr);
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.commons.io.Charsets;
|
||||
import org.apache.hadoop.nfs.nfs3.FileHandle;
|
||||
import org.apache.hadoop.oncrpc.XDR;
|
||||
|
||||
@ -56,6 +57,6 @@ public void serialize(XDR xdr) {
|
||||
handle.serialize(xdr);
|
||||
fromDirHandle.serialize(xdr);
|
||||
xdr.writeInt(fromName.length());
|
||||
xdr.writeFixedOpaque(fromName.getBytes(), fromName.length());
|
||||
xdr.writeFixedOpaque(fromName.getBytes(Charsets.UTF_8), fromName.length());
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.commons.io.Charsets;
|
||||
import org.apache.hadoop.nfs.nfs3.FileHandle;
|
||||
import org.apache.hadoop.oncrpc.XDR;
|
||||
|
||||
@ -53,7 +54,7 @@ public void setName(String name) {
|
||||
@VisibleForTesting
|
||||
public void serialize(XDR xdr) {
|
||||
handle.serialize(xdr);
|
||||
xdr.writeInt(name.getBytes().length);
|
||||
xdr.writeFixedOpaque(name.getBytes());
|
||||
xdr.writeInt(name.getBytes(Charsets.UTF_8).length);
|
||||
xdr.writeFixedOpaque(name.getBytes(Charsets.UTF_8));
|
||||
}
|
||||
}
|
@ -19,6 +19,7 @@
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.commons.io.Charsets;
|
||||
import org.apache.hadoop.nfs.nfs3.FileHandle;
|
||||
import org.apache.hadoop.oncrpc.XDR;
|
||||
|
||||
@ -54,8 +55,8 @@ public SetAttr3 getObjAttr() {
|
||||
@Override
|
||||
public void serialize(XDR xdr) {
|
||||
handle.serialize(xdr);
|
||||
xdr.writeInt(name.getBytes().length);
|
||||
xdr.writeFixedOpaque(name.getBytes());
|
||||
xdr.writeInt(name.getBytes(Charsets.UTF_8).length);
|
||||
xdr.writeFixedOpaque(name.getBytes(Charsets.UTF_8));
|
||||
objAttr.serialize(xdr);
|
||||
}
|
||||
}
|
@ -19,6 +19,7 @@
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.commons.io.Charsets;
|
||||
import org.apache.hadoop.nfs.NfsFileType;
|
||||
import org.apache.hadoop.nfs.nfs3.FileHandle;
|
||||
import org.apache.hadoop.nfs.nfs3.Nfs3FileAttributes.Specdata3;
|
||||
@ -79,7 +80,7 @@ public Specdata3 getSpec() {
|
||||
public void serialize(XDR xdr) {
|
||||
handle.serialize(xdr);
|
||||
xdr.writeInt(name.length());
|
||||
xdr.writeFixedOpaque(name.getBytes(), name.length());
|
||||
xdr.writeFixedOpaque(name.getBytes(Charsets.UTF_8), name.length());
|
||||
objAttr.serialize(xdr);
|
||||
if (spec != null) {
|
||||
xdr.writeInt(spec.getSpecdata1());
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.commons.io.Charsets;
|
||||
import org.apache.hadoop.nfs.nfs3.FileHandle;
|
||||
import org.apache.hadoop.oncrpc.XDR;
|
||||
|
||||
@ -46,7 +47,7 @@ public String getName() {
|
||||
@Override
|
||||
public void serialize(XDR xdr) {
|
||||
handle.serialize(xdr);
|
||||
xdr.writeInt(name.getBytes().length);
|
||||
xdr.writeFixedOpaque(name.getBytes());
|
||||
xdr.writeInt(name.getBytes(Charsets.UTF_8).length);
|
||||
xdr.writeFixedOpaque(name.getBytes(Charsets.UTF_8));
|
||||
}
|
||||
}
|
@ -19,6 +19,7 @@
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.commons.io.Charsets;
|
||||
import org.apache.hadoop.nfs.nfs3.FileHandle;
|
||||
import org.apache.hadoop.oncrpc.XDR;
|
||||
|
||||
@ -66,10 +67,10 @@ public String getToName() {
|
||||
@Override
|
||||
public void serialize(XDR xdr) {
|
||||
fromDirHandle.serialize(xdr);
|
||||
xdr.writeInt(fromName.getBytes().length);
|
||||
xdr.writeFixedOpaque(fromName.getBytes());
|
||||
xdr.writeInt(fromName.getBytes(Charsets.UTF_8).length);
|
||||
xdr.writeFixedOpaque(fromName.getBytes(Charsets.UTF_8));
|
||||
toDirHandle.serialize(xdr);
|
||||
xdr.writeInt(toName.getBytes().length);
|
||||
xdr.writeFixedOpaque(toName.getBytes());
|
||||
xdr.writeInt(toName.getBytes(Charsets.UTF_8).length);
|
||||
xdr.writeFixedOpaque(toName.getBytes(Charsets.UTF_8));
|
||||
}
|
||||
}
|
@ -19,6 +19,7 @@
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.commons.io.Charsets;
|
||||
import org.apache.hadoop.nfs.nfs3.FileHandle;
|
||||
import org.apache.hadoop.oncrpc.XDR;
|
||||
|
||||
@ -46,7 +47,7 @@ public String getName() {
|
||||
@Override
|
||||
public void serialize(XDR xdr) {
|
||||
handle.serialize(xdr);
|
||||
xdr.writeInt(name.getBytes().length);
|
||||
xdr.writeFixedOpaque(name.getBytes());
|
||||
xdr.writeInt(name.getBytes(Charsets.UTF_8).length);
|
||||
xdr.writeFixedOpaque(name.getBytes(Charsets.UTF_8));
|
||||
}
|
||||
}
|
@ -19,6 +19,7 @@
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.commons.io.Charsets;
|
||||
import org.apache.hadoop.nfs.nfs3.FileHandle;
|
||||
import org.apache.hadoop.oncrpc.XDR;
|
||||
|
||||
@ -62,10 +63,10 @@ public String getSymData() {
|
||||
@Override
|
||||
public void serialize(XDR xdr) {
|
||||
handle.serialize(xdr);
|
||||
xdr.writeInt(name.getBytes().length);
|
||||
xdr.writeFixedOpaque(name.getBytes());
|
||||
xdr.writeInt(name.getBytes(Charsets.UTF_8).length);
|
||||
xdr.writeFixedOpaque(name.getBytes(Charsets.UTF_8));
|
||||
symAttr.serialize(xdr);
|
||||
xdr.writeInt(symData.getBytes().length);
|
||||
xdr.writeFixedOpaque(symData.getBytes());
|
||||
xdr.writeInt(symData.getBytes(Charsets.UTF_8).length);
|
||||
xdr.writeFixedOpaque(symData.getBytes(Charsets.UTF_8));
|
||||
}
|
||||
}
|
@ -19,6 +19,7 @@
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.apache.commons.io.Charsets;
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.buffer.ChannelBuffers;
|
||||
|
||||
@ -165,11 +166,11 @@ public void writeVariableOpaque(byte[] src) {
|
||||
}
|
||||
|
||||
public String readString() {
|
||||
return new String(readVariableOpaque());
|
||||
return new String(readVariableOpaque(), Charsets.UTF_8);
|
||||
}
|
||||
|
||||
public void writeString(String s) {
|
||||
writeVariableOpaque(s.getBytes());
|
||||
writeVariableOpaque(s.getBytes(Charsets.UTF_8));
|
||||
}
|
||||
|
||||
private void writePadding() {
|
||||
|
@ -20,6 +20,7 @@
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import org.apache.commons.io.Charsets;
|
||||
import org.apache.hadoop.oncrpc.XDR;
|
||||
|
||||
/** Credential used by AUTH_SYS */
|
||||
@ -93,7 +94,7 @@ public void read(XDR xdr) {
|
||||
@Override
|
||||
public void write(XDR xdr) {
|
||||
// mStamp + mHostName.length + mHostName + mUID + mGID + mAuxGIDs.count
|
||||
mCredentialsLength = 20 + mHostName.getBytes().length;
|
||||
mCredentialsLength = 20 + mHostName.getBytes(Charsets.UTF_8).length;
|
||||
// mAuxGIDs
|
||||
if (mAuxGIDs != null && mAuxGIDs.length > 0) {
|
||||
mCredentialsLength += mAuxGIDs.length * 4;
|
||||
|
@ -593,6 +593,8 @@ Release 2.7.0 - UNRELEASED
|
||||
HDFS-7506. Consolidate implementation of setting inode attributes into a
|
||||
single class. (wheat9)
|
||||
|
||||
HDFS-7516. Fix findbugs warnings in hdfs-nfs project. (brandonli)
|
||||
|
||||
Release 2.6.1 - UNRELEASED
|
||||
|
||||
INCOMPATIBLE CHANGES
|
||||
|
Loading…
Reference in New Issue
Block a user