Skip to content

Commit

Permalink
HBASE-20478 Update checkstyle to v8.2
Browse files Browse the repository at this point in the history
Cannot go to latest (8.9) yet due to
  checkstyle/checkstyle#5279

* move hbaseanti import checks to checkstyle
* implment a few missing equals checks, and ignore one
* fix lots of javadoc errors

Signed-off-by: Sean Busbey <busbey@apache.org>
  • Loading branch information
madrob committed May 29, 2018
1 parent 42be553 commit a110e1e
Show file tree
Hide file tree
Showing 43 changed files with 163 additions and 139 deletions.
18 changes: 0 additions & 18 deletions dev-support/hbase-personality.sh
Original file line number Diff line number Diff line change
Expand Up @@ -631,24 +631,6 @@ function hbaseanti_patchfile
((result=result+1))
fi

warnings=$(${GREP} -c 'import org.apache.hadoop.classification' "${patchfile}")
if [[ ${warnings} -gt 0 ]]; then
add_vote_table -1 hbaseanti "" "The patch appears use Hadoop classification instead of HBase."
((result=result+1))
fi

warnings=$(${GREP} -c 'import org.codehaus.jackson' "${patchfile}")
if [[ ${warnings} -gt 0 ]]; then
add_vote_table -1 hbaseanti "" "The patch appears use Jackson 1 classes/annotations."
((result=result+1))
fi

warnings=$(${GREP} -cE 'org.apache.commons.logging.Log(Factory|;)' "${patchfile}")
if [[ ${warnings} -gt 0 ]]; then
add_vote_table -1 hbaseanti "" "The patch appears to use commons-logging instead of slf4j."
((result=result+1))
fi

