Skip to content

Commit

Permalink
Address ErrorProne errors
Browse files Browse the repository at this point in the history
  • Loading branch information
olim7t committed Jan 24, 2018
1 parent 6a51aab commit adebb92
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 19 deletions.
Expand Up @@ -271,7 +271,7 @@ public boolean equals(Object other) {

@Override
public int hashCode() {
return Objects.hash(major, minor, patch, dsePatch, preReleases, build);
return Objects.hash(major, minor, patch, dsePatch, Arrays.hashCode(preReleases), build);
}

@Override
Expand Down
Expand Up @@ -179,6 +179,8 @@ TableMetadata parseTable(
clusteringColumnsBuilder.put(
column, raw.reversed ? ClusteringOrder.DESC : ClusteringOrder.ASC);
break;
default:
// nothing to do
}
allColumnsBuilder.put(column.getName(), column);

Expand Down Expand Up @@ -237,6 +239,9 @@ private void pruneStaticCompactTableColumns(List<RawColumn> columns) {
break;
case STATIC:
column.kind = RawColumn.Kind.REGULAR;
break;
default:
// nothing to do
}
}
}
Expand Down
Expand Up @@ -116,6 +116,8 @@ ViewMetadata parseView(
clusteringColumnsBuilder.put(
column, raw.reversed ? ClusteringOrder.DESC : ClusteringOrder.ASC);
break;
default:
// nothing to do
}
allColumnsBuilder.put(column.getName(), column);
}
Expand Down
Expand Up @@ -106,37 +106,50 @@ private long murmur(ByteBuffer data) {
switch (length & 15) {
case 15:
k2 ^= ((long) data.get(offset + 14)) << 48;
// fall through
case 14:
k2 ^= ((long) data.get(offset + 13)) << 40;
// fall through
case 13:
k2 ^= ((long) data.get(offset + 12)) << 32;
// fall through
case 12:
k2 ^= ((long) data.get(offset + 11)) << 24;
// fall through
case 11:
k2 ^= ((long) data.get(offset + 10)) << 16;
// fall through
case 10:
k2 ^= ((long) data.get(offset + 9)) << 8;
// fall through
case 9:
k2 ^= ((long) data.get(offset + 8));
k2 *= c2;
k2 = rotl64(k2, 33);
k2 *= c1;
h2 ^= k2;

// fall through
case 8:
k1 ^= ((long) data.get(offset + 7)) << 56;
// fall through
case 7:
k1 ^= ((long) data.get(offset + 6)) << 48;
// fall through
case 6:
k1 ^= ((long) data.get(offset + 5)) << 40;
// fall through
case 5:
k1 ^= ((long) data.get(offset + 4)) << 32;
// fall through
case 4:
k1 ^= ((long) data.get(offset + 3)) << 24;
// fall through
case 3:
k1 ^= ((long) data.get(offset + 2)) << 16;
// fall through
case 2:
k1 ^= ((long) data.get(offset + 1)) << 8;
// fall through
case 1:
k1 ^= ((long) data.get(offset));
k1 *= c1;
Expand Down
Expand Up @@ -67,21 +67,25 @@ public DefaultCodecRegistry(
if (cacheWeigher != null) {
cacheBuilder.weigher(cacheWeigher::apply).maximumWeight(maximumCacheWeight);
}
CacheLoader<CacheKey, TypeCodec<?>> cacheLoader =
new CacheLoader<CacheKey, TypeCodec<?>>() {
@Override
public TypeCodec<?> load(CacheKey key) throws Exception {
return createCodec(key.cqlType, key.javaType);
}
};
if (cacheRemovalListener != null) {
//noinspection ResultOfMethodCallIgnored
cacheBuilder.removalListener(
(RemovalListener<CacheKey, TypeCodec<?>>)
notification ->
cacheRemovalListener.accept(notification.getKey(), notification.getValue()));
this.cache =
cacheBuilder
.removalListener(
(RemovalListener<CacheKey, TypeCodec<?>>)
notification ->
cacheRemovalListener.accept(
notification.getKey(), notification.getValue()))
.build(cacheLoader);
} else {
this.cache = cacheBuilder.build(cacheLoader);
}
this.cache =
cacheBuilder.build(
new CacheLoader<CacheKey, TypeCodec<?>>() {
@Override
public TypeCodec<?> load(CacheKey key) throws Exception {
return createCodec(key.cqlType, key.javaType);
}
});
}

public DefaultCodecRegistry(String logPrefix, TypeCodec<?>... userCodecs) {
Expand Down
Expand Up @@ -74,7 +74,7 @@ void onReleaseLock(LazyReference<?> reference) {
synchronized (this) {
Thread me = Thread.currentThread();
LOG.debug("{} is done initializing {}", me, reference.getName());
graph.removeEdge(reference.getName(), me);
graph.removeEdge(reference.getName(), me.getName());
}
}
}
Expand Down
Expand Up @@ -150,7 +150,7 @@ public void should_parse_tuple() {
TupleValue tuple = parse("(1,NULL,'a')");

assertThat(tuple.getInt(0)).isEqualTo(1);
assertThat(tuple.isNull(1));
assertThat(tuple.isNull(1)).isTrue();
assertThat(tuple.getString(2)).isEqualTo("a");

Mockito.verify(intCodec).parse("1");
Expand Down
Expand Up @@ -159,7 +159,7 @@ public void should_parse_udt() {
UdtValue udt = parse("{field1:1,field2:NULL,field3:'a'}");

assertThat(udt.getInt(0)).isEqualTo(1);
assertThat(udt.isNull(1));
assertThat(udt.isNull(1)).isTrue();
assertThat(udt.getString(2)).isEqualTo("a");

Mockito.verify(intCodec).parse("1");
Expand Down
Expand Up @@ -503,6 +503,7 @@ private static <S extends SettableByIndex<S>> S setValue(
bs = bs.setCqlDuration(index, (CqlDuration) value);
break;
}
// fall through
case ProtocolConstants.DataType.LIST:
case ProtocolConstants.DataType.SET:
case ProtocolConstants.DataType.MAP:
Expand Down Expand Up @@ -593,6 +594,7 @@ private static <S extends SettableByName<S>> S setValue(
bs = bs.setCqlDuration(name, (CqlDuration) value);
break;
}
// fall through
case ProtocolConstants.DataType.LIST:
case ProtocolConstants.DataType.SET:
case ProtocolConstants.DataType.MAP:
Expand Down Expand Up @@ -702,6 +704,7 @@ private <K> void readValue(
assertThat(row.getCqlDuration(0)).isEqualTo(expectedValue);
break;
}
// fall through
case ProtocolConstants.DataType.LIST:
case ProtocolConstants.DataType.MAP:
case ProtocolConstants.DataType.SET:
Expand Down
Expand Up @@ -340,7 +340,7 @@ public void should_be_able_to_register_and_use_custom_codec_with_generic_type()
// next row (at key 1) should be absent (null value).
row = rows.next();
// value should be null.
assertThat(row.isNull(0));
assertThat(row.isNull(0)).isTrue();
// getting with codec should return Optional.empty()
assertThat(row.get(0, optionalMapCodec.getJavaType())).isEqualTo(absentMap);
// getting with map should return an empty map.
Expand Down

0 comments on commit adebb92

Please sign in to comment.