Revert "Use ProtobufMagic methods in ProtobufUtil"

This reverts commit 6b37f26280.
This commit is contained in:
Sean Busbey 2015-06-23 00:30:25 -05:00
parent b636c6b1cd
commit abc2e61eb1
2 changed files with 9 additions and 4 deletions

View File

@ -264,7 +264,8 @@ 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) {
return ProtobufMagic.isPBMagicPrefix(bytes); if (bytes == null) return false;
return isPBMagicPrefix(bytes, 0, bytes.length);
} }
/** /**
@ -274,7 +275,9 @@ 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) {
return ProtobufMagic.isPBMagicPrefix(bytes, offset, len); if (bytes == null || len < ProtobufMagic.PB_MAGIC.length) return false;
return Bytes.compareTo(ProtobufMagic.PB_MAGIC, 0, ProtobufMagic.PB_MAGIC.length,
bytes, offset, ProtobufMagic.PB_MAGIC.length) == 0;
} }
/** /**
@ -289,10 +292,10 @@ public final class ProtobufUtil {
} }
/** /**
* @return Length of {@link ProtobufMagic#lengthOfPBMagic()} * @return Length of {@link ProtobufMagic#PB_MAGIC}
*/ */
public static int lengthOfPBMagic() { public static int lengthOfPBMagic() {
return ProtobufMagic.lengthOfPBMagic(); return ProtobufMagic.PB_MAGIC.length;
} }
/** /**

View File

@ -22,6 +22,8 @@ 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 {