Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id A87BA200CA3 for ; Thu, 18 May 2017 07:17:10 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id A6EA1160BCB; Thu, 18 May 2017 05:17:10 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id C9ADC160BBA for ; Thu, 18 May 2017 07:17:09 +0200 (CEST) Received: (qmail 14264 invoked by uid 500); 18 May 2017 05:17:08 -0000 Mailing-List: contact issues-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list issues@hbase.apache.org Received: (qmail 14253 invoked by uid 99); 18 May 2017 05:17:08 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 May 2017 05:17:08 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 70ECB1A0082 for ; Thu, 18 May 2017 05:17:08 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.202 X-Spam-Level: X-Spam-Status: No, score=-99.202 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id ioA7ENyYCi6u for ; Thu, 18 May 2017 05:17:07 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id DD7685F568 for ; Thu, 18 May 2017 05:17:06 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id E8F4AE02CA for ; Thu, 18 May 2017 05:17:05 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 8491E263A8 for ; Thu, 18 May 2017 05:17:04 +0000 (UTC) Date: Thu, 18 May 2017 05:17:04 +0000 (UTC) From: "Guanghao Zhang (JIRA)" To: issues@hbase.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (HBASE-15616) CheckAndMutate will encouter NPE if qualifier to check is null MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Thu, 18 May 2017 05:17:10 -0000 [ https://issues.apache.org/jira/browse/HBASE-15616?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16015219#comment-16015219 ] Guanghao Zhang commented on HBASE-15616: ---------------------------------------- Attach a v3 patch. I add a ut to make sure null qualifier will be allowed by increment/append/checkAnd* operation. For put, it create a cell for each column and value. And when use qualifier, copy it from the byte array. Because the qualifier length is 0, so it set a new byte[0] for null qualifier. The v3 patch use new byte[0] for increment/checkAnd*'s null qualifier, too. > CheckAndMutate will encouter NPE if qualifier to check is null > -------------------------------------------------------------- > > Key: HBASE-15616 > URL: https://issues.apache.org/jira/browse/HBASE-15616 > Project: HBase > Issue Type: Bug > Components: Client > Affects Versions: 2.0.0 > Reporter: Jianwei Cui > Assignee: Guanghao Zhang > Attachments: HBASE-15616-v1.patch, HBASE-15616-v2.patch, HBASE-15616-v3.patch > > > If qualifier to check is null, the checkAndMutate/checkAndPut/checkAndDelete will encounter NPE. > The test code: > {code} > table.checkAndPut(row, family, null, Bytes.toBytes(0), new Put(row).addColumn(family, null, Bytes.toBytes(1))); > {code} > The exception: > {code} > Exception in thread "main" org.apache.hadoop.hbase.client.RetriesExhaustedException: Failed after attempts=3, exceptions: > Fri Apr 08 15:51:31 CST 2016, RpcRetryingCaller{globalStartTime=1460101891615, pause=100, maxAttempts=3}, java.io.IOException: com.google.protobuf.ServiceException: java.lang.NullPointerException > Fri Apr 08 15:51:31 CST 2016, RpcRetryingCaller{globalStartTime=1460101891615, pause=100, maxAttempts=3}, java.io.IOException: com.google.protobuf.ServiceException: java.lang.NullPointerException > Fri Apr 08 15:51:32 CST 2016, RpcRetryingCaller{globalStartTime=1460101891615, pause=100, maxAttempts=3}, java.io.IOException: com.google.protobuf.ServiceException: java.lang.NullPointerException > at org.apache.hadoop.hbase.client.RpcRetryingCallerImpl.callWithRetries(RpcRetryingCallerImpl.java:120) > at org.apache.hadoop.hbase.client.HTable.checkAndPut(HTable.java:772) > at ... > Caused by: java.io.IOException: com.google.protobuf.ServiceException: java.lang.NullPointerException > at org.apache.hadoop.hbase.protobuf.ProtobufUtil.getRemoteException(ProtobufUtil.java:341) > at org.apache.hadoop.hbase.client.HTable$7.call(HTable.java:768) > at org.apache.hadoop.hbase.client.HTable$7.call(HTable.java:755) > at org.apache.hadoop.hbase.client.RpcRetryingCallerImpl.callWithRetries(RpcRetryingCallerImpl.java:99) > ... 2 more > Caused by: com.google.protobuf.ServiceException: java.lang.NullPointerException > at org.apache.hadoop.hbase.ipc.AbstractRpcClient.callBlockingMethod(AbstractRpcClient.java:239) > at org.apache.hadoop.hbase.ipc.AbstractRpcClient$BlockingRpcChannelImplementation.callBlockingMethod(AbstractRpcClient.java:331) > at org.apache.hadoop.hbase.protobuf.generated.ClientProtos$ClientService$BlockingStub.mutate(ClientProtos.java:35252) > at org.apache.hadoop.hbase.client.HTable$7.call(HTable.java:765) > ... 4 more > Caused by: java.lang.NullPointerException > at com.google.protobuf.LiteralByteString.size(LiteralByteString.java:76) > at com.google.protobuf.CodedOutputStream.computeBytesSizeNoTag(CodedOutputStream.java:767) > at com.google.protobuf.CodedOutputStream.computeBytesSize(CodedOutputStream.java:539) > at org.apache.hadoop.hbase.protobuf.generated.ClientProtos$Condition.getSerializedSize(ClientProtos.java:7483) > at com.google.protobuf.CodedOutputStream.computeMessageSizeNoTag(CodedOutputStream.java:749) > at com.google.protobuf.CodedOutputStream.computeMessageSize(CodedOutputStream.java:530) > at org.apache.hadoop.hbase.protobuf.generated.ClientProtos$MutateRequest.getSerializedSize(ClientProtos.java:12431) > at org.apache.hadoop.hbase.ipc.IPCUtil.getTotalSizeWhenWrittenDelimited(IPCUtil.java:311) > at org.apache.hadoop.hbase.ipc.AsyncRpcChannel.writeRequest(AsyncRpcChannel.java:409) > at org.apache.hadoop.hbase.ipc.AsyncRpcChannel.callMethod(AsyncRpcChannel.java:333) > at org.apache.hadoop.hbase.ipc.AsyncRpcClient.call(AsyncRpcClient.java:245) > at org.apache.hadoop.hbase.ipc.AbstractRpcClient.callBlockingMethod(AbstractRpcClient.java:226) > ... 7 more > {code} > The reason is {{LiteralByteString.size()}} will throw NPE if wrapped byte array is null. It is possible to invoke {{put}} and {{checkAndMutate}} on the same column, because null qualifier is allowed for {{Put}}, users may be confused if null qualifier is not allowed for {{checkAndMutate}}. We can also convert null qualifier to empty byte array for {{checkAndMutate}} in client side. Discussions and suggestions are welcomed. -- This message was sent by Atlassian JIRA (v6.3.15#6346)