From 444552962cfdfbe8e3dbc03134da195c939671e3 Mon Sep 17 00:00:00 2001 From: Carter Kozak Date: Tue, 3 May 2022 10:05:57 -0400 Subject: [PATCH] Latest gradle-baseline --- .../CassandraRequestExceptionHandler.java | 3 +- .../cassandra/thrift/ThriftQueryWeighers.java | 2 +- .../DistributionOutlierControllerTest.java | 2 +- .../impl/ProfilingKeyValueService.java | 2 +- .../impl/SweepStatsKeyValueService.java | 5 ++- .../sweep/queue/id/SweepTableIdentifier.java | 2 +- .../atlasdb/table/description/Schema.java | 1 + ...SlidingWindowMetricsInvocationHandler.java | 6 +--- .../TaggedMetricsInvocationEventHandler.java | 6 +--- .../com/palantir/common/base/Throwables.java | 1 + .../common/proxy/SerializingUtils.java | 2 +- .../startup/ConsistencyCheckRunner.java | 6 ++-- .../dbkvs/impl/TableMetadataCache.java | 2 ++ .../atlasdb/sweep/queue/ShardProgress.java | 1 + .../atlasdb/sweep/queue/SweepableCells.java | 6 ++-- .../WriteBatchingTransactionService.java | 15 ++++----- ...ndraImitatingConsensusForgettingStore.java | 1 + .../atlasdb/impl/TableMetadataCache.java | 1 + .../sweep/AbstractSweepTaskRunnerTest.java | 4 +-- .../SweeperServiceImplIntegrationTest.java | 4 +-- build.gradle | 7 ++-- .../util/jmx/AbstractOperationStats.java | 4 +-- .../palantir/nexus/db/pool/CloseTracking.java | 7 ++-- .../nexus/db/sql/AgnosticResultRowImpl.java | 2 +- .../com/palantir/nexus/db/sql/BasicSQL.java | 7 ++-- gradle/versions.gradle | 4 --- .../palantir/paxos/SingleLeaderPinger.java | 1 + .../lock/client/LockLeaseService.java | 1 + .../lock/client/TransactionStarterHelper.java | 1 + .../paxos/PaxosRemoteClientsTest.java | 1 + .../paxos/GetSuspectedLeaderWithUuid.java | 1 + .../adjudicate/FeedbackAnalysisTest.java | 32 +++++++++---------- .../PointHealthReportAnalysisTest.java | 10 +++--- 33 files changed, 75 insertions(+), 75 deletions(-) diff --git a/atlasdb-cassandra/src/main/java/com/palantir/atlasdb/keyvalue/cassandra/CassandraRequestExceptionHandler.java b/atlasdb-cassandra/src/main/java/com/palantir/atlasdb/keyvalue/cassandra/CassandraRequestExceptionHandler.java index 5c3e53bccb6..ccf7e133342 100644 --- a/atlasdb-cassandra/src/main/java/com/palantir/atlasdb/keyvalue/cassandra/CassandraRequestExceptionHandler.java +++ b/atlasdb-cassandra/src/main/java/com/palantir/atlasdb/keyvalue/cassandra/CassandraRequestExceptionHandler.java @@ -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); } @Override diff --git a/atlasdb-cassandra/src/main/java/com/palantir/atlasdb/keyvalue/cassandra/thrift/ThriftQueryWeighers.java b/atlasdb-cassandra/src/main/java/com/palantir/atlasdb/keyvalue/cassandra/thrift/ThriftQueryWeighers.java index bb2625407c9..ccfbb77f32e 100644 --- a/atlasdb-cassandra/src/main/java/com/palantir/atlasdb/keyvalue/cassandra/thrift/ThriftQueryWeighers.java +++ b/atlasdb-cassandra/src/main/java/com/palantir/atlasdb/keyvalue/cassandra/thrift/ThriftQueryWeighers.java @@ -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)) .timeTakenNanos(timeTakenNanos) .numDistinctRows(1) .build(); diff --git a/atlasdb-cassandra/src/test/java/com/palantir/atlasdb/keyvalue/cassandra/pool/DistributionOutlierControllerTest.java b/atlasdb-cassandra/src/test/java/com/palantir/atlasdb/keyvalue/cassandra/pool/DistributionOutlierControllerTest.java index b5bd2c45367..498d78c941c 100644 --- a/atlasdb-cassandra/src/test/java/com/palantir/atlasdb/keyvalue/cassandra/pool/DistributionOutlierControllerTest.java +++ b/atlasdb-cassandra/src/test/java/com/palantir/atlasdb/keyvalue/cassandra/pool/DistributionOutlierControllerTest.java @@ -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); } @Test diff --git a/atlasdb-client/src/main/java/com/palantir/atlasdb/keyvalue/impl/ProfilingKeyValueService.java b/atlasdb-client/src/main/java/com/palantir/atlasdb/keyvalue/impl/ProfilingKeyValueService.java index e14f1e6ab2d..02d1b49bf94 100644 --- a/atlasdb-client/src/main/java/com/palantir/atlasdb/keyvalue/impl/ProfilingKeyValueService.java +++ b/atlasdb-client/src/main/java/com/palantir/atlasdb/keyvalue/impl/ProfilingKeyValueService.java @@ -238,7 +238,7 @@ public Set getAllTableNames() { public Multimap getAllTimestamps(TableReference tableRef, Set 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 diff --git a/atlasdb-client/src/main/java/com/palantir/atlasdb/keyvalue/impl/SweepStatsKeyValueService.java b/atlasdb-client/src/main/java/com/palantir/atlasdb/keyvalue/impl/SweepStatsKeyValueService.java index ef1c05995fd..f6386f4be6f 100644 --- a/atlasdb-client/src/main/java/com/palantir/atlasdb/keyvalue/impl/SweepStatsKeyValueService.java +++ b/atlasdb-client/src/main/java/com/palantir/atlasdb/keyvalue/impl/SweepStatsKeyValueService.java @@ -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); + log.warn("Error occurred while flushing sweep stats", t); } } } @@ -283,8 +283,7 @@ private void flushWrites(Multiset writes, Set 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 tableNames = Sets.difference(writes.elementSet(), clears); Collection rows = Collections2.transform( diff --git a/atlasdb-client/src/main/java/com/palantir/atlasdb/sweep/queue/id/SweepTableIdentifier.java b/atlasdb-client/src/main/java/com/palantir/atlasdb/sweep/queue/id/SweepTableIdentifier.java index c3d9d6e32fd..8e3752dacd6 100644 --- a/atlasdb-client/src/main/java/com/palantir/atlasdb/sweep/queue/id/SweepTableIdentifier.java +++ b/atlasdb-client/src/main/java/com/palantir/atlasdb/sweep/queue/id/SweepTableIdentifier.java @@ -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 diff --git a/atlasdb-client/src/main/java/com/palantir/atlasdb/table/description/Schema.java b/atlasdb-client/src/main/java/com/palantir/atlasdb/table/description/Schema.java index 28c2223ddc5..697caafc727 100644 --- a/atlasdb-client/src/main/java/com/palantir/atlasdb/table/description/Schema.java +++ b/atlasdb-client/src/main/java/com/palantir/atlasdb/table/description/Schema.java @@ -323,6 +323,7 @@ public Namespace getNamespace() { * * @param srcDir root source directory where code generation is performed. */ + @SuppressWarnings("DangerousIdentityKey") 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"); diff --git a/atlasdb-client/src/main/java/com/palantir/atlasdb/util/SlidingWindowMetricsInvocationHandler.java b/atlasdb-client/src/main/java/com/palantir/atlasdb/util/SlidingWindowMetricsInvocationHandler.java index 259c7194350..8a3298cc391 100644 --- a/atlasdb-client/src/main/java/com/palantir/atlasdb/util/SlidingWindowMetricsInvocationHandler.java +++ b/atlasdb-client/src/main/java/com/palantir/atlasdb/util/SlidingWindowMetricsInvocationHandler.java @@ -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; @@ -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); return; } diff --git a/atlasdb-client/src/main/java/com/palantir/atlasdb/util/TaggedMetricsInvocationEventHandler.java b/atlasdb-client/src/main/java/com/palantir/atlasdb/util/TaggedMetricsInvocationEventHandler.java index 6540fd9d3c5..70d2abe6b89 100644 --- a/atlasdb-client/src/main/java/com/palantir/atlasdb/util/TaggedMetricsInvocationEventHandler.java +++ b/atlasdb-client/src/main/java/com/palantir/atlasdb/util/TaggedMetricsInvocationEventHandler.java @@ -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; @@ -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; } diff --git a/atlasdb-commons/src/main/java/com/palantir/common/base/Throwables.java b/atlasdb-commons/src/main/java/com/palantir/common/base/Throwables.java index 96b67fa6fa1..35347af2273 100644 --- a/atlasdb-commons/src/main/java/com/palantir/common/base/Throwables.java +++ b/atlasdb-commons/src/main/java/com/palantir/common/base/Throwables.java @@ -204,6 +204,7 @@ public static 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 rewrap(final String newMessage, final T throwable) { Preconditions.checkNotNull(throwable); log.info( diff --git a/atlasdb-commons/src/main/java/com/palantir/common/proxy/SerializingUtils.java b/atlasdb-commons/src/main/java/com/palantir/common/proxy/SerializingUtils.java index 742c4931e86..4d73d6519a3 100644 --- a/atlasdb-commons/src/main/java/com/palantir/common/proxy/SerializingUtils.java +++ b/atlasdb-commons/src/main/java/com/palantir/common/proxy/SerializingUtils.java @@ -36,7 +36,7 @@ public static T copy(T orig) { return copy(orig, (is, codebase) -> new ObjectInputStream(is)); } - @SuppressWarnings("unchecked") + @SuppressWarnings({"unchecked", "DangerousJavaDeserialization"}) public static T copy(T orig, ObjectInputStreamFactory factory) { T obj = null; diff --git a/atlasdb-config/src/main/java/com/palantir/atlasdb/factory/startup/ConsistencyCheckRunner.java b/atlasdb-config/src/main/java/com/palantir/atlasdb/factory/startup/ConsistencyCheckRunner.java index e0149ffefdf..b407a287460 100644 --- a/atlasdb-config/src/main/java/com/palantir/atlasdb/factory/startup/ConsistencyCheckRunner.java +++ b/atlasdb-config/src/main/java/com/palantir/atlasdb/factory/startup/ConsistencyCheckRunner.java @@ -43,8 +43,6 @@ public final class ConsistencyCheckRunner extends Callback { private static final SafeLogger log = SafeLoggerFactory.get(ConsistencyCheckRunner.class); - private static final RuntimeException UNKNOWN = new SafeRuntimeException("unknown"); - private final List consistencyChecks; @VisibleForTesting @@ -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: diff --git a/atlasdb-dbkvs/src/main/java/com/palantir/atlasdb/keyvalue/dbkvs/impl/TableMetadataCache.java b/atlasdb-dbkvs/src/main/java/com/palantir/atlasdb/keyvalue/dbkvs/impl/TableMetadataCache.java index a57bc1bf71e..a152234224e 100644 --- a/atlasdb-dbkvs/src/main/java/com/palantir/atlasdb/keyvalue/dbkvs/impl/TableMetadataCache.java +++ b/atlasdb-dbkvs/src/main/java/com/palantir/atlasdb/keyvalue/dbkvs/impl/TableMetadataCache.java @@ -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) { @@ -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) { diff --git a/atlasdb-impl-shared/src/main/java/com/palantir/atlasdb/sweep/queue/ShardProgress.java b/atlasdb-impl-shared/src/main/java/com/palantir/atlasdb/sweep/queue/ShardProgress.java index cbacd5354d5..457bfca6343 100644 --- a/atlasdb-impl-shared/src/main/java/com/palantir/atlasdb/sweep/queue/ShardProgress.java +++ b/atlasdb-impl-shared/src/main/java/com/palantir/atlasdb/sweep/queue/ShardProgress.java @@ -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 diff --git a/atlasdb-impl-shared/src/main/java/com/palantir/atlasdb/sweep/queue/SweepableCells.java b/atlasdb-impl-shared/src/main/java/com/palantir/atlasdb/sweep/queue/SweepableCells.java index 2bf65125851..c1663e741e3 100644 --- a/atlasdb-impl-shared/src/main/java/com/palantir/atlasdb/sweep/queue/SweepableCells.java +++ b/atlasdb-impl-shared/src/main/java/com/palantir/atlasdb/sweep/queue/SweepableCells.java @@ -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; @@ -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; @@ -180,7 +179,8 @@ private DedicatedRows getDedicatedRowsToClear(List 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())); diff --git a/atlasdb-impl-shared/src/main/java/com/palantir/atlasdb/transaction/service/WriteBatchingTransactionService.java b/atlasdb-impl-shared/src/main/java/com/palantir/atlasdb/transaction/service/WriteBatchingTransactionService.java index eb7a26f784b..fc99dcc6b0b 100644 --- a/atlasdb-impl-shared/src/main/java/com/palantir/atlasdb/transaction/service/WriteBatchingTransactionService.java +++ b/atlasdb-impl-shared/src/main/java/com/palantir/atlasdb/transaction/service/WriteBatchingTransactionService.java @@ -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; @@ -283,12 +281,13 @@ private static Map> classifyTimestampsOnKeySetPresence( private static Set getAlreadyExistingStartTimestamps( EncodingTransactionService delegate, Set startTimestamps, KeyAlreadyExistsException exception) { Set 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; } diff --git a/atlasdb-impl-shared/src/test/java/com/palantir/atlasdb/pue/CassandraImitatingConsensusForgettingStore.java b/atlasdb-impl-shared/src/test/java/com/palantir/atlasdb/pue/CassandraImitatingConsensusForgettingStore.java index 39cad454c75..bf171395858 100644 --- a/atlasdb-impl-shared/src/test/java/com/palantir/atlasdb/pue/CassandraImitatingConsensusForgettingStore.java +++ b/atlasdb-impl-shared/src/test/java/com/palantir/atlasdb/pue/CassandraImitatingConsensusForgettingStore.java @@ -203,6 +203,7 @@ private void writeToQuorum(Cell cell, Set quorumNodes, byte[] value) { }); } + @SuppressWarnings("DangerousIdentityKey") private Set getQuorumNodes() { return nodes.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(ArrayList::new), list -> { Collections.shuffle(list); diff --git a/atlasdb-service/src/main/java/com/palantir/atlasdb/impl/TableMetadataCache.java b/atlasdb-service/src/main/java/com/palantir/atlasdb/impl/TableMetadataCache.java index fbbd67a05f7..d9fb45f2d1a 100644 --- a/atlasdb-service/src/main/java/com/palantir/atlasdb/impl/TableMetadataCache.java +++ b/atlasdb-service/src/main/java/com/palantir/atlasdb/impl/TableMetadataCache.java @@ -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) { diff --git a/atlasdb-tests-shared/src/main/java/com/palantir/atlasdb/sweep/AbstractSweepTaskRunnerTest.java b/atlasdb-tests-shared/src/main/java/com/palantir/atlasdb/sweep/AbstractSweepTaskRunnerTest.java index 6fd00ba683d..b906d20153a 100644 --- a/atlasdb-tests-shared/src/main/java/com/palantir/atlasdb/sweep/AbstractSweepTaskRunnerTest.java +++ b/atlasdb-tests-shared/src/main/java/com/palantir/atlasdb/sweep/AbstractSweepTaskRunnerTest.java @@ -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) @@ -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) diff --git a/atlasdb-tests-shared/src/main/java/com/palantir/atlasdb/sweep/SweeperServiceImplIntegrationTest.java b/atlasdb-tests-shared/src/main/java/com/palantir/atlasdb/sweep/SweeperServiceImplIntegrationTest.java index fd3415aaf6a..d030dbed172 100644 --- a/atlasdb-tests-shared/src/main/java/com/palantir/atlasdb/sweep/SweeperServiceImplIntegrationTest.java +++ b/atlasdb-tests-shared/src/main/java/com/palantir/atlasdb/sweep/SweeperServiceImplIntegrationTest.java @@ -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 readMap = KeyedStream.of(cells).map(_ignore -> 102L).collectToMap(); diff --git a/build.gradle b/build.gradle index ccbd53dcaf1..443ba11d8d3 100644 --- a/build.gradle +++ b/build.gradle @@ -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' @@ -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' @@ -106,7 +110,6 @@ allprojects { 'EqualsGetClass', 'FutureReturnValueIgnored', 'NarrowingCompoundAssignment', - 'PublicConstructorForAbstractClass', 'Slf4jLogsafeArgs', 'StaticAssignmentInConstructor', 'StrictUnusedVariable' diff --git a/commons-api/src/main/java/com/palantir/util/jmx/AbstractOperationStats.java b/commons-api/src/main/java/com/palantir/util/jmx/AbstractOperationStats.java index f2fcb874faa..9fd2347f3db 100644 --- a/commons-api/src/main/java/com/palantir/util/jmx/AbstractOperationStats.java +++ b/commons-api/src/main/java/com/palantir/util/jmx/AbstractOperationStats.java @@ -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 @@ -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; } diff --git a/commons-db/src/main/java/com/palantir/nexus/db/pool/CloseTracking.java b/commons-db/src/main/java/com/palantir/nexus/db/pool/CloseTracking.java index 6c818c0363c..02c033c4425 100644 --- a/commons-db/src/main/java/com/palantir/nexus/db/pool/CloseTracking.java +++ b/commons-db/src/main/java/com/palantir/nexus/db/pool/CloseTracking.java @@ -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()); } } @@ -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> destructorReferences = Sets.newSetFromMap(new ConcurrentHashMap, Boolean>()); + private static final FinalizableReferenceQueue destructorQueue = new FinalizableReferenceQueue(); } diff --git a/commons-db/src/main/java/com/palantir/nexus/db/sql/AgnosticResultRowImpl.java b/commons-db/src/main/java/com/palantir/nexus/db/sql/AgnosticResultRowImpl.java index f4a7a921822..7a9ef039db6 100644 --- a/commons-db/src/main/java/com/palantir/nexus/db/sql/AgnosticResultRowImpl.java +++ b/commons-db/src/main/java/com/palantir/nexus/db/sql/AgnosticResultRowImpl.java @@ -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 diff --git a/commons-db/src/main/java/com/palantir/nexus/db/sql/BasicSQL.java b/commons-db/src/main/java/com/palantir/nexus/db/sql/BasicSQL.java index b83c0779a67..ea3530e478e 100644 --- a/commons-db/src/main/java/com/palantir/nexus/db/sql/BasicSQL.java +++ b/commons-db/src/main/java/com/palantir/nexus/db/sql/BasicSQL.java @@ -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; @@ -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(); @@ -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$ } diff --git a/gradle/versions.gradle b/gradle/versions.gradle index 44fa4068757..7a977adbea8 100644 --- a/gradle/versions.gradle +++ b/gradle/versions.gradle @@ -30,7 +30,3 @@ ext.libVersions = ant: '1.9.4', postgresql: '42.3.3' ] - -javaVersions { - libraryTarget = 11 -} diff --git a/leader-election-impl/src/main/java/com/palantir/paxos/SingleLeaderPinger.java b/leader-election-impl/src/main/java/com/palantir/paxos/SingleLeaderPinger.java index fa5ff7dd157..67465eb6395 100644 --- a/leader-election-impl/src/main/java/com/palantir/paxos/SingleLeaderPinger.java +++ b/leader-election-impl/src/main/java/com/palantir/paxos/SingleLeaderPinger.java @@ -278,6 +278,7 @@ private Optional> getSuspectedLeaderOverNetw return Optional.empty(); } + @SuppressWarnings("ImmutablesReferenceEquality") private void throwIfInvalidSetup( LeaderPingerContext cachedService, LeaderPingerContext pingedService, diff --git a/lock-api/src/main/java/com/palantir/lock/client/LockLeaseService.java b/lock-api/src/main/java/com/palantir/lock/client/LockLeaseService.java index 299679dec54..e7b353f931f 100644 --- a/lock-api/src/main/java/com/palantir/lock/client/LockLeaseService.java +++ b/lock-api/src/main/java/com/palantir/lock/client/LockLeaseService.java @@ -42,6 +42,7 @@ import java.util.UUID; import java.util.stream.Collectors; +@SuppressWarnings("DangerousIdentityKey") public class LockLeaseService implements AutoCloseable { private final NamespacedConjureTimelockService delegate; private final UUID clientId; diff --git a/lock-api/src/main/java/com/palantir/lock/client/TransactionStarterHelper.java b/lock-api/src/main/java/com/palantir/lock/client/TransactionStarterHelper.java index a9af15226e2..7db80be06e7 100644 --- a/lock-api/src/main/java/com/palantir/lock/client/TransactionStarterHelper.java +++ b/lock-api/src/main/java/com/palantir/lock/client/TransactionStarterHelper.java @@ -69,6 +69,7 @@ private static Set unlock( return ImmutableSet.copyOf(Sets.union(resultLockTokenShares, resultLockTokens)); } + @SuppressWarnings("DangerousIdentityKey") static Set filterLockTokenShares(Set tokens) { return tokens.stream() .filter(TransactionStarterHelper::isLockTokenShare) diff --git a/timelock-agent/src/test/java/com/palantir/atlasdb/timelock/paxos/PaxosRemoteClientsTest.java b/timelock-agent/src/test/java/com/palantir/atlasdb/timelock/paxos/PaxosRemoteClientsTest.java index 4aa71f00164..35a77cdd4bb 100644 --- a/timelock-agent/src/test/java/com/palantir/atlasdb/timelock/paxos/PaxosRemoteClientsTest.java +++ b/timelock-agent/src/test/java/com/palantir/atlasdb/timelock/paxos/PaxosRemoteClientsTest.java @@ -43,6 +43,7 @@ import org.junit.Test; import org.junit.rules.TemporaryFolder; +@SuppressWarnings("DangerousIdentityKey") public class PaxosRemoteClientsTest { @Rule public final TemporaryFolder temporaryFolder = new TemporaryFolder(); diff --git a/timelock-impl/src/main/java/com/palantir/atlasdb/timelock/paxos/GetSuspectedLeaderWithUuid.java b/timelock-impl/src/main/java/com/palantir/atlasdb/timelock/paxos/GetSuspectedLeaderWithUuid.java index fb0495791de..c0c9276913e 100644 --- a/timelock-impl/src/main/java/com/palantir/atlasdb/timelock/paxos/GetSuspectedLeaderWithUuid.java +++ b/timelock-impl/src/main/java/com/palantir/atlasdb/timelock/paxos/GetSuspectedLeaderWithUuid.java @@ -134,6 +134,7 @@ private static void completeRequest( futures.forEach(result -> result.set(outcome)); } + @SuppressWarnings("ImmutablesReferenceEquality") private void throwIfInvalidSetup( LeaderPingerContext cachedService, LeaderPingerContext pingedService, diff --git a/timelock-impl/src/test/java/com/palantir/atlasdb/timelock/adjudicate/FeedbackAnalysisTest.java b/timelock-impl/src/test/java/com/palantir/atlasdb/timelock/adjudicate/FeedbackAnalysisTest.java index 6efd171cfd0..de646693ad8 100644 --- a/timelock-impl/src/test/java/com/palantir/atlasdb/timelock/adjudicate/FeedbackAnalysisTest.java +++ b/timelock-impl/src/test/java/com/palantir/atlasdb/timelock/adjudicate/FeedbackAnalysisTest.java @@ -233,9 +233,9 @@ private ConjureTimeLockClientFeedback getUnhealthyClientFeedbackReport(String se serviceName, nodeId, LEADER_TIME_MIN_RATE + 1, - LEADER_TIME_MAX_P99 + 1, + (double) (LEADER_TIME_MAX_P99 + 1), START_TXN_MIN_RATE + 1, - START_TRANSACTION_MAX_P99 + 1); + (double) (START_TRANSACTION_MAX_P99 + 1)); } private ConjureTimeLockClientFeedback getHealthyClientFeedbackReport(String serviceName, UUID nodeId) { @@ -243,9 +243,9 @@ private ConjureTimeLockClientFeedback getHealthyClientFeedbackReport(String serv serviceName, nodeId, LEADER_TIME_MIN_RATE + 1, - LEADER_TIME_MAX_P99 - 1, + (double) (LEADER_TIME_MAX_P99 - 1), START_TXN_MIN_RATE + 1, - START_TRANSACTION_MAX_P99 - 1); + (double) (START_TRANSACTION_MAX_P99 - 1)); } private ConjureTimeLockClientFeedback getUnknownClientFeedbackReport(String serviceName, UUID nodeId) { @@ -253,9 +253,9 @@ private ConjureTimeLockClientFeedback getUnknownClientFeedbackReport(String serv serviceName, nodeId, LEADER_TIME_MIN_RATE - 1, - LEADER_TIME_MAX_P99 - 1, + (double) (LEADER_TIME_MAX_P99 - 1), START_TXN_MIN_RATE - 1, - START_TRANSACTION_MAX_P99 - 1); + (double) (START_TRANSACTION_MAX_P99 - 1)); } private ConjureTimeLockClientFeedback getReportWithLeaderTimeMetricInUnknownState(String serviceName, UUID nodeId) { @@ -263,9 +263,9 @@ private ConjureTimeLockClientFeedback getReportWithLeaderTimeMetricInUnknownStat serviceName, nodeId, LEADER_TIME_MIN_RATE - 1, - LEADER_TIME_MAX_P99 - 1, + (double) (LEADER_TIME_MAX_P99 - 1), START_TXN_MIN_RATE + 1, - START_TRANSACTION_MAX_P99 - 1); + (double) (START_TRANSACTION_MAX_P99 - 1)); } private ConjureTimeLockClientFeedback getReportWithStartTxnMetricInUnknownState(String serviceName, UUID nodeId) { @@ -273,9 +273,9 @@ private ConjureTimeLockClientFeedback getReportWithStartTxnMetricInUnknownState( serviceName, nodeId, LEADER_TIME_MIN_RATE + 1, - LEADER_TIME_MAX_P99 - 1, + (double) (LEADER_TIME_MAX_P99 - 1), START_TXN_MIN_RATE - 1, - START_TRANSACTION_MAX_P99 - 1); + (double) (START_TRANSACTION_MAX_P99 - 1)); } private ConjureTimeLockClientFeedback getReportWithLeaderTimeMetricInUnhealthyState( @@ -284,9 +284,9 @@ private ConjureTimeLockClientFeedback getReportWithLeaderTimeMetricInUnhealthySt serviceName, nodeId, LEADER_TIME_MIN_RATE + 1, - LEADER_TIME_MAX_P99 + 1, + (double) (LEADER_TIME_MAX_P99 + 1), START_TXN_MIN_RATE + 1, - START_TRANSACTION_MAX_P99 - 1); + (double) (START_TRANSACTION_MAX_P99 - 1)); } private ConjureTimeLockClientFeedback getReportWithStartTxnMetricInUnHealthyState(String serviceName, UUID nodeId) { @@ -294,9 +294,9 @@ private ConjureTimeLockClientFeedback getReportWithStartTxnMetricInUnHealthyStat serviceName, nodeId, LEADER_TIME_MIN_RATE + 1, - LEADER_TIME_MAX_P99 - 1, + (double) (LEADER_TIME_MAX_P99 - 1), START_TXN_MIN_RATE + 1, - START_TRANSACTION_MAX_P99 + 1); + (double) (START_TRANSACTION_MAX_P99 + 1)); } private ConjureTimeLockClientFeedback getReportWithStartTxnForVeryHighP99(String serviceName, UUID nodeId) { @@ -304,9 +304,9 @@ private ConjureTimeLockClientFeedback getReportWithStartTxnForVeryHighP99(String serviceName, nodeId, LEADER_TIME_MIN_RATE + 1, - LEADER_TIME_MAX_P99 - 1, + (double) (LEADER_TIME_MAX_P99 - 1), START_TXN_MIN_RATE - 0.001, // Outliers are bad, even if req rate is low - START_TXN_QUIET_P99_LIMIT + 1); + (double) (START_TXN_QUIET_P99_LIMIT + 1)); } private ConjureTimeLockClientFeedback getClientFeedbackReport( diff --git a/timelock-impl/src/test/java/com/palantir/atlasdb/timelock/adjudicate/PointHealthReportAnalysisTest.java b/timelock-impl/src/test/java/com/palantir/atlasdb/timelock/adjudicate/PointHealthReportAnalysisTest.java index ad608b0ffc4..52b80be4938 100644 --- a/timelock-impl/src/test/java/com/palantir/atlasdb/timelock/adjudicate/PointHealthReportAnalysisTest.java +++ b/timelock-impl/src/test/java/com/palantir/atlasdb/timelock/adjudicate/PointHealthReportAnalysisTest.java @@ -40,7 +40,7 @@ public class PointHealthReportAnalysisTest { public void reportIsHealthyWhenEverythingIsRight() { FeedbackHandler feedbackHandler = FeedbackHandler.createForTests(); EndpointStatistics statistics = EndpointStatistics.builder() - .p99(P_99 - 1) + .p99((double) (P_99 - 1)) .oneMin(RATE + 1) .errorRate(0) .build(); @@ -52,7 +52,7 @@ public void reportIsHealthyWhenEverythingIsRight() { public void reportStatusIsUnknownIfReqRateIsBelowThreshold() { FeedbackHandler feedbackHandler = FeedbackHandler.createForTests(); EndpointStatistics statistics = EndpointStatistics.builder() - .p99(P_99 + 1) + .p99((double) (P_99 + 1)) .oneMin(RATE - 0.01) .errorRate(ERROR_PROPORTION * RATE + 0.1) .build(); @@ -64,7 +64,7 @@ public void reportStatusIsUnknownIfReqRateIsBelowThreshold() { public void reportStatusIsUnhealthyIfErrProportionIsHigh() { FeedbackHandler feedbackHandler = FeedbackHandler.createForTests(); EndpointStatistics statistics = EndpointStatistics.builder() - .p99(P_99 + 1) + .p99((double) (P_99 + 1)) .oneMin(RATE + 0.01) .errorRate(ERROR_PROPORTION * RATE + 0.1) .build(); @@ -76,7 +76,7 @@ public void reportStatusIsUnhealthyIfErrProportionIsHigh() { public void reportStatusIsUnhealthyIfP99IsAboveThreshold() { FeedbackHandler feedbackHandler = FeedbackHandler.createForTests(); EndpointStatistics statistics = EndpointStatistics.builder() - .p99(P_99 + 1) + .p99((double) (P_99 + 1)) .oneMin(RATE + 0.01) .errorRate(ERROR_PROPORTION * RATE) .build(); @@ -88,7 +88,7 @@ public void reportStatusIsUnhealthyIfP99IsAboveThreshold() { public void reportStatusIsUnhealthyIfQuietP99IsAboveThreshold() { FeedbackHandler feedbackHandler = FeedbackHandler.createForTests(); EndpointStatistics statistics = EndpointStatistics.builder() - .p99(QUIET_P99 + 1) + .p99((double) (QUIET_P99 + 1)) .oneMin(RATE - 0.01) .errorRate(0) .build();