From 8efa08a11119dbd89dcc38d038ce0f44c9f40331 Mon Sep 17 00:00:00 2001 From: Benoit Sigoure Date: Sun, 26 Jan 2014 18:29:24 -0800 Subject: [PATCH] Fix the signature of zeroCopyGetBytes to make it usable. --- .../main/java/com/google/protobuf/ZeroCopyLiteralByteString.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hbase-protocol/src/main/java/com/google/protobuf/ZeroCopyLiteralByteString.java b/hbase-protocol/src/main/java/com/google/protobuf/ZeroCopyLiteralByteString.java index c57f1a7..8a70c9c 100644 --- a/hbase-protocol/src/main/java/com/google/protobuf/ZeroCopyLiteralByteString.java +++ b/hbase-protocol/src/main/java/com/google/protobuf/ZeroCopyLiteralByteString.java @@ -57,7 +57,12 @@ public final class ZeroCopyLiteralByteString extends LiteralByteString { * @param buf A buffer from which to extract the array. This buffer must be * actually an instance of a {@code LiteralByteString}. */ - public static byte[] zeroCopyGetBytes(final LiteralByteString buf) { - return buf.bytes; + public static byte[] zeroCopyGetBytes(final ByteString buf) { + if (buf instanceof LiteralByteString) { + return ((LiteralByteString) buf).bytes; + } + throw new UnsupportedOperationException("Need a LiteralByteString, got a " + + buf.getClass().getName()); } + } -- 1.8.4.475.gd10da9c