You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ja...@apache.org on 2020/01/20 21:24:13 UTC

[hbase] branch branch-2 updated: HBASE-23625 Reduced number of Checkstyle violations in hbase-common

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

janh pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2 by this push:
     new c165699  HBASE-23625 Reduced number of Checkstyle violations in hbase-common
c165699 is described below

commit c16569996b101a863e60172a593c403cc6d9488f
Author: Jan Hentschel <ja...@apache.org>
AuthorDate: Mon Jan 20 22:24:01 2020 +0100

    HBASE-23625 Reduced number of Checkstyle violations in hbase-common
    
    Signed-off-by: stack <st...@apache.org>
---
 .../java/org/apache/hadoop/hbase/CellScanner.java  |  3 +-
 .../hadoop/hbase/IndividualBytesFieldCell.java     | 54 ++++++-------
 .../hadoop/hbase/util/AbstractByteRange.java       | 41 +++-------
 .../hbase/util/AbstractPositionedByteRange.java    | 91 ++--------------------
 .../org/apache/hadoop/hbase/util/AtomicUtils.java  |  6 +-
 .../hadoop/hbase/util/DynamicClassLoader.java      | 71 +++++++++--------
 .../apache/hadoop/hbase/util/ExceptionUtil.java    | 30 ++++---
 .../java/org/apache/hadoop/hbase/util/Methods.java |  6 +-
 .../java/org/apache/hadoop/hbase/util/Sleeper.java | 12 +--
 .../java/org/apache/hadoop/hbase/util/Strings.java | 14 ++--
 10 files changed, 130 insertions(+), 198 deletions(-)

diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/CellScanner.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/CellScanner.java
index 9d0b8d8..3765f6d 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/CellScanner.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/CellScanner.java
@@ -15,7 +15,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.hadoop.hbase;
 
 import java.io.IOException;
@@ -56,7 +55,7 @@ public interface CellScanner {
   /**
    * Advance the scanner 1 cell.
    * @return true if the next cell is found and {@link #current()} will return a valid Cell
-   * @throws IOException
+   * @throws IOException if advancing the scanner fails
    */
   boolean advance() throws IOException;
 }
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/IndividualBytesFieldCell.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/IndividualBytesFieldCell.java
index e477023..3b48bf4 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/IndividualBytesFieldCell.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/IndividualBytesFieldCell.java
@@ -15,7 +15,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.hadoop.hbase;
 
 import org.apache.commons.lang3.ArrayUtils;
