From commits-return-22701-archive-asf-public=cust-asf.ponee.io@accumulo.apache.org Tue Mar 12 23:18:07 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 58007180600 for ; Wed, 13 Mar 2019 00:18:07 +0100 (CET) Received: (qmail 4579 invoked by uid 500); 12 Mar 2019 23:18:06 -0000 Mailing-List: contact commits-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@accumulo.apache.org Delivered-To: mailing list commits@accumulo.apache.org Received: (qmail 4570 invoked by uid 99); 12 Mar 2019 23:18:06 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Mar 2019 23:18:06 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id DCEDB879DB; Tue, 12 Mar 2019 23:18:05 +0000 (UTC) Date: Tue, 12 Mar 2019 23:18:05 +0000 To: "commits@accumulo.apache.org" Subject: [accumulo] branch master updated: Fix lgtm dead logic alerts (#1025) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <155243268542.7657.14568042840853300139@gitbox.apache.org> From: mmiller@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: accumulo X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: dbfe04b446181be5688e57dd9960c79d7eeefe19 X-Git-Newrev: e124fcd34da80d8d7eae866af6c3b359d56ef075 X-Git-Rev: e124fcd34da80d8d7eae866af6c3b359d56ef075 X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated This is an automated email from the ASF dual-hosted git repository. mmiller pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/accumulo.git The following commit(s) were added to refs/heads/master by this push: new e124fcd Fix lgtm dead logic alerts (#1025) e124fcd is described below commit e124fcd34da80d8d7eae866af6c3b359d56ef075 Author: Mike Miller AuthorDate: Tue Mar 12 19:17:59 2019 -0400 Fix lgtm dead logic alerts (#1025) * Remove checks that will never be true * Add comments for false positives --- .../java/org/apache/accumulo/fate/ZooStore.java | 6 ++-- .../org/apache/accumulo/tserver/tablet/Tablet.java | 34 +++++----------------- 2 files changed, 12 insertions(+), 28 deletions(-) diff --git a/core/src/main/java/org/apache/accumulo/fate/ZooStore.java b/core/src/main/java/org/apache/accumulo/fate/ZooStore.java index c1064ba..bb6c9f7 100644 --- a/core/src/main/java/org/apache/accumulo/fate/ZooStore.java +++ b/core/src/main/java/org/apache/accumulo/fate/ZooStore.java @@ -187,7 +187,8 @@ public class ZooStore implements TStore { } synchronized (this) { - if (events == statusChangeEvents) { + // suppress lgtm alert - synchronized variable is not always true + if (events == statusChangeEvents) { // lgtm [java/constant-comparison] if (defered.size() > 0) { Long minTime = Collections.min(defered.values()); long waitTime = minTime - System.currentTimeMillis(); @@ -376,7 +377,8 @@ public class ZooStore implements TStore { return status; synchronized (this) { - if (events == statusChangeEvents) { + // suppress lgtm alert - synchronized variable is not always true + if (events == statusChangeEvents) { // lgtm [java/constant-comparison] try { this.wait(5000); } catch (InterruptedException e) { diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java index 5cc6af2..d1d78a8 100644 --- a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java +++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java @@ -2610,39 +2610,21 @@ public class Tablet { return !releaseLock; } - int numAdded = 0; - int numContained = 0; + boolean added; + boolean contained; if (addToOther) { - if (otherLogs.add(more)) - numAdded++; - - if (currentLogs.contains(more)) - numContained++; + added = otherLogs.add(more); + contained = currentLogs.contains(more); } else { - if (currentLogs.add(more)) - numAdded++; - - if (otherLogs.contains(more)) - numContained++; + added = currentLogs.add(more); + contained = otherLogs.contains(more); } - if (numAdded > 0) { + if (added) { rebuildReferencedLogs(); } - if (numAdded > 1) { - // expect to add all or none - throw new IllegalArgumentException( - "Added subset of logs " + extent + " " + more + " " + currentLogs); - } - - if (numContained > 1) { - // expect to contain all or none - throw new IllegalArgumentException( - "Other logs contained subset of logs " + extent + " " + more + " " + otherLogs); - } - - if (numAdded > 0 && numContained == 0) { + if (added && !contained) { releaseLock = false; }