You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ed...@apache.org on 2023/02/01 19:02:52 UTC

[accumulo] branch 2.1 updated: fix checkstyle issues failing commit build checks and other suggestions (#3179)

This is an automated email from the ASF dual-hosted git repository.

edcoleman pushed a commit to branch 2.1
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/2.1 by this push:
     new af63adc4d7 fix checkstyle issues failing commit build checks and other suggestions (#3179)
af63adc4d7 is described below

commit af63adc4d797985a1fe7ade0728b82b1b04c50e9
Author: EdColeman <de...@etcoleman.com>
AuthorDate: Wed Feb 1 14:02:44 2023 -0500

    fix checkstyle issues failing commit build checks and other suggestions (#3179)
    
    * fix checkstyle issues failing commit checks and other suggestions
    * convert uses of Arrays.asList to List.of
---
 .../core/clientImpl/TabletLocatorImpl.java         | 15 +++----
 .../core/clientImpl/TabletLocatorImplTest.java     | 46 ++++++++++------------
 2 files changed, 28 insertions(+), 33 deletions(-)

diff --git a/core/src/main/java/org/apache/accumulo/core/clientImpl/TabletLocatorImpl.java b/core/src/main/java/org/apache/accumulo/core/clientImpl/TabletLocatorImpl.java
index 31ec31c027..02844db972 100644
--- a/core/src/main/java/org/apache/accumulo/core/clientImpl/TabletLocatorImpl.java
+++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/TabletLocatorImpl.java
@@ -83,11 +83,11 @@ public class TabletLocatorImpl extends TabletLocator {
   protected TabletLocator parent;
   protected TreeMap<Text,TabletLocation> metaCache = new TreeMap<>(END_ROW_COMPARATOR);
   protected TabletLocationObtainer locationObtainer;
-  private TabletServerLockChecker lockChecker;
+  private final TabletServerLockChecker lockChecker;
   protected Text lastTabletRow;
 
-  private TreeSet<KeyExtent> badExtents = new TreeSet<>();
-  private ReentrantReadWriteLock rwLock = new ReentrantReadWriteLock();
+  private final TreeSet<KeyExtent> badExtents = new TreeSet<>();
+  private final ReentrantReadWriteLock rwLock = new ReentrantReadWriteLock();
   private final Lock rLock = rwLock.readLock();
   private final Lock wLock = rwLock.writeLock();
 
@@ -111,8 +111,8 @@ public class TabletLocatorImpl extends TabletLocator {
 
   private class LockCheckerSession {
 
-    private HashSet<Pair<String,String>> okLocks = new HashSet<>();
-    private HashSet<Pair<String,String>> invalidLocks = new HashSet<>();
+    private final HashSet<Pair<String,String>> okLocks = new HashSet<>();
+    private final HashSet<Pair<String,String>> invalidLocks = new HashSet<>();
 
     private TabletLocation checkLock(TabletLocation tl) {
       // the goal of this class is to minimize calls out to lockChecker under that assumption that
@@ -353,8 +353,9 @@ public class TabletLocatorImpl extends TabletLocator {
         }
       } else {
         failures.add(range);
-        if (!useCache)
+        if (!useCache) {
           lookupFailed = true;
+        }
       }
 
     }
@@ -617,7 +618,7 @@ public class TabletLocatorImpl extends TabletLocator {
   }
 
   static void removeOverlapping(TreeMap<Text,TabletLocation> metaCache, KeyExtent nke) {
-    Iterator<Entry<Text,TabletLocation>> iter = null;
+    Iterator<Entry<Text,TabletLocation>> iter;
 
     if (nke.prevEndRow() == null) {
       iter = metaCache.entrySet().iterator();
diff --git a/core/src/test/java/org/apache/accumulo/core/clientImpl/TabletLocatorImplTest.java b/core/src/test/java/org/apache/accumulo/core/clientImpl/TabletLocatorImplTest.java
index e33b937208..ea20ee6643 100644
--- a/core/src/test/java/org/apache/accumulo/core/clientImpl/TabletLocatorImplTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/clientImpl/TabletLocatorImplTest.java
@@ -19,15 +19,14 @@
 package org.apache.accumulo.core.clientImpl;
 
 import static org.easymock.EasyMock.replay;
-import static org.junit.Assert.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -58,7 +57,6 @@ import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.Cu
 import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.TabletColumnFamily;
 import org.apache.hadoop.io.Text;
 import org.easymock.EasyMock;
-import org.junit.Assert;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
@@ -84,7 +82,7 @@ public class TabletLocatorImplTest {
   }
 
   static List<Range> createNewRangeList(Range... ranges) {
-    return Arrays.asList(ranges);
+    return List.of(ranges);
   }
 
   static class RangeLocation {
@@ -258,7 +256,7 @@ public class TabletLocatorImplTest {
   }
 
   static List<Mutation> createNewMutationList(Mutation... ma) {
-    return Arrays.asList(ma);
+    return List.of(ma);
   }
 
   private void runTest(TabletLocatorImpl metaCache, List<Mutation> ml,
@@ -270,7 +268,7 @@ public class TabletLocatorImplTest {
     verify(emb, binnedMutations);
 
     ArrayList<String> afs = new ArrayList<>();
-    ArrayList<String> efs = new ArrayList<>(Arrays.asList(efailures));
+    ArrayList<String> efs = new ArrayList<>(List.of(efailures));
 
     for (Mutation mutation : afailures) {
       afs.add(new String(mutation.getRow()));
@@ -1090,8 +1088,6 @@ public class TabletLocatorImplTest {
     KeyExtent e2 = createNewKeyExtent("foo", "1", "05");
     KeyExtent e3 = createNewKeyExtent("foo", "2", "05");
 
-    Text tableName = new Text("foo");
-
     TServers tservers = new TServers();
     TabletLocatorImpl metaCache =
         createLocators(tservers, "tserver1", "tserver2", "foo", e1, "l1", e2, "l1");
@@ -1137,8 +1133,6 @@ public class TabletLocatorImplTest {
     KeyExtent e6 = createNewKeyExtent("foo", "s", "n");
     KeyExtent e7 = createNewKeyExtent("foo", null, "s");
 
-    Text tableName = new Text("foo");
-
     TServers tservers = new TServers();
     TabletLocatorImpl metaCache = createLocators(tservers, "tserver1", "tserver2", "foo", e1, "l1",
         e2, "l1", e4, "l1", e5, "l1", e7, "l1");
@@ -1186,31 +1180,31 @@ public class TabletLocatorImplTest {
     TabletLocation e3 = new TabletLocation(createNewKeyExtent("foo", "3", "2"), "l1", "1");
     TabletLocation e4 = new TabletLocation(createNewKeyExtent("foo", null, "3"), "l1", "1");
 
-    Assert.assertTrue(TabletLocatorImpl.isContiguous(Arrays.asList(e1, e2, e3, e4)));
-    Assert.assertTrue(TabletLocatorImpl.isContiguous(Arrays.asList(e1, e2, e3)));
-    Assert.assertTrue(TabletLocatorImpl.isContiguous(Arrays.asList(e2, e3, e4)));
-    Assert.assertTrue(TabletLocatorImpl.isContiguous(Arrays.asList(e2, e3)));
-    Assert.assertTrue(TabletLocatorImpl.isContiguous(Arrays.asList(e1)));
-    Assert.assertTrue(TabletLocatorImpl.isContiguous(Arrays.asList(e2)));
-    Assert.assertTrue(TabletLocatorImpl.isContiguous(Arrays.asList(e4)));
+    assertTrue(TabletLocatorImpl.isContiguous(List.of(e1, e2, e3, e4)));
+    assertTrue(TabletLocatorImpl.isContiguous(List.of(e1, e2, e3)));
+    assertTrue(TabletLocatorImpl.isContiguous(List.of(e2, e3, e4)));
+    assertTrue(TabletLocatorImpl.isContiguous(List.of(e2, e3)));
+    assertTrue(TabletLocatorImpl.isContiguous(List.of(e1)));
+    assertTrue(TabletLocatorImpl.isContiguous(List.of(e2)));
+    assertTrue(TabletLocatorImpl.isContiguous(List.of(e4)));
 
-    assertFalse(TabletLocatorImpl.isContiguous(Arrays.asList(e1, e2, e4)));
-    assertFalse(TabletLocatorImpl.isContiguous(Arrays.asList(e1, e3, e4)));
+    assertFalse(TabletLocatorImpl.isContiguous(List.of(e1, e2, e4)));
+    assertFalse(TabletLocatorImpl.isContiguous(List.of(e1, e3, e4)));
 
     TabletLocation e5 = new TabletLocation(createNewKeyExtent("foo", null, null), "l1", "1");
-    assertFalse(TabletLocatorImpl.isContiguous(Arrays.asList(e1, e2, e3, e4, e5)));
-    assertFalse(TabletLocatorImpl.isContiguous(Arrays.asList(e5, e1, e2, e3, e4)));
-    assertFalse(TabletLocatorImpl.isContiguous(Arrays.asList(e1, e2, e3, e5)));
-    assertFalse(TabletLocatorImpl.isContiguous(Arrays.asList(e5, e2, e3, e4)));
-    Assert.assertTrue(TabletLocatorImpl.isContiguous(Arrays.asList(e5)));
+    assertFalse(TabletLocatorImpl.isContiguous(List.of(e1, e2, e3, e4, e5)));
+    assertFalse(TabletLocatorImpl.isContiguous(List.of(e5, e1, e2, e3, e4)));
+    assertFalse(TabletLocatorImpl.isContiguous(List.of(e1, e2, e3, e5)));
+    assertFalse(TabletLocatorImpl.isContiguous(List.of(e5, e2, e3, e4)));
+    assertTrue(TabletLocatorImpl.isContiguous(List.of(e5)));
 
     TabletLocation e6 = new TabletLocation(createNewKeyExtent("foo", null, "1"), "l1", "1");
 
-    assertFalse(TabletLocatorImpl.isContiguous(Arrays.asList(e1, e2, e3, e6)));
+    assertFalse(TabletLocatorImpl.isContiguous(List.of(e1, e2, e3, e6)));
 
     TabletLocation e7 = new TabletLocation(createNewKeyExtent("foo", "33", "11"), "l1", "1");
 
-    assertFalse(TabletLocatorImpl.isContiguous(Arrays.asList(e1, e2, e7, e4)));
+    assertFalse(TabletLocatorImpl.isContiguous(List.of(e1, e2, e7, e4)));
   }
 
   @Test