From 6b37f26280ea7e2f475f9813301543411e71383b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Lipt=C3=A1k?= Date: Tue, 16 Jun 2015 21:13:58 -0400 Subject: [PATCH] Use ProtobufMagic methods in ProtobufUtil Signed-off-by: Andrew Purtell --- .../apache/hadoop/hbase/protobuf/ProtobufUtil.java | 11 ++++------- .../apache/hadoop/hbase/protobuf/ProtobufMagic.java | 2 -- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java index 1bcf1e62ad4..b72f0bbd7ee 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java @@ -264,8 +264,7 @@ public final class ProtobufUtil { * @return True if passed bytes has {@link ProtobufMagic#PB_MAGIC} for a prefix. */ public static boolean isPBMagicPrefix(final byte [] bytes) { - if (bytes == null) return false; - return isPBMagicPrefix(bytes, 0, bytes.length); + return ProtobufMagic.isPBMagicPrefix(bytes); } /** @@ -275,9 +274,7 @@ public final class ProtobufUtil { * @return True if passed bytes has {@link ProtobufMagic#PB_MAGIC} for a prefix. */ public static boolean isPBMagicPrefix(final byte [] bytes, int offset, int 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; + return ProtobufMagic.isPBMagicPrefix(bytes, offset, len); } /** @@ -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() { - return ProtobufMagic.PB_MAGIC.length; + return ProtobufMagic.lengthOfPBMagic(); } /** diff --git a/hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufMagic.java b/hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufMagic.java index bf947576884..7bd1bf94fd9 100644 --- a/hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufMagic.java +++ b/hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufMagic.java @@ -22,8 +22,6 @@ import org.apache.hadoop.hbase.classification.InterfaceAudience; /** * Protobufs utility. */ -@edu.umd.cs.findbugs.annotations.SuppressWarnings(value="DP_CREATE_CLASSLOADER_INSIDE_DO_PRIVILEGED", - justification="None. Address sometime.") @InterfaceAudience.Private public class ProtobufMagic {