Skip to content

Commit

Permalink
HBASE-20707 Move MissingSwitchDefault case check
Browse files Browse the repository at this point in the history
Perform this check using error-prone instead of checkstyle because the
former can handle enum switches somewhat more intelligently.
  • Loading branch information
madrob committed Jun 11, 2018
1 parent 573b57d commit eb13cdd
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions hbase-build-configuration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
<arg>-XepDisableWarningsInGeneratedCode</arg>
<arg>-Xep:FallThrough:OFF</arg> <!-- already in findbugs -->
<arg>-Xep:ClassNewInstance:ERROR</arg>
<arg>-Xep:MissingDefault:ERROR</arg>
</compilerArgs>
<annotationProcessorPaths>
<path>
Expand Down
1 change: 0 additions & 1 deletion hbase-checkstyle/src/main/resources/hbase/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
<module name="EqualsHashCode"/>
<module name="IllegalInstantiation"/>
<module name="InnerAssignment"/>
<module name="MissingSwitchDefault"/>
<module name="NoFinalizer"/>

<!-- Import Checks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public static void main(String[] args) throws IOException {
* <p>Use for hash table lookup, or anything where one collision in 2^^32 is
* acceptable. Do NOT use for cryptographic purposes.
*/
@SuppressWarnings("fallthrough")
@SuppressWarnings({"fallthrough", "MissingDefault"})
@Override
public <T> int hash(HashKey<T> hashKey, int initval) {
int length = hashKey.length();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ public <T> int hash(HashKey<T> hashKey, int initval) {
k1 = (k1 << 15) | (k1 >>> 17); // ROTL32(k1,15);
k1 *= c2;
h1 ^= k1;
default:
// fall out
}

// finalization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@ private static Operator getOperator(byte op) {
return Operator.OR;
case NOT:
return Operator.NOT;
default:
return null;
}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ protected List<Pair<ServerName, Long>> getDeadServers(long since) {
@Test
public void testMaxSend() {
ClusterStatusPublisher csp = new ClusterStatusPublisher() {
@SuppressWarnings("MissingDefault")
@Override
protected List<Pair<ServerName, Long>> getDeadServers(long since) {
List<Pair<ServerName, Long>> res = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,8 @@ public ExecuteProceduresResponse sendRequest(ServerName server, ExecuteProcedure
case 0: throw new ServerNotRunningYetException("wait on server startup");
case 1: throw new SocketTimeoutException("simulate socket timeout");
case 2: throw new RemoteException("java.io.IOException", "unexpected exception");
default:
// fall out
}
return super.sendRequest(server, req);
}
Expand All @@ -785,6 +787,8 @@ protected RegionOpeningState execOpenRegion(final ServerName server, RegionOpenI
LOG.info("Return transition report that FAILED_OPEN/FAILED_OPENING response");
sendTransitionReport(server, openReq.getRegion(), TransitionCode.FAILED_OPEN);
return OpenRegionResponse.RegionOpeningState.FAILED_OPENING;
default:
// fall out
}
// The procedure on master will just hang forever because nothing comes back
// from the RS in this case.
Expand Down

0 comments on commit eb13cdd

Please sign in to comment.