private static CompressionCodec getCompressor(final Configuration conf) {
    String className = conf.get("hbase.client.rpc.compressor", null);
    if (className == null || className.isEmpty()) {
      return null;
    }
    try {
      return Class.forName(className).asSubclass(CompressionCodec.class).getDeclaredConstructor()
        .newInstance();
    } catch (Exception e) {
      throw new RuntimeException("Failed getting compressor " + className, e);
    }
  }
Encapsulate the ugly casting and RuntimeException conversion in private method.
@param conf configuration
@return The compressor to use on this client.
hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/AbstractRpcClient.java