[accumulo] branch main updated: Avoid NPE when comparing equality (#2326)

2021-10-25 Thread ctubbsii
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/main by this push:
 new 5f20e38  Avoid NPE when comparing equality (#2326)
5f20e38 is described below

commit 5f20e38628abd6385a5ee652634f4d748ecd013f
Author: EdColeman 
AuthorDate: Mon Oct 25 13:29:22 2021 -0400

Avoid NPE when comparing equality (#2326)

* Use Objects.equals(a,b) instead of a.equals(b) to avoid NPE when a is null
* Apply other minor IDE suggested checkstyle corrections

Co-authored-by: Ed Coleman etcoleman 
---
 .../apache/accumulo/gc/SimpleGarbageCollector.java | 43 ++
 1 file changed, 20 insertions(+), 23 deletions(-)

diff --git 
a/server/gc/src/main/java/org/apache/accumulo/gc/SimpleGarbageCollector.java 
b/server/gc/src/main/java/org/apache/accumulo/gc/SimpleGarbageCollector.java
index 3b7761f..2c67b7c 100644
--- a/server/gc/src/main/java/org/apache/accumulo/gc/SimpleGarbageCollector.java
+++ b/server/gc/src/main/java/org/apache/accumulo/gc/SimpleGarbageCollector.java
@@ -31,6 +31,7 @@ import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map.Entry;
+import java.util.Objects;
 import java.util.Set;
 import java.util.SortedMap;
 import java.util.UUID;
@@ -97,7 +98,6 @@ import org.apache.accumulo.server.rpc.ThriftServerType;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.Path;
 import org.apache.htrace.Trace;
-import org.apache.htrace.TraceScope;
 import org.apache.htrace.impl.ProbabilitySampler;
 import org.apache.zookeeper.KeeperException;
 import org.slf4j.Logger;
@@ -110,19 +110,17 @@ import com.google.protobuf.InvalidProtocolBufferException;
 
 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 
-// Could/Should implement HighlyAvaialbleService but the Thrift server is 
already started before
+// Could/Should implement HighlyAvailableService but the Thrift server is 
already started before
 // the ZK lock is acquired. The server is only for metrics, there are no 
concerns about clients
 // using the service before the lock is acquired.
 public class SimpleGarbageCollector extends AbstractServer implements Iface {
 
   private static final Logger log = 
LoggerFactory.getLogger(SimpleGarbageCollector.class);
 
-  private ServiceLock lock;
-
-  private GCStatus status =
+  private final GCStatus status =
   new GCStatus(new GcCycleStats(), new GcCycleStats(), new GcCycleStats(), 
new GcCycleStats());
 
-  private GcCycleMetrics gcCycleMetrics = new GcCycleMetrics();
+  private final GcCycleMetrics gcCycleMetrics = new GcCycleMetrics();
 
   public static void main(String[] args) throws Exception {
 try (SimpleGarbageCollector gc = new SimpleGarbageCollector(new 
ServerOpts(), args)) {
@@ -201,14 +199,14 @@ public class SimpleGarbageCollector extends 
AbstractServer implements Iface {
 
   private class GCEnv implements GarbageCollectionEnvironment {
 
-private DataLevel level;
+private final DataLevel level;
 
 GCEnv(Ample.DataLevel level) {
   this.level = level;
 }
 
 @Override
-public Iterator getCandidates() throws TableNotFoundException {
+public Iterator getCandidates() {
   return getContext().getAmple().getGcCandidates(level);
 }
 
@@ -262,7 +260,7 @@ public class SimpleGarbageCollector extends AbstractServer 
implements Iface {
 .checkConsistency().fetch(DIR, FILES, SCANS).build().stream();
   }
 
-  Stream refStream = tabletStream.flatMap(tm -> {
+  return tabletStream.flatMap(tm -> {
 Stream refs = Stream.concat(tm.getFiles().stream(), 
tm.getScans().stream())
 .map(f -> new Reference(tm.getTableId(), f.getMetaUpdateDelete(), 
false));
 if (tm.getDirName() != null) {
@@ -271,8 +269,6 @@ public class SimpleGarbageCollector extends AbstractServer 
implements Iface {
 }
 return refs;
   });
-
-  return refStream;
 }
 
 @Override
@@ -323,7 +319,7 @@ public class SimpleGarbageCollector extends AbstractServer 
implements Iface {
   // volume switching when something needs to be deleted. Since 
the rest of the code
   // uses suffixes to compare delete entries, there is no danger
   // of deleting something that should not be deleted. Must not 
change value of delete
-  // variable because thats whats stored in metadata table.
+  // variable because that's what's stored in metadata table.
   log.debug("Volume replaced {} -> {}", delete, switchedDelete);
   fullPath = TabletFileUtil.validate(switchedDelete);
 } else {
@@ -402,7 +398,7 @@ public class SimpleGarbageCollector extends AbstractServer 
implements Iface {
   // if dir exist and is empty, then empty list is returned...
   // hadoop 2.0 will throw an 

[accumulo] branch main updated: Fix javadoc typo

2021-10-25 Thread mmiller
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/main by this push:
 new 4738d5a  Fix javadoc typo
4738d5a is described below

commit 4738d5ad55047a93a5e6869d0defea9b5b4956da
Author: Mike Miller 
AuthorDate: Mon Oct 25 09:01:38 2021 -0400

Fix javadoc typo
---
 .../java/org/apache/accumulo/core/client/lexicoder/AbstractEncoder.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/core/src/main/java/org/apache/accumulo/core/client/lexicoder/AbstractEncoder.java
 
b/core/src/main/java/org/apache/accumulo/core/client/lexicoder/AbstractEncoder.java
index 255a478..84d1257 100644
--- 
a/core/src/main/java/org/apache/accumulo/core/client/lexicoder/AbstractEncoder.java
+++ 
b/core/src/main/java/org/apache/accumulo/core/client/lexicoder/AbstractEncoder.java
@@ -23,7 +23,7 @@ import static java.util.Objects.requireNonNull;
 
 /**
  * AbstractEncoder is an {@link Encoder} that implements all of Encoder's 
methods validating the
- * input, but has those methods defer logic to to a new method,
+ * input, but has those methods defer logic to a new method,
  * {@link #decodeUnchecked(byte[], int, int)}.
  *
  * @since 1.7.0