HBASE-13900 Use ProtobufMagic methods in ProtobufUtil

Signed-off-by: Andrew Purtell <apurtell@apache.org>
This commit is contained in:
Gábor Lipták 2015-06-16 21:13:58 -04:00 committed by Sean Busbey
parent abc2e61eb1
commit 6a537eb854
2 changed files with 4 additions and 9 deletions

View File

@ -264,8 +264,7 @@ public final class ProtobufUtil {
* @return True if passed <code>bytes</code> has {@link ProtobufMagic#PB_MAGIC} for a prefix. * @return True if passed <code>bytes</code> has {@link ProtobufMagic#PB_MAGIC} for a prefix.
*/ */
public static boolean isPBMagicPrefix(final byte [] bytes) { public static boolean isPBMagicPrefix(final byte [] bytes) {
if (bytes == null) return false; return ProtobufMagic.isPBMagicPrefix(bytes);
return isPBMagicPrefix(bytes, 0, bytes.length);
} }
/** /**
@ -275,9 +274,7 @@ public final class ProtobufUtil {
* @return True if passed <code>bytes</code> has {@link ProtobufMagic#PB_MAGIC} for a prefix. * @return True if passed <code>bytes</code> has {@link ProtobufMagic#PB_MAGIC} for a prefix.
*/ */
public static boolean isPBMagicPrefix(final byte [] bytes, int offset, int len) { public static boolean isPBMagicPrefix(final byte [] bytes, int offset, int len) {
if (bytes == null || len < ProtobufMagic.PB_MAGIC.length) return false; return ProtobufMagic.isPBMagicPrefix(bytes, offset, len);
return Bytes.compareTo(ProtobufMagic.PB_MAGIC, 0, ProtobufMagic.PB_MAGIC.length,
bytes, offset, ProtobufMagic.PB_MAGIC.length) == 0;
} }
/** /**
@ -292,10 +289,10 @@ public final class ProtobufUtil {
} }
/** /**
* @return Length of {@link ProtobufMagic#PB_MAGIC} * @return Length of {@link ProtobufMagic#lengthOfPBMagic()}
*/ */
public static int lengthOfPBMagic() { public static int lengthOfPBMagic() {
return ProtobufMagic.PB_MAGIC.length; return ProtobufMagic.lengthOfPBMagic();
} }
/** /**

View File

@ -22,8 +22,6 @@ import org.apache.hadoop.hbase.classification.InterfaceAudience;
/** /**
* Protobufs utility. * Protobufs utility.
*/ */
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value="DP_CREATE_CLASSLOADER_INSIDE_DO_PRIVILEGED",
justification="None. Address sometime.")
@InterfaceAudience.Private @InterfaceAudience.Private
public class ProtobufMagic { public class ProtobufMagic {