Return-Path: X-Original-To: apmail-calcite-dev-archive@www.apache.org Delivered-To: apmail-calcite-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 51E14186D6 for ; Thu, 3 Dec 2015 23:50:16 +0000 (UTC) Received: (qmail 82933 invoked by uid 500); 3 Dec 2015 23:50:16 -0000 Delivered-To: apmail-calcite-dev-archive@calcite.apache.org Received: (qmail 82864 invoked by uid 500); 3 Dec 2015 23:50:16 -0000 Mailing-List: contact dev-help@calcite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@calcite.apache.org Delivered-To: mailing list dev@calcite.apache.org Received: (qmail 82852 invoked by uid 99); 3 Dec 2015 23:50:15 -0000 Received: from Unknown (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Dec 2015 23:50:15 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 70D12CC8DB for ; Thu, 3 Dec 2015 23:50:15 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.7 X-Spam-Level: X-Spam-Status: No, score=0.7 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, KAM_ASCII_DIVIDERS=0.8, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id mwR055GJrOqk for ; Thu, 3 Dec 2015 23:50:04 +0000 (UTC) Received: from mail-qk0-f180.google.com (mail-qk0-f180.google.com [209.85.220.180]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with ESMTPS id 5B5A942AD1 for ; Thu, 3 Dec 2015 23:50:04 +0000 (UTC) Received: by qkfo3 with SMTP id o3so37319364qkf.1 for ; Thu, 03 Dec 2015 15:49:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=QWZa2ArD2crDAzX8ptL4ZYOe7G8g1oe2KjiGepkOkGQ=; b=r5uAVz7jI25UOJj6+MpE64jys3J2sFesBp5v5lOsEU5gW3hXrWZHBEX4tCEFcE7jZW /taq33abX92V58d7T7fLhjAqqYvDfoF0iskL3IOLB+dAX2p4+xrXT0GdAPj7U8pcQDHS Aj4le7bztgb9urasIuiFB7qjf3M4bRunrTrlGoVDcJ3vq1F9kpt5S6LXKddz11GzJNV0 s9EE8LHRHQLGbLg6TuNH6lPgHQvDYr3ic908Q04IcaDKN2cBy+vKg5NxpuCNH8Lr1YDy L2ie3QvAIsn5fwGIvwqRzJcBdotqZgUEoAdUdRUjmvlwUw3kUN/+paB+tPAtwpIhxw+w IjsA== X-Received: by 10.55.76.16 with SMTP id z16mr14335306qka.83.1449186598680; Thu, 03 Dec 2015 15:49:58 -0800 (PST) Received: from hw10447.local (c-76-100-48-87.hsd1.md.comcast.net. [76.100.48.87]) by smtp.googlemail.com with ESMTPSA id e184sm4348064qkb.40.2015.12.03.15.49.57 for (version=TLSv1/SSLv3 cipher=OTHER); Thu, 03 Dec 2015 15:49:57 -0800 (PST) Message-ID: <5660D522.9000005@gmail.com> Date: Thu, 03 Dec 2015 18:49:54 -0500 From: Josh Elser User-Agent: Postbox 3.0.11 (Macintosh/20140602) MIME-Version: 1.0 To: dev@calcite.apache.org Subject: Re: FW: New Defects reported by Coverity Scan for Apache Calcite References: <56609508dcacd_2dd3885338366b5@ss1435.mail> <5B7DD02C-0E0F-4007-88D5-7F3D85C0DBDD@apache.org> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Alrighty, easy enough. Julian Hyde wrote: > Intellij highlights several other bugs in that file: lines 398, 1036, > 1246, 1326 (possible), 2266. Please fix these also. > > On Thu, Dec 3, 2015 at 2:59 PM, Julian Hyde wrote: >> Bosco, >> >> Yes, this is a problem. Thanks for forwarding. >> >> Josh, >> >> You made this change yesterday. Can you please fix? >> >> I see quite a few examples in that file that should be boilerplate. Why does >> >> if (obj == null || !(obj instanceof RpcMetadataResponse)) { >> return false; >> } >> >> depart from >> >> if (!(obj instanceof RpcMetadataResponse)) { >> return false; >> } >> >> which is sufficient and is used elsewhere in the file? Boring stuff >> should look boring. >> >> In fact the whole method could be simplified. Rather than >> >> public boolean equals(Object obj) { >> if (this == obj) { >> return true; >> } >> >> if (obj == null || !(obj instanceof RpcMetadataResponse)) { >> return false; >> } >> >> RpcMetadataResponse other = (RpcMetadataResponse) obj; >> if (serverAddress == null) { >> if (other.serverAddress != null) { >> return false; >> } >> } >> return serverAddress.equals(other.serverAddress); >> } >> >> there is a case to be made that >> >> public boolean equals(Object obj) { >> return this == obj >> || obj instanceof RpcMetadataResponse >> && Objects.equals(((RpcMetadataResponse) obj).serverAddress, serverAddress); >> } >> >> is more understandable as well as more concise. >> >> Elsewhere in the file there is -- not written by you -- the following: >> >> if (null == connectionId) { >> if (null != other.connectionId) { >> return false; >> } >> } else if (!connectionId.equals(other.connectionId)) { >> return false; >> } >> >> return true; >> >> It works, but not obviously so. >> >> Julian >> >> >> On Thu, Dec 3, 2015 at 11:21 AM, Bosco Durai wrote: >>>> 3195 return serverAddress.equals(other.serverAddress); >>> Good catch. I know you are monitoring it. Just wanted double sure about it… >>> >>> Thanks >>> >>> Bosco >>> >>> >>> >>> >>> On 12/3/15, 11:16 AM, "scan-admin@coverity.com" wrote: >>> >>>> Hi, >>>> >>>> Please find the latest report on new defect(s) introduced to Apache Calcite found with Coverity Scan. >>>> >>>> 1 new defect(s) introduced to Apache Calcite found with Coverity Scan. >>>> >>>> >>>> New defect(s) Reported-by: Coverity Scan >>>> Showing 1 of 1 defect(s) >>>> >>>> >>>> ** CID 120367: Null pointer dereferences (FORWARD_NULL) >>>> /avatica/src/main/java/org/apache/calcite/avatica/remote/Service.java: 3195 in org.apache.calcite.avatica.remote.Service$RpcMetadataResponse.equals(java.lang.Object)() >>>> >>>> >>>> ________________________________________________________________________________________________________ >>>> *** CID 120367: Null pointer dereferences (FORWARD_NULL) >>>> /avatica/src/main/java/org/apache/calcite/avatica/remote/Service.java: 3195 in org.apache.calcite.avatica.remote.Service$RpcMetadataResponse.equals(java.lang.Object)() >>>> 3189 RpcMetadataResponse other = (RpcMetadataResponse) obj; >>>> 3190 if (serverAddress == null) { >>>> 3191 if (other.serverAddress != null) { >>>> 3192 return false; >>>> 3193 } >>>> 3194 } >>>>>>> CID 120367: Null pointer dereferences (FORWARD_NULL) >>>>>>> Calling a method on null object "serverAddress". >>>> 3195 return serverAddress.equals(other.serverAddress); >>>> 3196 } >>>> 3197 } >>>> 3198 } >>>> 3199 >>>> >>>> >>>> ________________________________________________________________________________________________________ >>>> To view the defects in Coverity Scan visit, https://scan.coverity.com/projects/apache-calcite?tab=overview >>>> >>>> To manage Coverity Scan email notifications for "bosco@apache.org", click https://scan.coverity.com/subscriptions/edit?email=bosco%40apache.org&token=368c97cfe2c99af46cce4f2657f16fe3 >>>>