From 69a375b8232f105a161fb88745aff1b6d1cff15b Mon Sep 17 00:00:00 2001 From: Sandra Wang Date: Thu, 10 Mar 2022 23:08:55 -0500 Subject: [PATCH] [#2766]fix: clean up deprecation warnings (#3511) * clean up deprecation warnings *Quantity Interface getValue() * LegacyPrivateStateStorage * GraphQLDataFetcherContext Signed-off-by: Sandra Wang Co-authored-by: Sally MacFarlane --- .../consensus/merge/blockcreation/PayloadIdentifier.java | 2 +- .../merge/blockcreation/PayloadIdentifierTest.java | 2 +- .../errorpronechecks/PrivateStaticFinalLoggers.java | 6 +++++- .../besu/ethereum/mainnet/ClassicDifficultyCalculators.java | 2 +- .../besu/ethereum/mainnet/MainnetDifficultyCalculators.java | 2 +- .../sorter/BaseFeePendingTransactionsSorter.java | 4 ++-- .../java/org/hyperledger/besu/ethstats/EthStatsService.java | 4 ++-- .../org/hyperledger/besu/nat/upnp/OkHttpStreamClient.java | 4 ++-- 8 files changed, 15 insertions(+), 11 deletions(-) diff --git a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/PayloadIdentifier.java b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/PayloadIdentifier.java index 092a2c15d3..db64770464 100644 --- a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/PayloadIdentifier.java +++ b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/PayloadIdentifier.java @@ -72,7 +72,7 @@ public class PayloadIdentifier implements Quantity { @Override public boolean equals(final Object o) { if (o instanceof PayloadIdentifier) { - return getValue().equals(((PayloadIdentifier) o).getValue()); + return getAsBigInteger().equals(((PayloadIdentifier) o).getAsBigInteger()); } return false; } diff --git a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/PayloadIdentifierTest.java b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/PayloadIdentifierTest.java index 07bbebb8f1..9203db85d4 100644 --- a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/PayloadIdentifierTest.java +++ b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/PayloadIdentifierTest.java @@ -41,6 +41,6 @@ public class PayloadIdentifierTest { public void conversionCoverage() { var idTest = PayloadIdentifier.forPayloadParams(Hash.ZERO, 1337L); assertThat(new PayloadIdentifier(idTest.getAsBigInteger().longValue())).isEqualTo(idTest); - assertThat(new PayloadIdentifier(idTest.getValue().longValue())).isEqualTo(idTest); + assertThat(new PayloadIdentifier(idTest.getAsBigInteger().longValue())).isEqualTo(idTest); } } diff --git a/errorprone-checks/src/main/java/org/hyperledger/errorpronechecks/PrivateStaticFinalLoggers.java b/errorprone-checks/src/main/java/org/hyperledger/errorpronechecks/PrivateStaticFinalLoggers.java index 9a805fbf92..bf769500d1 100644 --- a/errorprone-checks/src/main/java/org/hyperledger/errorpronechecks/PrivateStaticFinalLoggers.java +++ b/errorprone-checks/src/main/java/org/hyperledger/errorpronechecks/PrivateStaticFinalLoggers.java @@ -21,6 +21,7 @@ import static com.google.errorprone.util.ASTHelpers.getType; import static com.google.errorprone.util.ASTHelpers.isSubtype; import java.util.List; +import java.util.Optional; import javax.lang.model.element.ElementKind; import javax.lang.model.element.Modifier; @@ -29,6 +30,7 @@ import com.google.errorprone.BugPattern; import com.google.errorprone.VisitorState; import com.google.errorprone.bugpatterns.BugChecker; import com.google.errorprone.bugpatterns.BugChecker.VariableTreeMatcher; +import com.google.errorprone.fixes.SuggestedFix; import com.google.errorprone.matchers.Description; import com.google.errorprone.suppliers.Supplier; import com.google.errorprone.suppliers.Suppliers; @@ -60,8 +62,10 @@ public class PrivateStaticFinalLoggers extends BugChecker implements VariableTre if (!isSubtype(getType(tree), ORG_SLF4J_LOGGER.get(state), state)) { return NO_MATCH; } + Optional fixes = + addModifiers(tree, state, Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL); return buildDescription(tree) - .addFix(addModifiers(tree, state, Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL)) + .addFix(fixes.isPresent() ? fixes.get() : SuggestedFix.emptyFix()) .build(); } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ClassicDifficultyCalculators.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ClassicDifficultyCalculators.java index 67554fccb5..0e7e5d08a4 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ClassicDifficultyCalculators.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ClassicDifficultyCalculators.java @@ -103,6 +103,6 @@ public abstract class ClassicDifficultyCalculators { } private static BigInteger difficulty(final Quantity value) { - return (BigInteger) value.getValue(); + return value.getAsBigInteger(); } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetDifficultyCalculators.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetDifficultyCalculators.java index ffac7a4c9c..e8f227fc07 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetDifficultyCalculators.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetDifficultyCalculators.java @@ -138,6 +138,6 @@ public abstract class MainnetDifficultyCalculators { } private static BigInteger difficulty(final Quantity value) { - return (BigInteger) value.getValue(); + return value.getAsBigInteger(); } } diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/sorter/BaseFeePendingTransactionsSorter.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/sorter/BaseFeePendingTransactionsSorter.java index cc03be4afc..55256cb176 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/sorter/BaseFeePendingTransactionsSorter.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/sorter/BaseFeePendingTransactionsSorter.java @@ -84,7 +84,7 @@ public class BaseFeePendingTransactionsSorter extends AbstractPendingTransaction .getMaxPriorityFeePerGas() // safe to .get() here because only 1559 txs can be in the static range .get() - .getValue() + .getAsBigInteger() .longValue()) .thenComparing(TransactionInfo::getSequence) .reversed()); @@ -97,7 +97,7 @@ public class BaseFeePendingTransactionsSorter extends AbstractPendingTransaction transactionInfo .getTransaction() .getMaxFeePerGas() - .map(maxFeePerGas -> maxFeePerGas.getValue().longValue()) + .map(maxFeePerGas -> maxFeePerGas.getAsBigInteger().longValue()) .orElse(transactionInfo.getGasPrice().toLong())) .thenComparing(TransactionInfo::getSequence) .reversed()); diff --git a/ethereum/ethstats/src/main/java/org/hyperledger/besu/ethstats/EthStatsService.java b/ethereum/ethstats/src/main/java/org/hyperledger/besu/ethstats/EthStatsService.java index 784115b2af..e9ec5330d1 100644 --- a/ethereum/ethstats/src/main/java/org/hyperledger/besu/ethstats/EthStatsService.java +++ b/ethereum/ethstats/src/main/java/org/hyperledger/besu/ethstats/EthStatsService.java @@ -440,9 +440,9 @@ public class EthStatsService { return block.getBody().getTransactions().stream() .min(Comparator.comparing(t -> t.getEffectiveGasPrice(block.getHeader().getBaseFee()))) .map(t -> t.getEffectiveGasPrice(block.getHeader().getBaseFee())) - .filter(wei -> wei.getValue().longValue() > 0) + .filter(wei -> wei.getAsBigInteger().longValue() > 0) .orElse(miningCoordinator.getMinTransactionGasPrice()) - .getValue() + .getAsBigInteger() .longValue(); } } diff --git a/nat/src/main/java/org/hyperledger/besu/nat/upnp/OkHttpStreamClient.java b/nat/src/main/java/org/hyperledger/besu/nat/upnp/OkHttpStreamClient.java index 5a62ce002a..5773c3be3d 100644 --- a/nat/src/main/java/org/hyperledger/besu/nat/upnp/OkHttpStreamClient.java +++ b/nat/src/main/java/org/hyperledger/besu/nat/upnp/OkHttpStreamClient.java @@ -50,9 +50,9 @@ public class OkHttpStreamClient extends AbstractStreamClient