Return-Path: X-Original-To: apmail-hbase-commits-archive@www.apache.org Delivered-To: apmail-hbase-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 46D6DCC71 for ; Thu, 18 Jul 2013 18:38:18 +0000 (UTC) Received: (qmail 51392 invoked by uid 500); 18 Jul 2013 18:38:18 -0000 Delivered-To: apmail-hbase-commits-archive@hbase.apache.org Received: (qmail 51344 invoked by uid 500); 18 Jul 2013 18:38:18 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 51335 invoked by uid 99); 18 Jul 2013 18:38:18 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Jul 2013 18:38:18 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Jul 2013 18:38:15 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 4916923888A6; Thu, 18 Jul 2013 18:37:54 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1504591 - in /hbase/trunk: hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java hbase-server/src/test/java/org/apache/hadoop/hbase/protobuf/TestProtobufUtil.java Date: Thu, 18 Jul 2013 18:37:54 -0000 To: commits@hbase.apache.org From: stack@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20130718183754.4916923888A6@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: stack Date: Thu Jul 18 18:37:53 2013 New Revision: 1504591 URL: http://svn.apache.org/r1504591 Log: HBASE-8987 ProtobufUtil.toException doesn't handle plain RemoteException, gets a NoSuchMethodException Modified: hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/protobuf/TestProtobufUtil.java Modified: hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java?rev=1504591&r1=1504590&r2=1504591&view=diff ============================================================================== --- hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java (original) +++ hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java Thu Jul 18 18:37:53 2013 @@ -1204,17 +1204,22 @@ public final class ProtobufUtil { * @throws IOException if failed to deserialize the parameter */ @SuppressWarnings("unchecked") - public static Throwable toException( - final NameBytesPair parameter) throws IOException { + public static Throwable toException(final NameBytesPair parameter) throws IOException { if (parameter == null || !parameter.hasValue()) return null; String desc = parameter.getValue().toStringUtf8(); String type = parameter.getName(); try { Class c = (Class)Class.forName(type, true, CLASS_LOADER); - Constructor cn = - c.getDeclaredConstructor(String.class); - return cn.newInstance(desc); + Constructor cn = null; + try { + cn = c.getDeclaredConstructor(String.class); + return cn.newInstance(desc); + } catch (NoSuchMethodException e) { + // Could be a raw RemoteException. See HBASE-8987. + cn = c.getDeclaredConstructor(String.class, String.class); + return cn.newInstance(type, desc); + } } catch (Exception e) { throw new IOException(e); } Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/protobuf/TestProtobufUtil.java URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/protobuf/TestProtobufUtil.java?rev=1504591&r1=1504590&r2=1504591&view=diff ============================================================================== --- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/protobuf/TestProtobufUtil.java (original) +++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/protobuf/TestProtobufUtil.java Thu Jul 18 18:37:53 2013 @@ -36,6 +36,7 @@ import org.apache.hadoop.hbase.protobuf. import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.ColumnValue.QualifierValue; import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.DeleteType; import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.MutationType; +import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.NameBytesPair; import org.apache.hadoop.hbase.util.Bytes; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -47,6 +48,20 @@ import com.google.protobuf.ByteString; */ @Category(SmallTests.class) public class TestProtobufUtil { + @Test + public void testException() throws IOException { + NameBytesPair.Builder builder = NameBytesPair.newBuilder(); + final String omg = "OMG!!!"; + builder.setName("java.io.IOException"); + builder.setValue(ByteString.copyFrom(Bytes.toBytes(omg))); + Throwable t = ProtobufUtil.toException(builder.build()); + assertEquals(omg, t.getMessage()); + builder.clear(); + builder.setName("org.apache.hadoop.ipc.RemoteException"); + builder.setValue(ByteString.copyFrom(Bytes.toBytes(omg))); + t = ProtobufUtil.toException(builder.build()); + assertEquals(omg, t.getMessage()); + } /** * Test basic Get conversions.