if [[ ${result} -gt 0 ]]; then
return 1
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public RestoreTablesClient(Connection conn, RestoreRequest request) {
/**
* Validate target tables.
*
* @param tTableArray: target tables
* @param tTableArray target tables
* @param isOverwrite overwrite existing table
* @throws IOException exception
*/
Expand Down Expand Up @@ -123,10 +123,10 @@ private void checkTargetTables(TableName[] tTableArray, boolean isOverwrite) thr
/**
* Restore operation handle each backupImage in array.
*
* @param images: array BackupImage
* @param sTable: table to be restored
* @param tTable: table to be restored to
* @param truncateIfExists: truncate table
* @param images array BackupImage
* @param sTable table to be restored
* @param tTable table to be restored to
* @param truncateIfExists truncate table
* @throws IOException exception
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@
<suppress checks="VisibilityModifier" files=".*/src/test/.*\.java"/>
<suppress checks="InterfaceIsTypeCheck" files=".*/src/main/.*\.java"/>
<suppress checks="EmptyBlockCheck" files="TBoundedThreadPoolServer.java"/>
<suppress checks="EqualsHashCode" files="StartcodeAgnosticServerName.java"/>
</suppressions>
8 changes: 7 additions & 1 deletion hbase-checkstyle/src/main/resources/hbase/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
<module name="VisibilityModifier">
<property name="packageAllowed" value="true"/>
<property name="protectedAllowed" value="true"/>
<property name="allowPublicImmutableFields" value="true"/>
</module>

<!-- Coding Checks
Expand Down Expand Up @@ -85,7 +86,12 @@
org.apache.commons.collections4,
org.apache.commons.lang,
org.apache.curator.shaded,
org.apache.htrace.shaded"/>
org.apache.hadoop.classification,
org.apache.htrace.shaded,
org.codehaus.jackson"/>
<property name="illegalClasses" value="
org.apache.commons.logging.Log,
org.apache.commons.logging.LogFactory"/>
</module>
<!-- Javadoc Checks
http://checkstyle.sourceforge.net/config_javadoc.html -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ RegionLocations locateRegion(TableName tableName, byte[] row, boolean useCache,

/**
* Establishes a connection to the region server at the specified address.
* @param serverName
* @param serverName the region server to connect to
* @return proxy for HRegionServer
* @throws IOException if a remote or network exception occurs
*/
Expand All @@ -242,7 +242,7 @@ RegionLocations locateRegion(TableName tableName, byte[] row, boolean useCache,
* Establishes a connection to the region server at the specified address, and returns
* a region client protocol.
*
* @param serverName
* @param serverName the region server to connect to
* @return ClientProtocol proxy for RegionServer
* @throws IOException if a remote or network exception occurs
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

/**
* Used by {@link org.apache.hadoop.hbase.client.Admin#listReplicatedTableCFs()}.
* The cfs is a map of <ColumnFamily, ReplicationScope>.
* The cfs is a map of &lt;ColumnFamily, ReplicationScope>.
*/
@InterfaceAudience.Public
public class TableCFs {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1559,7 +1559,7 @@ public static ServerInfo getServerInfo(final RpcController controller,


/**
* @see {@link #buildGetServerInfoRequest()}
* @see #buildGetServerInfoRequest()
*/
private static GetServerInfoRequest GET_SERVER_INFO_REQUEST =
GetServerInfoRequest.newBuilder().build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
* <tr><td>u.&lt;user&gt;</td><td>q:s</td><td>&lt;global-quotas&gt;</td></tr>
* <tr><td>u.&lt;user&gt;</td><td>q:s.&lt;table&gt;</td><td>&lt;table-quotas&gt;</td></tr>
* <tr><td>u.&lt;user&gt;</td><td>q:s.&lt;ns&gt;</td><td>&lt;namespace-quotas&gt;</td></tr>
* </table
* </table>
*/
@InterfaceAudience.Private
@InterfaceStability.Evolving
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,7 @@ public static CompactRegionRequest buildCompactRegionRequest(byte[] regionName,
}

/**
* @see {@link #buildRollWALWriterRequest()}
* @see #buildRollWALWriterRequest()
*/
private static RollWALWriterRequest ROLL_WAL_WRITER_REQUEST = RollWALWriterRequest.newBuilder()
.build();
Expand All @@ -1040,7 +1040,7 @@ public static RollWALWriterRequest buildRollWALWriterRequest() {
}

/**
* @see {@link #buildGetServerInfoRequest()}
* @see #buildGetServerInfoRequest()
*/
private static GetServerInfoRequest GET_SERVER_INFO_REQUEST = GetServerInfoRequest.newBuilder()
.build();
Expand Down Expand Up @@ -1522,7 +1522,7 @@ public static GetClusterStatusRequest buildGetClusterStatusRequest(EnumSet<Optio
}

/**
* @see {@link #buildCatalogScanRequest}
* @see #buildCatalogScanRequest
*/
private static final RunCatalogScanRequest CATALOG_SCAN_REQUEST =
RunCatalogScanRequest.newBuilder().build();
Expand All @@ -1544,7 +1544,7 @@ public static EnableCatalogJanitorRequest buildEnableCatalogJanitorRequest(boole
}

/**
* @see {@link #buildIsCatalogJanitorEnabledRequest()}
* @see #buildIsCatalogJanitorEnabledRequest()
*/
private static final IsCatalogJanitorEnabledRequest IS_CATALOG_JANITOR_ENABLED_REQUEST =
IsCatalogJanitorEnabledRequest.newBuilder().build();
Expand All @@ -1558,7 +1558,7 @@ public static IsCatalogJanitorEnabledRequest buildIsCatalogJanitorEnabledRequest
}

/**
* @see {@link #buildCleanerChoreRequest}
* @see #buildRunCleanerChoreRequest()
*/
private static final RunCleanerChoreRequest CLEANER_CHORE_REQUEST =
RunCleanerChoreRequest.newBuilder().build();
Expand All @@ -1580,7 +1580,7 @@ public static SetCleanerChoreRunningRequest buildSetCleanerChoreRunningRequest(b
}

/**
* @see {@link #buildIsCleanerChoreEnabledRequest()}
* @see #buildIsCleanerChoreEnabledRequest()
*/
private static final IsCleanerChoreEnabledRequest IS_CLEANER_CHORE_ENABLED_REQUEST =
IsCleanerChoreEnabledRequest.newBuilder().build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* An immutable type to hold a hostname and port combo, like an Endpoint
* or java.net.InetSocketAddress (but without danger of our calling
* resolve -- we do NOT want a resolve happening every time we want
* to hold a hostname and port combo). This class is also <<Comparable>>.
* to hold a hostname and port combo). This class is also {@link Comparable}
* <p>In implementation this class is a facade over Guava's {@link HostAndPort}.
* We cannot have Guava classes in our API hence this Type.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,20 @@ protected void clearHashCache() {
hash = UNSET_HASH_VALUE;
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof ByteRange)) {
return false;
}
return compareTo((ByteRange) obj) == 0;
}