@@ -25,12 +24,14 @@ import org.apache.yetus.audience.InterfaceAudience;
 
 @InterfaceAudience.Private
 public class IndividualBytesFieldCell implements ExtendedCell, Cloneable {
-
-  private static final long FIXED_OVERHEAD = ClassSize.align(  // do alignment(padding gap)
-        ClassSize.OBJECT              // object header
-      + KeyValue.TIMESTAMP_TYPE_SIZE  // timestamp and type
-      + Bytes.SIZEOF_LONG             // sequence id
-      + 5 * ClassSize.REFERENCE);     // references to all byte arrays: row, family, qualifier, value, tags
+  // do alignment(padding gap)
+  private static final long FIXED_OVERHEAD = ClassSize.align(ClassSize.OBJECT // object header
+    // timestamp and type
+    + KeyValue.TIMESTAMP_TYPE_SIZE
+    // sequence id
+    + Bytes.SIZEOF_LONG
+    // references to all byte arrays: row, family, qualifier, value, tags
+    + 5 * ClassSize.REFERENCE);
 
   // The following fields are backed by individual byte arrays
   private final byte[] row;
@@ -54,13 +55,13 @@ public class IndividualBytesFieldCell implements ExtendedCell, Cloneable {
   private final byte type;  // A byte, rather than org.apache.hadoop.hbase.KeyValue.Type
   private long seqId;
 
-  public IndividualBytesFieldCell(byte[] row, byte[] family, byte[] qualifier,
-                                  long timestamp, KeyValue.Type type,  byte[] value) {
+  public IndividualBytesFieldCell(byte[] row, byte[] family, byte[] qualifier, long timestamp,
+      KeyValue.Type type,  byte[] value) {
     this(row, family, qualifier, timestamp, type, 0L /* sequence id */, value, null /* tags */);
   }
 
-  public IndividualBytesFieldCell(byte[] row, byte[] family, byte[] qualifier,
-                                  long timestamp, KeyValue.Type type, long seqId, byte[] value, byte[] tags) {
+  public IndividualBytesFieldCell(byte[] row, byte[] family, byte[] qualifier, long timestamp,
+      KeyValue.Type type, long seqId, byte[] value, byte[] tags) {
     this(row, 0, ArrayUtils.getLength(row),
             family, 0, ArrayUtils.getLength(family),
             qualifier, 0, ArrayUtils.getLength(qualifier),
@@ -69,13 +70,10 @@ public class IndividualBytesFieldCell implements ExtendedCell, Cloneable {
             tags, 0, ArrayUtils.getLength(tags));
   }
 
-  public IndividualBytesFieldCell(byte[] row, int rOffset, int rLength,
-                                  byte[] family, int fOffset, int fLength,
-                                  byte[] qualifier, int qOffset, int qLength,
-                                  long timestamp, KeyValue.Type type, long seqId,
-                                  byte[] value, int vOffset, int vLength,
-                                  byte[] tags, int tagsOffset, int tagsLength) {
-
+  public IndividualBytesFieldCell(byte[] row, int rOffset, int rLength, byte[] family, int fOffset,
+      int fLength, byte[] qualifier, int qOffset, int qLength, long timestamp, KeyValue.Type type,
+      long seqId, byte[] value, int vOffset, int vLength, byte[] tags, int tagsOffset,
+      int tagsLength) {
     // Check row, family, qualifier and value
     KeyValue.checkParameters(row, rLength,     // row and row length
                              family, fLength,  // family and family length
@@ -119,10 +117,12 @@ public class IndividualBytesFieldCell implements ExtendedCell, Cloneable {
 
   private void checkArrayBounds(byte[] bytes, int offset, int length) {
     if (offset < 0 || length < 0) {
-      throw new IllegalArgumentException("Negative number! offset=" + offset + "and length=" + length);
+      throw new IllegalArgumentException("Negative number! offset=" + offset + "and length="
+        + length);
     }
     if (bytes == null && (offset != 0 || length != 0)) {
-      throw new IllegalArgumentException("Null bytes array but offset=" + offset + "and length=" + length);
+      throw new IllegalArgumentException("Null bytes array but offset=" + offset + "and length="
+        + length);
     }
     if (bytes != null && bytes.length < offset + length) {
       throw new IllegalArgumentException("Out of bounds! bytes.length=" + bytes.length
@@ -131,7 +131,7 @@ public class IndividualBytesFieldCell implements ExtendedCell, Cloneable {
   }
 
   private long heapOverhead() {
-    return   FIXED_OVERHEAD
+    return FIXED_OVERHEAD
            + ClassSize.ARRAY                               // row      , can not be null
            + ((family    == null) ? 0 : ClassSize.ARRAY)   // family   , can be null
            + ((qualifier == null) ? 0 : ClassSize.ARRAY)   // qualifier, can be null
@@ -152,13 +152,14 @@ public class IndividualBytesFieldCell implements ExtendedCell, Cloneable {
 
   @Override
   public int getRowOffset() {
-        return rOffset;
-    }
+    return rOffset;
+  }
 
   @Override
   public short getRowLength() {
-    // If row is null or rLength is invalid, the constructor will reject it, by {@link KeyValue#checkParameters()},
-    // so it is safe to call rLength and make the type conversion.
+    // If row is null or rLength is invalid, the constructor will reject it, by
+    // {@link KeyValue#checkParameters()}, so it is safe to call rLength and make the type
+    // conversion.
     return (short)(rLength);
   }
 
@@ -255,7 +256,8 @@ public class IndividualBytesFieldCell implements ExtendedCell, Cloneable {
    */
   @Override
   public long heapSize() {
-    // Size of array headers are already included into overhead, so do not need to include it for each byte array
+    // Size of array headers are already included into overhead, so do not need to include it for
+    // each byte array
     return   heapOverhead()                         // overhead, with array headers included
            + ClassSize.align(getRowLength())        // row
            + ClassSize.align(getFamilyLength())     // family
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/AbstractByteRange.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/AbstractByteRange.java
index 47c59a1..749d0fa 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/AbstractByteRange.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/AbstractByteRange.java
@@ -59,7 +59,6 @@ import org.apache.yetus.audience.InterfaceStability;
 @InterfaceAudience.Private
 @InterfaceStability.Evolving
 public abstract class AbstractByteRange implements ByteRange {
-
   public static final int UNSET_HASH_VALUE = -1;
 
   // Note to maintainers: Do not make these final, as the intention is to
@@ -96,17 +95,16 @@ public abstract class AbstractByteRange implements ByteRange {
   }
 
   @Override
-  public abstract ByteRange unset();
-
-  @Override
   public ByteRange set(int capacity) {
     return set(new byte[capacity]);
   }
 
   @Override
   public ByteRange set(byte[] bytes) {
-    if (null == bytes)
+    if (null == bytes) {
       return unset();
+    }
+
     clearHashCache();
     this.bytes = bytes;
     this.offset = 0;
@@ -116,8 +114,10 @@ public abstract class AbstractByteRange implements ByteRange {
 
   @Override
   public ByteRange set(byte[] bytes, int offset, int length) {
-    if (null == bytes)
+    if (null == bytes) {
       return unset();
+    }
+
     clearHashCache();
     this.bytes = bytes;
     this.offset = offset;
@@ -172,15 +172,19 @@ public abstract class AbstractByteRange implements ByteRange {
 
   @Override
   public ByteRange get(int index, byte[] dst) {
-    if (0 == dst.length)
+    if (0 == dst.length) {
       return this;
+    }
+
     return get(index, dst, 0, dst.length);
   }
 
   @Override
   public ByteRange get(int index, byte[] dst, int offset, int length) {
-    if (0 == length)
+    if (0 == length) {
       return this;
+    }
+
     System.arraycopy(this.bytes, this.offset + index, dst, offset, length);
     return this;
   }
@@ -243,27 +247,6 @@ public abstract class AbstractByteRange implements ByteRange {
     return rPos + 1;
   }
 
-  @Override
-  public abstract ByteRange put(int index, byte val);
-
-  @Override
-  public abstract ByteRange put(int index, byte[] val);
-
-  @Override
-  public abstract ByteRange put(int index, byte[] val, int offset, int length);
-
-  @Override
-  public abstract ByteRange putInt(int index, int val);
-
-  @Override
-  public abstract ByteRange putLong(int index, long val);
-
-  @Override
-  public abstract ByteRange putShort(int index, short val);
-
-  @Override
-  public abstract int putVLong(int index, long val);
-
   //
   // methods for duplicating the current instance
   //
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/AbstractPositionedByteRange.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/AbstractPositionedByteRange.java
index 175da02..bd28483 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/AbstractPositionedByteRange.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/AbstractPositionedByteRange.java
@@ -17,12 +17,9 @@
  */
 package org.apache.hadoop.hbase.util;
 
-
 import org.apache.yetus.audience.InterfaceAudience;
 import org.apache.yetus.audience.InterfaceStability;
 
-import org.apache.hbase.thirdparty.com.google.common.annotations.VisibleForTesting;
-
 /**
  * Extends the basic {@link SimpleByteRange} implementation with position
  * support. {@code position} is considered transient, not fundamental to the
@@ -49,9 +46,6 @@ public abstract class AbstractPositionedByteRange extends AbstractByteRange impl
   protected int limit = 0;
 
   @Override
-  public abstract PositionedByteRange unset();
-
-  @Override
   public PositionedByteRange set(int capacity) {
     this.position = 0;
     super.set(capacity);
@@ -134,77 +128,24 @@ public abstract class AbstractPositionedByteRange extends AbstractByteRange impl
 
   @Override
   public PositionedByteRange get(byte[] dst) {
-    if (0 == dst.length)
+    if (0 == dst.length) {
       return this;
-    return this.get(dst, 0, dst.length); // be clear we're calling self, not
-                                         // super
+    }
+
+    return this.get(dst, 0, dst.length); // be clear we're calling self, not super
   }
 
   @Override
   public PositionedByteRange get(byte[] dst, int offset, int length) {
-    if (0 == length)
+    if (0 == length) {
       return this;
+    }
+
     super.get(this.position, dst, offset, length);
     this.position += length;
     return this;
   }
 
-  @Override
-  public abstract PositionedByteRange put(byte val);
-
-  @Override
-  public abstract PositionedByteRange put(byte[] val);
-
-  @Override
-  public abstract PositionedByteRange put(byte[] val, int offset, int length);
-
-  @Override
-  public abstract PositionedByteRange putInt(int index, int val);
-
-  @Override
-  public abstract PositionedByteRange putLong(int index, long val);
-
-  @Override
-  public abstract PositionedByteRange putShort(int index, short val);
-
-  @Override
-  public abstract PositionedByteRange putInt(int val);
-
-  @Override
-  public abstract PositionedByteRange putLong(long val);
-
-  @Override
-  public abstract PositionedByteRange putShort(short val);
-
-  @Override
-  public abstract int putVLong(int index, long val);
-
-  @Override
-  public abstract int putVLong(long val);
-  /**
-   * Similar to {@link java.nio.ByteBuffer#flip()}. Sets length to position, position to
-   * offset.
-   */
-  @VisibleForTesting
-  PositionedByteRange flip() {
-    clearHashCache();
-    length = position;
-    position = offset;
-    return this;
-  }
-
-  /**
-   * Similar to {@link java.nio.ByteBuffer#clear()}. Sets position to 0, length to
-   * capacity.
-   */
-  @VisibleForTesting
-  PositionedByteRange clear() {
-    clearHashCache();
-    position = 0;
-    length = bytes.length - offset;
-    return this;
-  }
-
   // java boilerplate
 
   @Override
@@ -248,24 +189,6 @@ public abstract class AbstractPositionedByteRange extends AbstractByteRange impl
   }
 
   @Override
-  public abstract PositionedByteRange put(int index, byte val);
-
-  @Override
-  public abstract PositionedByteRange put(int index, byte[] val);
-
-  @Override
-  public abstract PositionedByteRange put(int index, byte[] val, int offset, int length);
-
-  @Override
-  public abstract PositionedByteRange deepCopy();
-
-  @Override
-  public abstract PositionedByteRange shallowCopy();
-
-  @Override
-  public abstract PositionedByteRange shallowCopySubRange(int innerOffset, int copyLength);
-
-  @Override
   public PositionedByteRange setLimit(int limit) {
     this.limit = limit;
     return this;
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/AtomicUtils.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/AtomicUtils.java
index c3cf8b5..65d2611 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/AtomicUtils.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/AtomicUtils.java
@@ -25,7 +25,10 @@ import org.apache.yetus.audience.InterfaceAudience;
  * Utilities related to atomic operations.
  */
 @InterfaceAudience.Private
-public class AtomicUtils {
+public final class AtomicUtils {
+  private AtomicUtils() {
+  }
+
   /**
    * Updates a AtomicLong which is supposed to maintain the minimum values. This method is not
    * synchronized but is thread-safe.
@@ -59,5 +62,4 @@ public class AtomicUtils {
       }
     }
   }
-
 }
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/DynamicClassLoader.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/DynamicClassLoader.java
index e769e7f..9c242ab 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/DynamicClassLoader.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/DynamicClassLoader.java
@@ -57,8 +57,7 @@ import org.slf4j.LoggerFactory;
  */
 @InterfaceAudience.Private
 public class DynamicClassLoader extends ClassLoaderBase {
-  private static final Logger LOG =
-      LoggerFactory.getLogger(DynamicClassLoader.class);
+  private static final Logger LOG = LoggerFactory.getLogger(DynamicClassLoader.class);
 
   // Dynamic jars are put under ${hbase.local.dir}/jars/
   private static final String DYNAMIC_JARS_DIR = File.separator
@@ -90,8 +89,7 @@ public class DynamicClassLoader extends ClassLoaderBase {
    * @param conf the configuration for the cluster.
    * @param parent the parent ClassLoader to set.
    */
-  public DynamicClassLoader(
-      final Configuration conf, final ClassLoader parent) {
+  public DynamicClassLoader(final Configuration conf, final ClassLoader parent) {
     super(parent);
 
     // Save off the user's original configuration value for the DynamicClassLoader
@@ -158,38 +156,40 @@ public class DynamicClassLoader extends ClassLoaderBase {
     }
   }
 
-
-  private Class<?> tryRefreshClass(String name)
-      throws ClassNotFoundException {
+  private Class<?> tryRefreshClass(String name) throws ClassNotFoundException {
     synchronized (getClassLoadingLock(name)) {
-        // Check whether the class has already been loaded:
-        Class<?> clasz = findLoadedClass(name);
-        if (clasz != null) {
+      // Check whether the class has already been loaded:
+      Class<?> clasz = findLoadedClass(name);
+
+      if (clasz != null) {
+        if (LOG.isDebugEnabled()) {
+          LOG.debug("Class {} already loaded", name);
+        }
+      } else {
+        try {
           if (LOG.isDebugEnabled()) {
-            LOG.debug("Class " + name + " already loaded");
+            LOG.debug("Finding class: {}", name);
           }
-        }
-        else {
-          try {
-            if (LOG.isDebugEnabled()) {
-              LOG.debug("Finding class: " + name);
-            }
-            clasz = findClass(name);
-          } catch (ClassNotFoundException cnfe) {
-            // Load new jar files if any
-            if (LOG.isDebugEnabled()) {
-              LOG.debug("Loading new jar files, if any");
-            }
-            loadNewJars();
 
-            if (LOG.isDebugEnabled()) {
-              LOG.debug("Finding class again: " + name);
-            }
-            clasz = findClass(name);
+          clasz = findClass(name);
+        } catch (ClassNotFoundException cnfe) {
+          // Load new jar files if any
+          if (LOG.isDebugEnabled()) {
+            LOG.debug("Loading new jar files, if any");
           }
+
+          loadNewJars();
+
+          if (LOG.isDebugEnabled()) {
+            LOG.debug("Finding class again: {}", name);
+          }
+
+          clasz = findClass(name);
         }
-        return clasz;
       }
+
+      return clasz;
+    }
   }
 
   private synchronized void loadNewJars() {
@@ -202,7 +202,7 @@ public class DynamicClassLoader extends ClassLoaderBase {
           continue;
         }
         if (file.isFile() && fileName.endsWith(".jar")) {
-          jarModifiedTime.put(fileName, Long.valueOf(file.lastModified()));
+          jarModifiedTime.put(fileName, file.lastModified());
           try {
             URL url = file.toURI().toURL();
             addURL(url);
@@ -228,19 +228,22 @@ public class DynamicClassLoader extends ClassLoaderBase {
     }
 
     for (FileStatus status: statuses) {
-      if (status.isDirectory()) continue; // No recursive lookup
+      if (status.isDirectory()) {
+        continue; // No recursive lookup
+      }
+
       Path path = status.getPath();
       String fileName = path.getName();
       if (!fileName.endsWith(".jar")) {
         if (LOG.isDebugEnabled()) {
-          LOG.debug("Ignored non-jar file " + fileName);
+          LOG.debug("Ignored non-jar file {}", fileName);
         }
         continue; // Ignore non-jar files
       }
       Long cachedLastModificationTime = jarModifiedTime.get(fileName);
       if (cachedLastModificationTime != null) {
         long lastModified = status.getModificationTime();
-        if (lastModified < cachedLastModificationTime.longValue()) {
+        if (lastModified < cachedLastModificationTime) {
           // There could be some race, for example, someone uploads
           // a new one right in the middle the old one is copied to
           // local. We can check the size as well. But it is still
@@ -255,7 +258,7 @@ public class DynamicClassLoader extends ClassLoaderBase {
         // Copy it to local
         File dst = new File(localDir, fileName);
         remoteDirFs.copyToLocalFile(path, new Path(dst.getPath()));
-        jarModifiedTime.put(fileName, Long.valueOf(dst.lastModified()));
+        jarModifiedTime.put(fileName, dst.lastModified());
         URL url = dst.toURI().toURL();
         addURL(url);
       } catch (IOException ioe) {
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ExceptionUtil.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ExceptionUtil.java
index bca9e2f..9f6b5c5 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ExceptionUtil.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ExceptionUtil.java
@@ -34,14 +34,22 @@ import org.apache.yetus.audience.InterfaceAudience;
  * interruption, so we have to distinguish the case. This pattern is unfortunately common.
  */
 @InterfaceAudience.Private
-public class ExceptionUtil {
+public final class ExceptionUtil {
+  private ExceptionUtil() {
+  }
 
   /**
    * @return true if the throwable comes an interruption, false otherwise.
    */
   public static boolean isInterrupt(Throwable t) {
-    if (t instanceof InterruptedException) return true;
-    if (t instanceof SocketTimeoutException) return false;
+    if (t instanceof InterruptedException) {
+      return true;
+    }
+
+    if (t instanceof SocketTimeoutException) {
+      return false;
+    }
+
     return (t instanceof InterruptedIOException || t instanceof ClosedByInterruptException);
   }
 
@@ -50,16 +58,23 @@ public class ExceptionUtil {
    */
   public static void rethrowIfInterrupt(Throwable t) throws InterruptedIOException {
     InterruptedIOException iie = asInterrupt(t);
-    if (iie != null) throw iie;
+
+    if (iie != null) {
+      throw iie;
+    }
   }
 
   /**
    * @return an InterruptedIOException if t was an interruption, null otherwise
    */
   public static InterruptedIOException asInterrupt(Throwable t) {
-    if (t instanceof SocketTimeoutException) return null;
+    if (t instanceof SocketTimeoutException) {
+      return null;
+    }
 
-    if (t instanceof InterruptedIOException) return (InterruptedIOException) t;
+    if (t instanceof InterruptedIOException) {
+      return (InterruptedIOException) t;
+    }
 
     if (t instanceof InterruptedException || t instanceof ClosedByInterruptException) {
       InterruptedIOException iie =
@@ -70,7 +85,4 @@ public class ExceptionUtil {
 
     return null;
   }
-
-  private ExceptionUtil() {
-  }
 }
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Methods.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Methods.java
index 6e472a0..32a007b 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Methods.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Methods.java
@@ -17,7 +17,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.hadoop.hbase.util;
 
 import java.lang.reflect.InvocationTargetException;
@@ -30,9 +29,12 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 @InterfaceAudience.Private
-public class Methods {
+public final class Methods {
   private static final Logger LOG = LoggerFactory.getLogger(Methods.class);
 
+  private Methods() {
+  }
+
   public static <T> Object call(Class<T> clazz, T instance, String methodName,
       Class[] types, Object[] args) throws Exception {
     try {
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Sleeper.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Sleeper.java
index 93ef08c..54accef 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Sleeper.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Sleeper.java
@@ -42,7 +42,7 @@ public class Sleeper {
   /**
    * @param sleep sleep time in milliseconds
    * @param stopper When {@link Stoppable#isStopped()} is true, this thread will
-   * cleanup and exit cleanly.
+   *    cleanup and exit cleanly.
    */
   public Sleeper(final int sleep, final Stoppable stopper) {
     this.period = sleep;
@@ -77,16 +77,18 @@ public class Sleeper {
       long woke = -1;
       try {
         synchronized (sleepLock) {
-          if (triggerWake) break;
+          if (triggerWake) {
+            break;
+          }
+
           sleepLock.wait(currentSleepTime);
         }
         woke = System.currentTimeMillis();
         long slept = woke - now;
         if (slept - this.period > MINIMAL_DELTA_FOR_LOGGING) {
-          LOG.warn("We slept " + slept + "ms instead of " + this.period +
-              "ms, this is likely due to a long " +
+          LOG.warn("We slept {}ms instead of {}ms, this is likely due to a long " +
               "garbage collecting pause and it's usually bad, see " +
-              "http://hbase.apache.org/book.html#trouble.rs.runtime.zkexpired");
+              "http://hbase.apache.org/book.html#trouble.rs.runtime.zkexpired", slept, this.period);
         }
       } catch(InterruptedException iex) {
         // We we interrupted because we're meant to stop?  If not, just
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Strings.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Strings.java
index 033d3ec..0a39dca 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Strings.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Strings.java
@@ -25,9 +25,12 @@ import org.apache.yetus.audience.InterfaceAudience;
  * Utility for Strings.
  */
 @InterfaceAudience.Private
-public class Strings {
-  public final static String DEFAULT_SEPARATOR = "=";
-  public final static String DEFAULT_KEYVALUE_SEPARATOR = ", ";
+public final class Strings {
+  public static final String DEFAULT_SEPARATOR = "=";
+  public static final String DEFAULT_KEYVALUE_SEPARATOR = ", ";
+
+  private Strings() {
+  }
 
   /**
    * Append to a StringBuilder a key/value.
@@ -68,11 +71,12 @@ public class Strings {
    * host.example.com
    * @param dnPtr a domain name pointer (PTR) string.
    * @return Sanitized hostname with last period stripped off.
-   *
    */
   public static String domainNamePointerToHostName(String dnPtr) {
-    if (dnPtr == null)
+    if (dnPtr == null) {
       return null;
+    }
+
     return dnPtr.endsWith(".") ? dnPtr.substring(0, dnPtr.length()-1) : dnPtr;
   }