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

mwalch 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 a72c863  Fix more lgtm.com warnings (#974)
a72c863 is described below

commit a72c863a6d36142c48a7e4fabbe236bac4d294ec
Author: Mike Walch <mwa...@apache.org>
AuthorDate: Thu Feb 21 16:56:14 2019 -0500

    Fix more lgtm.com warnings (#974)
    
    * Remove synchronized from getAuthorizations() in ScannerOptions
    * Added synchronized to methods that override a sychonrized method
    * Stop overriding Thread.start() in Proxy
---
 .../accumulo/core/clientImpl/ScannerOptions.java    |  2 +-
 .../core/crypto/streams/NoFlushOutputStream.java    |  2 +-
 .../impl/SeekableByteArrayInputStream.java          |  4 ++--
 .../file/streams/BoundedRangeFileInputStream.java   |  4 ++--
 .../core/file/streams/RateLimitedOutputStream.java  |  4 ++--
 .../main/java/org/apache/accumulo/proxy/Proxy.java  | 21 +++++++++------------
 6 files changed, 17 insertions(+), 20 deletions(-)

diff --git 
a/core/src/main/java/org/apache/accumulo/core/clientImpl/ScannerOptions.java 
b/core/src/main/java/org/apache/accumulo/core/clientImpl/ScannerOptions.java
index 71c7900..d578bdc 100644
--- a/core/src/main/java/org/apache/accumulo/core/clientImpl/ScannerOptions.java
+++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/ScannerOptions.java
@@ -219,7 +219,7 @@ public class ScannerOptions implements ScannerBase {
   }
 
   @Override
-  public synchronized Authorizations getAuthorizations() {
+  public Authorizations getAuthorizations() {
     throw new UnsupportedOperationException("No authorizations to return");
   }
 
diff --git 
a/core/src/main/java/org/apache/accumulo/core/crypto/streams/NoFlushOutputStream.java
 
b/core/src/main/java/org/apache/accumulo/core/crypto/streams/NoFlushOutputStream.java
index cea7798..1bff099 100644
--- 
a/core/src/main/java/org/apache/accumulo/core/crypto/streams/NoFlushOutputStream.java
+++ 
b/core/src/main/java/org/apache/accumulo/core/crypto/streams/NoFlushOutputStream.java
@@ -31,7 +31,7 @@ public class NoFlushOutputStream extends DataOutputStream {
    * calls write a single byte at a time and will kill performance.
    */
   @Override
-  public void write(byte[] b, int off, int len) throws IOException {
+  public synchronized void write(byte[] b, int off, int len) throws 
IOException {
     out.write(b, off, len);
   }
 
diff --git 
a/core/src/main/java/org/apache/accumulo/core/file/blockfile/impl/SeekableByteArrayInputStream.java
 
b/core/src/main/java/org/apache/accumulo/core/file/blockfile/impl/SeekableByteArrayInputStream.java
index 928c550..773a921 100644
--- 
a/core/src/main/java/org/apache/accumulo/core/file/blockfile/impl/SeekableByteArrayInputStream.java
+++ 
b/core/src/main/java/org/apache/accumulo/core/file/blockfile/impl/SeekableByteArrayInputStream.java
@@ -106,12 +106,12 @@ public class SeekableByteArrayInputStream extends 
InputStream {
   }
 
   @Override
-  public void mark(int readAheadLimit) {
+  public synchronized void mark(int readAheadLimit) {
     throw new UnsupportedOperationException();
   }
 
   @Override
-  public void reset() {
+  public synchronized void reset() {
     throw new UnsupportedOperationException();
   }
 
diff --git 
a/core/src/main/java/org/apache/accumulo/core/file/streams/BoundedRangeFileInputStream.java
 
b/core/src/main/java/org/apache/accumulo/core/file/streams/BoundedRangeFileInputStream.java
index 34bd8b4..f40404c 100644
--- 
a/core/src/main/java/org/apache/accumulo/core/file/streams/BoundedRangeFileInputStream.java
+++ 
b/core/src/main/java/org/apache/accumulo/core/file/streams/BoundedRangeFileInputStream.java
@@ -115,12 +115,12 @@ public class BoundedRangeFileInputStream extends 
InputStream {
   }
 
   @Override
-  public void mark(int readlimit) {
+  public synchronized void mark(int readlimit) {
     mark = pos;
   }
 
   @Override
-  public void reset() throws IOException {
+  public synchronized void reset() throws IOException {
     if (mark < 0)
       throw new IOException("Resetting to invalid mark");
     pos = mark;
diff --git 
a/core/src/main/java/org/apache/accumulo/core/file/streams/RateLimitedOutputStream.java
 
b/core/src/main/java/org/apache/accumulo/core/file/streams/RateLimitedOutputStream.java
index 0397092..1fcbbba 100644
--- 
a/core/src/main/java/org/apache/accumulo/core/file/streams/RateLimitedOutputStream.java
+++ 
b/core/src/main/java/org/apache/accumulo/core/file/streams/RateLimitedOutputStream.java
@@ -36,13 +36,13 @@ public class RateLimitedOutputStream extends 
DataOutputStream {
   }
 
   @Override
-  public void write(int i) throws IOException {
+  public synchronized void write(int i) throws IOException {
     writeLimiter.acquire(1);
     out.write(i);
   }
 
   @Override
-  public void write(byte[] buffer, int offset, int length) throws IOException {
+  public synchronized void write(byte[] buffer, int offset, int length) throws 
IOException {
     writeLimiter.acquire(length);
     out.write(buffer, offset, length);
   }
diff --git a/proxy/src/main/java/org/apache/accumulo/proxy/Proxy.java 
b/proxy/src/main/java/org/apache/accumulo/proxy/Proxy.java
index d5ef5cb..b117fee 100644
--- a/proxy/src/main/java/org/apache/accumulo/proxy/Proxy.java
+++ b/proxy/src/main/java/org/apache/accumulo/proxy/Proxy.java
@@ -147,19 +147,16 @@ public class Proxy implements KeywordExecutable {
       final MiniAccumuloCluster accumulo = new MiniAccumuloCluster(folder, 
"secret");
       accumulo.start();
       clientProps = accumulo.getClientProperties();
-      Runtime.getRuntime().addShutdownHook(new Thread() {
-        @Override
-        public void start() {
-          try {
-            accumulo.stop();
-          } catch (Exception e) {
-            throw new RuntimeException();
-          } finally {
-            if (!folder.delete())
-              log.warn("Unexpected error removing {}", folder);
-          }
+      Runtime.getRuntime().addShutdownHook(new Thread(() -> {
+        try {
+          accumulo.stop();
+        } catch (InterruptedException|IOException e) {
+          throw new RuntimeException(e);
+        } finally {
+          if (!folder.delete())
+            log.warn("Unexpected error removing {}", folder);
         }
-      });
+      }));
     } else if (clientProps == null) {
       System.err.println("The '-c' option must be set with an 
accumulo-client.properties file or"
           + " proxy.properties must contain either useMiniAccumulo=true");

Reply via email to