Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Latest gradle-baseline #6021

Merged
merged 1 commit into from
May 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,8 @@ public boolean shouldBackoff(Exception ex) {
@Override
public long getBackoffPeriod(int numberOfAttempts) {
double randomCoeff = ThreadLocalRandom.current().nextDouble(1 - UNCERTAINTY, 1 + UNCERTAINTY);
return (long) (Math.min(BACKOFF_COEFF * Math.pow(2, numberOfAttempts), MAX_EXPECTED_BACKOFF) * randomCoeff);
return (long) (Math.min(BACKOFF_COEFF * Math.pow(2, numberOfAttempts), (double) MAX_EXPECTED_BACKOFF)
* randomCoeff);
Comment on lines -304 to +305
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From ./gradlew classes testClasses -PerrorProneApply=LongDoubleConversion

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public QueryWeight weighSuccess(T result, long timeTakenNanos) {
@Override
public QueryWeight weighFailure(Exception error, long timeTakenNanos) {
return ImmutableQueryWeight.builder()
.numBytes(ESTIMATED_NUM_BYTES_PER_ROW * numberOfQueriedRows)
.numBytes(ESTIMATED_NUM_BYTES_PER_ROW * ((long) numberOfQueriedRows))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From ./gradlew classes testClasses -PerrorProneApply=NarrowCalculation

.timeTakenNanos(timeTakenNanos)
.numDistinctRows(1)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void queriesGaugesAgainAfterTimeInterval() {

value.set(8);
tick.addAndGet(DistributionOutlierController.REFRESH_INTERVAL.toNanos() + 1);
assertThat(defaultController.getMeanGauge().getValue()).isEqualTo(8L);
assertThat(defaultController.getMeanGauge().getValue()).isEqualTo((double) 8L);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assertThat(defaultController.getMeanGauge().getValue()).isEqualTo((double) 8L);
assertThat(defaultController.getMeanGauge().getValue()).isEqualTo(8.0);

this is fine, and I don't expect us to fix this to get this merged, though this should really be 8.0 (possibly with whatever double equality hacks we need, though none are needed for 8).

More "the existing tests were naughty" rather than anything bad about this change

}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public Set<TableReference> getAllTableNames() {
public Multimap<Cell, Long> getAllTimestamps(TableReference tableRef, Set<Cell> cells, long timestamp) {
return maybeLog(
() -> delegate.getAllTimestamps(tableRef, cells, timestamp),
logCellsAndSize("getAllTimestamps", tableRef, cells.size(), cells.size() * Longs.BYTES));
logCellsAndSize("getAllTimestamps", tableRef, cells.size(), cells.size() * ((long) Longs.BYTES)));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ private void flushTask() {
}
} catch (Throwable t) {
if (!Thread.interrupted()) {
log.warn("Error occurred while flushing sweep stats: {}", UnsafeArg.of("throwable", t), t);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ugh. lol

log.warn("Error occurred while flushing sweep stats", t);
}
}
}
Expand All @@ -283,8 +283,7 @@ private void flushWrites(Multiset<TableReference> writes, Set<TableReference> cl
"Flushing stats for {} writes and {} clears",
SafeArg.of("writes", writes.size()),
SafeArg.of("clears", clears.size()));
log.trace("Flushing writes: {}", UnsafeArg.of("writes", writes));
log.trace("Flushing clears: {}", UnsafeArg.of("clears", clears));
log.trace("Flushing writes: {} and clears: ", UnsafeArg.of("writes", writes), UnsafeArg.of("clears", clears));
try {
Set<TableReference> tableNames = Sets.difference(writes.elementSet(), clears);
Collection<byte[]> rows = Collections2.transform(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public interface SweepTableIdentifier extends Persistable {

@Override
default byte[] persistToBytes() {
return EncodingUtils.encodeSignedVarLong((isPending() ? -1 : 1) * identifier());
return EncodingUtils.encodeSignedVarLong((isPending() ? -1 : 1) * ((long) identifier()));
}

@Value.Check
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ public Namespace getNamespace() {
*
* @param srcDir root source directory where code generation is performed.
*/
@SuppressWarnings("DangerousIdentityKey")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DangerousIdentityKey suppressions lifted directly from #5753

public void renderTables(File srcDir) throws IOException {
com.palantir.logsafe.Preconditions.checkNotNull(name, "schema name not set");
com.palantir.logsafe.Preconditions.checkNotNull(packageName, "package name not set");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.codahale.metrics.SlidingTimeWindowArrayReservoir;
import com.codahale.metrics.Timer;
import com.palantir.logsafe.Preconditions;
import com.palantir.logsafe.UnsafeArg;
import com.palantir.logsafe.logger.SafeLogger;
import com.palantir.logsafe.logger.SafeLoggerFactory;
import com.palantir.tritium.event.AbstractInvocationEventHandler;
Expand Down Expand Up @@ -72,10 +71,7 @@ public void onSuccess(@Nullable InvocationContext context, @Nullable Object resu
public void onFailure(@Nullable InvocationContext context, @Nonnull Throwable cause) {
markGlobalFailure();
if (context == null) {
log.debug(
"Encountered null metric context likely due to exception in preInvocation: {}",
UnsafeArg.of("cause", cause),
cause);
log.debug("Encountered null metric context likely due to exception in preInvocation", cause);
Comment on lines -75 to +74
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DRY: Logging the cause as a throwable provides everything that cause.toString does, and more!

return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import com.palantir.logsafe.Preconditions;
import com.palantir.logsafe.UnsafeArg;
import com.palantir.logsafe.logger.SafeLogger;
import com.palantir.logsafe.logger.SafeLoggerFactory;
import com.palantir.tritium.event.AbstractInvocationEventHandler;
Expand Down Expand Up @@ -165,10 +164,7 @@ interface MethodWithExtraTags {
public void onFailure(@Nullable InvocationContext context, @Nonnull Throwable cause) {
markGlobalFailure();
if (context == null) {
log.debug(
"Encountered null metric context likely due to exception in preInvocation: {}",
UnsafeArg.of("exception", cause),
cause);
log.debug("Encountered null metric context likely due to exception in preInvocation", cause);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ public static <T extends Throwable> T rewrap(T throwable) {
* thread's stack trace. Use this method when you are about to rethrow a throwable from another thread,
* for example when throwing {@link ExecutionException#getCause()} after calling {@link Future#get()};
*/
@SuppressWarnings("LogsafeThrowableArgument")
public static <T extends Throwable> T rewrap(final String newMessage, final T throwable) {
Preconditions.checkNotNull(throwable);
log.info(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static <T> T copy(T orig) {
return copy(orig, (is, codebase) -> new ObjectInputStream(is));
}

@SuppressWarnings("unchecked")
@SuppressWarnings({"unchecked", "DangerousJavaDeserialization"})
public static <T> T copy(T orig, ObjectInputStreamFactory factory) {
T obj = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ public final class ConsistencyCheckRunner extends Callback<TransactionManager> {

private static final SafeLogger log = SafeLoggerFactory.get(ConsistencyCheckRunner.class);

private static final RuntimeException UNKNOWN = new SafeRuntimeException("unknown");

private final List<TransactionManagerConsistencyCheck> consistencyChecks;

@VisibleForTesting
Expand Down Expand Up @@ -76,7 +74,9 @@ private void processAggregatedResult(TransactionManagerConsistencyResult consist
// Errors get bubbled up to the top level
throw new AssertionError(
"AtlasDB found in an unexpected state!",
consistencyResult.reasonForInconsistency().orElse(UNKNOWN));
consistencyResult
.reasonForInconsistency()
.orElseGet(() -> new SafeRuntimeException("unknown")));
case INDETERMINATE:
throw new NotInitializedException("ConsistencyCheckRunner");
case CONSISTENT:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public TableMetadataCache(DbTableFactory dbTables) {
}

@Nullable
@SuppressWarnings("ImmutablesReferenceEquality")
public TableMetadata getTableMetadata(TableReference tableRef, ConnectionSupplier conns) {
TableMetadata metadataOrEmpty = getOrReturnEmpty(tableRef, conns);
if (metadataOrEmpty == EMPTY) {
Expand All @@ -45,6 +46,7 @@ public TableMetadata getTableMetadata(TableReference tableRef, ConnectionSupplie
}
}

@SuppressWarnings("ImmutablesReferenceEquality")
private TableMetadata getOrReturnEmpty(TableReference tableRef, ConnectionSupplier conns) {
TableMetadata cached = cache.getIfPresent(tableRef);
if (cached != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ private CheckAndSetRequest createRequest(ShardAndStrategy shardAndStrategy, long
}
}

@SuppressWarnings("ImmutablesReferenceEquality")
private static boolean isDefaultValue(ShardAndStrategy shardAndStrategy, long oldVal) {
return SweepQueueUtils.firstSweep(oldVal)
|| (shardAndStrategy == SHARD_COUNT_SAS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/
package com.palantir.atlasdb.sweep.queue;

import static com.google.common.base.Preconditions.checkState;

import com.google.common.collect.HashMultimap;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
Expand Down Expand Up @@ -48,6 +46,7 @@
import com.palantir.atlasdb.sweep.queue.id.SweepTableIndices;
import com.palantir.atlasdb.transaction.impl.TransactionConstants;
import com.palantir.atlasdb.transaction.service.TransactionService;
import com.palantir.logsafe.Preconditions;
import com.palantir.logsafe.SafeArg;
import com.palantir.logsafe.logger.SafeLogger;
import com.palantir.logsafe.logger.SafeLoggerFactory;
Expand Down Expand Up @@ -180,7 +179,8 @@ private DedicatedRows getDedicatedRowsToClear(List<SweepableCellsRow> rows, Time
.filter(row -> {
TargetedSweepMetadata metadata =
TargetedSweepMetadata.BYTES_HYDRATOR.hydrateFromBytes(row.getMetadata());
checkState(metadata.dedicatedRow(), "Row not a dedicated row", SafeArg.of("row", row));
Preconditions.checkState(
metadata.dedicatedRow(), "Row not a dedicated row", SafeArg.of("row", row));
return tsToSweep.timestampsDescending().contains(row.getTimestampPartition());
})
.collect(Collectors.toList()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@
import com.palantir.atlasdb.keyvalue.api.KeyAlreadyExistsException;
import com.palantir.common.streams.KeyedStream;
import com.palantir.lock.v2.TimelockService;
import com.palantir.logsafe.Preconditions;
import com.palantir.logsafe.SafeArg;
import com.palantir.logsafe.UnsafeArg;
import com.palantir.logsafe.exceptions.SafeIllegalStateException;
import com.palantir.logsafe.logger.SafeLogger;
import com.palantir.logsafe.logger.SafeLoggerFactory;
Expand Down Expand Up @@ -283,12 +281,13 @@ private static Map<Boolean, List<Long>> classifyTimestampsOnKeySetPresence(
private static Set<Long> getAlreadyExistingStartTimestamps(
EncodingTransactionService delegate, Set<Long> startTimestamps, KeyAlreadyExistsException exception) {
Set<Long> existingTimestamps = decodeCellsToTimestamps(delegate, exception.getExistingKeys());
Preconditions.checkState(
!existingTimestamps.isEmpty(),
"The underlying service threw a KeyAlreadyExistsException, but claimed no keys already existed!"
+ " This is likely to be a product bug - please contact support.",
SafeArg.of("startTimestamps", startTimestamps),
UnsafeArg.of("exception", exception));
if (existingTimestamps.isEmpty()) {
throw new SafeIllegalStateException(
"The underlying service threw a KeyAlreadyExistsException, but claimed no keys already existed!"
+ " This is likely to be a product bug - please contact support.",
exception,
SafeArg.of("startTimestamps", startTimestamps));
}
return existingTimestamps;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ private void writeToQuorum(Cell cell, Set<Node> quorumNodes, byte[] value) {
});
}

@SuppressWarnings("DangerousIdentityKey")
private Set<Node> getQuorumNodes() {
return nodes.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(ArrayList::new), list -> {
Collections.shuffle(list);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public TableMetadata load(String tableName) throws Exception {
}

@CheckForNull
@SuppressWarnings("ImmutablesReferenceEquality")
public TableMetadata getMetadata(String tableName) {
TableMetadata ret = cache.getUnchecked(tableName);
if (ret == EMPTY) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public void testSweepBatches() {

assertThat(sweepResults.getCellTsPairsExamined())
.describedAs("Expected Ts Pairs Examined should add up to entire table (2 values in each cell)")
.isEqualTo(2 * BIG_LIST_OF_CELLS.size());
.isEqualTo(2L * BIG_LIST_OF_CELLS.size());
}

@Test(timeout = 50000)
Expand All @@ -168,7 +168,7 @@ public void testSweepBatchesInDifferentRows() {

assertThat(sweepResults.getCellTsPairsExamined())
.describedAs("Expected Ts Pairs Examined should add up to entire table (2 values in each cell)")
.isEqualTo(2 * BIG_LIST_OF_CELLS_IN_DIFFERENT_ROWS.size());
.isEqualTo(2L * BIG_LIST_OF_CELLS_IN_DIFFERENT_ROWS.size());
}

@Test(timeout = 50000)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ public void sweepPreviouslyConservativeNowThoroughTableFuzzTest() {
.map(cell ->
ThreadLocalRandom.current().nextBoolean() ? cell.getRowName() : PtBytes.EMPTY_BYTE_ARRAY)
.collectToMap();
kvs.put(TABLE_1, writes, 100L + 2 * i);
txService.putUnlessExists(100L + 2 * i, 101L + 2 * i);
kvs.put(TABLE_1, writes, 100L + 2L * i);
txService.putUnlessExists(100L + 2L * i, 101L + 2L * i);
}

Map<Cell, Long> readMap = KeyedStream.of(cells).map(_ignore -> 102L).collectToMap();
Expand Down
7 changes: 5 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {
dependencies {
classpath 'com.netflix.nebula:gradle-info-plugin:11.3.3'
classpath 'com.netflix.nebula:nebula-publishing-plugin:18.4.0'
classpath 'com.palantir.baseline:gradle-baseline-java:4.53.0'
classpath 'com.palantir.baseline:gradle-baseline-java:4.125.0'
classpath 'com.palantir.gradle.conjure:gradle-conjure:5.22.0'
classpath 'com.palantir.gradle.docker:gradle-docker:0.32.0'
classpath 'com.palantir.gradle.externalpublish:gradle-external-publish-plugin:1.11.0'
Expand All @@ -35,6 +35,10 @@ apply plugin: 'com.palantir.git-version'
apply plugin: 'com.palantir.external-publish'
apply plugin: 'com.palantir.baseline-java-versions'

javaVersions {
libraryTarget = 11
}

apply from: 'gradle/versions.gradle'

group = 'com.palantir.atlasdb'
Expand Down Expand Up @@ -106,7 +110,6 @@ allprojects {
'EqualsGetClass',
'FutureReturnValueIgnored',
'NarrowingCompoundAssignment',
'PublicConstructorForAbstractClass',
'Slf4jLogsafeArgs',
'StaticAssignmentInConstructor',
'StrictUnusedVariable'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public double getPercentCallsFinishedInMillis(int millis) {
double prev = 1.0 - ((double) underStatsMillis.get(comparisonPoint - 1).get()) / localTotalCalls;
double next = 1.0 - ((double) underStatsMillis.get(comparisonPoint).get()) / localTotalCalls;
// lerp(x0, y0, x1, y1, x) -> y
return 100.0 * lerp(upper / 2.0, prev, upper, next, millis);
return 100.0 * lerp(upper / 2.0, prev, (double) upper, next, millis);
}

@Override
Expand Down Expand Up @@ -139,7 +139,7 @@ public double getPercentileMillis(double perc) {
prevPerc = percent;
percent = 100.0 * ((double) underStatsMillis.get(comparisonPoint).get()) / localTotalCalls;
}
double ret = lerp(prevPerc, millis / 2.0, percent, millis, mustBeBellow);
double ret = lerp(prevPerc, millis / 2.0, percent, (double) millis, mustBeBellow);
if (ret > maxInMillis) {
return maxInMillis;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,7 @@ public synchronized void close() {
@SuppressWarnings("BadAssert") // only fail close check with asserts enabled
public synchronized void check() {
if (!closed) {
log.error(
"{} never closed!",
UnsafeArg.of("typeName", typeName),
UnsafeArg.of("createTrace", createTrace));
log.error("{} never closed!", UnsafeArg.of("typeName", typeName), createTrace);
assert false : typeName + " never closed!" + "\n" + Arrays.toString(createTrace.getStackTrace());
}
}
Expand All @@ -106,7 +103,9 @@ public void finalizeReferent() {

// We maintain hard references to the custom weak references since
// otherwise they themselves can get collected and thus never enqueued.
@SuppressWarnings("DangerousIdentityKey")
private static final Set<MyReference<?>> destructorReferences =
Sets.newSetFromMap(new ConcurrentHashMap<MyReference<?>, Boolean>());

private static final FinalizableReferenceQueue destructorQueue = new FinalizableReferenceQueue();
}
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ protected Double getDoubleObject(int col) throws PalantirSqlException {
if (columns.get(col) == null) {
return null;
}
return Double.valueOf(getLong(col));
return Double.valueOf((double) getLong(col));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import com.palantir.exception.PalantirSqlException;
import com.palantir.logsafe.Preconditions;
import com.palantir.logsafe.SafeArg;
import com.palantir.logsafe.UnsafeArg;
import com.palantir.logsafe.exceptions.SafeRuntimeException;
import com.palantir.nexus.db.DBType;
import com.palantir.nexus.db.monitoring.timer.SqlTimer;
import com.palantir.nexus.db.sql.BasicSQLString.FinalSQLString;
Expand Down Expand Up @@ -256,7 +256,7 @@ static byte[] getBlobArray(Object obj) throws IOException {
/**
* Takes a byte array, deserializes it and returns an Object
*/
@SuppressWarnings("BanSerializableRead")
@SuppressWarnings({"BanSerializableRead", "DangerousJavaDeserialization"})
static Object getBlobObject(InputStream stream) throws IOException, ClassNotFoundException {
ObjectInputStream ois = new ObjectInputStream(stream);
Object object = ois.readObject();
Expand Down Expand Up @@ -595,8 +595,7 @@ public static PalantirSqlException handleInterruptions(long startTime, SQLExcept
SafeArg.of("elapsedTime", elapsedTime),
SafeArg.of("errorCode", cause.getErrorCode()), // $NON-NLS-1$
SafeArg.of("SQLState", cause.getSQLState()), // $NON-NLS-1$
UnsafeArg.of("SQLException", cause.getNextException()), // $NON-NLS-1$
new Exception("Just for a stack trace", cause));
new SafeRuntimeException("Just for a stack trace", cause));
Thread.currentThread().interrupt();
throw new PalantirInterruptedException("SQL call interrupted", cause); // $NON-NLS-1$
}
Expand Down
4 changes: 0 additions & 4 deletions gradle/versions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,3 @@ ext.libVersions =
ant: '1.9.4',
postgresql: '42.3.3'
]

javaVersions {
libraryTarget = 11
}
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ private Optional<LeaderPingerContext<PingableLeader>> getSuspectedLeaderOverNetw
return Optional.empty();
}

@SuppressWarnings("ImmutablesReferenceEquality")
private void throwIfInvalidSetup(
LeaderPingerContext<PingableLeader> cachedService,
LeaderPingerContext<PingableLeader> pingedService,
Expand Down
Loading