/**
* Bitwise comparison of each byte in the array. Unsigned comparison, not
* paying attention to java's signed bytes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@
/**
* Utility class for converting objects to JRuby.
*
* It handles null, Boolean, Number, String, byte[], List<Object>, Map<String, Object> structures.
* It handles null, Boolean, Number, String, byte[], List&lt;Object>, Map&lt;String, Object>
* structures.
*
* <p>
* E.g.
* <pre>
* Map<String, Object> map = new LinkedHashMap<>();
* Map&lt;String, Object> map = new LinkedHashMap&lt;>();
* map.put("null", null);
* map.put("boolean", true);
* map.put("number", 1);
Expand All @@ -48,7 +49,8 @@
* <p>
* Calling {@link #print(Object)} method will result:
* <pre>
* { null => '', boolean => 'true', number => '1', string => 'str', binary => '010203', list => [ '1', '2', 'true' ] }
* { null => '', boolean => 'true', number => '1', string => 'str',
* binary => '010203', list => [ '1', '2', 'true' ] }
* </pre>
* </p>
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ private static IllegalArgumentException unexpectedHeader(byte header) {

/**
* Perform unsigned comparison between two long values. Conforms to the same interface as
* {@link org.apache.hadoop.hbase.CellComparator#COMPARATOR#compare(Object, Object)}.
* {@link org.apache.hadoop.hbase.CellComparator}.
*/
private static int unsignedCmp(long x1, long x2) {
int cmp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public static float getWaitForRatio(Configuration conf) {
/**
* A predicate 'closure' used by the {@link Waiter#waitFor(Configuration, long, Predicate)} and
* {@link Waiter#waitFor(Configuration, long, Predicate)} and
* {@link Waiter#waitFor(Configuration, long, long, boolean, Predicate) methods.
* {@link Waiter#waitFor(Configuration, long, long, boolean, Predicate)} methods.
*/
@InterfaceAudience.Private
public interface Predicate<E extends Exception> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ public void prepareBulkLoad(RpcController controller, PrepareBulkLoadRequest req
done.run(null);
}

/**
* Convert from CPEP protobuf 2.5 to internal protobuf 3.3.
*/
org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.PrepareBulkLoadRequest
convert(PrepareBulkLoadRequest request)
throws org.apache.hbase.thirdparty.com.google.protobuf.InvalidProtocolBufferException {
Expand All @@ -121,8 +124,7 @@ public void cleanupBulkLoad(RpcController controller, CleanupBulkLoadRequest req
}

/**
* Convert from CPEP protobuf 2.5 to internal protobuf 3.3.
* @throws org.apache.hbase.thirdparty.com.google.protobuf.InvalidProtocolBufferException
* Convert from CPEP protobuf 2.5 to internal protobuf 3.3.
*/
org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CleanupBulkLoadRequest
convert(CleanupBulkLoadRequest request)
Expand Down Expand Up @@ -153,6 +155,9 @@ public void secureBulkLoadHFiles(RpcController controller, SecureBulkLoadHFilesR
done.run(SecureBulkLoadHFilesResponse.newBuilder().setLoaded(loaded).build());
}

/**
* Convert from CPEP protobuf 2.5 to internal protobuf 3.3.
*/
org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.BulkLoadHFileRequest
convert(BulkLoadHFileRequest request)
throws org.apache.hbase.thirdparty.com.google.protobuf.InvalidProtocolBufferException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,10 @@ public void initFilter(FilterContainer container, Configuration conf) {
* will be accessed as the passed user, by sending user.name request
* parameter.
*
* @param urlstring
* @param userName
* @return
* @throws IOException
* @param urlstring The url to access
* @param userName The user to perform access as
* @return The HTTP response code
* @throws IOException if there is a problem communicating with the server
*/
static int getHttpStatusCode(String urlstring, String userName)
throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@

/**
* Base class for HBase integration tests that want to use the Chaos Monkey.
* Usage: bin/hbase <sub_class_of_IntegrationTestBase> <options>
* Usage: bin/hbase &lt;sub_class_of_IntegrationTestBase> &lt;options>
* Options: -h,--help Show usage
* -m,--monkey <arg> Which chaos monkey to run
* -monkeyProps <arg> The properties file for specifying chaos monkey properties.
* -m,--monkey &lt;arg> Which chaos monkey to run
* -monkeyProps &lt;arg> The properties file for specifying chaos monkey properties.
* -ncc Option to not clean up the cluster at the end.
*/
public abstract class IntegrationTestBase extends AbstractHBaseTool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
* with the replication of the edits before read_delay_ms to the given region replica id so that
* the read and verify will not fail.
*
* The job will run for <b>at least<b> given runtime (default 10min) by running a concurrent
* The job will run for <b>at least</b> given runtime (default 10min) by running a concurrent
* writer and reader workload followed by a concurrent updater and reader workload for
* num_keys_per_server.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ public void before() throws IOException {
/**
* Setup a table with two rows and values.
*
* @param tableName
* @return
* @param tableName the name of the table to create
* @return A Table instance for the created table.
* @throws IOException
*/
public static Table createTable(byte[] tableName) throws IOException {
Expand All @@ -119,7 +119,7 @@ public static Table createTable(byte[] tableName) throws IOException {
* Setup a table with two rows and values per column family.
*
* @param tableName
* @return
* @return A Table instance for the created table.
* @throws IOException
*/
public static Table createTable(byte[] tableName, byte[][] families) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -537,9 +537,9 @@ public void testWithFilter() throws Throwable {
}

/**
* Count the number of keyvalues in the specified table for the given timerange
* @param table
* @return
* Count the number of keyvalues in the specified table with the given filter
* @param table the table to scan
* @return the number of keyvalues found
* @throws IOException
*/
private int getCount(Table table, Filter filter) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void before() throws IOException {
* Setup a table with two rows and values.
*
* @param tableName
* @return
* @return A Table instance for the created table.
* @throws IOException
*/
public static Table createTable(byte[] tableName) throws IOException {
Expand All @@ -116,7 +116,7 @@ public static Table createTable(byte[] tableName) throws IOException {
* Setup a table with two rows and values per column family.
*
* @param tableName
* @return
* @return A Table instance for the created table.
* @throws IOException
*/
public static Table createTable(byte[] tableName, byte[][] families) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -820,10 +820,10 @@ public static void main(String[] args) {
/**
* When NUM_TABLES is specified, the function starts multiple worker threads
* which individually start a LoadTestTool instance to load a table. Each
* table name is in format <tn>_<index>. For example, "-tn test -num_tables 2"
* table name is in format &lt;tn>_&lt;index>. For example, "-tn test -num_tables 2"
* , table names will be "test_1", "test_2"
*
* @throws IOException
* @throws IOException if one of the load tasks is unable to complete
*/
private int parallelLoadTables()
throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,8 @@ public int compareTo(ServerName other) {
public int hashCode() {
return getHostAndPort().hashCode();
}

// Do not need @Override #equals() because super.equals() delegates to compareTo(), which ends
// up doing the right thing. We have a test for it, so the checkstyle warning here would be a
// false positive.
}
Original file line number Diff line number Diff line change
Expand Up @@ -1481,7 +1481,7 @@ void add(byte[] firstKey, long blockOffset, int onDiskDataSize,
* The same as {@link #add(byte[], long, int, long)} but does not take the
* key/value into account. Used for single-level indexes.
*
* @see {@link #add(byte[], long, int, long)}
* @see #add(byte[], long, int, long)
*/
public void add(byte[] firstKey, long blockOffset, int onDiskDataSize) {
add(firstKey, blockOffset, onDiskDataSize, -1);
Expand Down
Loading

0 comments on commit a110e1e

Please sign in to comment.