From e493b91742cd194cd27fac76d2559accf287935e Mon Sep 17 00:00:00 2001 From: Danno Ferrin Date: Thu, 2 Jan 2020 10:27:54 -0700 Subject: [PATCH] Restore "FieldCanBeFinal" errorprone check (#287) This was turned off a number of months ago because of long build times. However it appears either because of code structure changes or fixed errorprone that this finishes in a reasonable time now. Code that violated this check is also fixed. Signed-off-by: Danno Ferrin --- .../acceptance/dsl/blockchain/Amount.java | 4 +- .../clique/ExpectedBlockHasProposer.java | 2 +- .../ethsigner/testutil/EthSignerConfig.java | 2 +- .../acceptance/dsl/node/cluster/Cluster.java | 2 +- .../BesuNodeConfigurationBuilder.java | 6 +- .../LoadPrivateSmartContractTransaction.java | 2 +- .../FindPrivacyGroupTransaction.java | 2 +- .../PrivDistributeTransactionTransaction.java | 2 +- .../web3j/generated/CrossContractReader.java | 110 ++++++++++-------- .../tests/web3j/generated/EventEmitter.java | 103 ++++++++-------- .../tests/web3j/generated/RevertReason.java | 93 ++++++++------- .../tests/web3j/generated/SimpleStorage.java | 95 ++++++++------- .../org/hyperledger/besu/RunnerBuilder.java | 2 +- .../org/hyperledger/besu/cli/BesuCommand.java | 21 ++-- .../cli/subcommands/PasswordSubCommand.java | 2 +- .../cli/subcommands/PublicKeySubCommand.java | 4 +- .../cli/subcommands/RetestethSubCommand.java | 2 +- .../subcommands/blocks/BlocksSubCommand.java | 2 +- .../operator/GenerateBlockchainConfig.java | 9 +- .../cli/subcommands/rlp/RLPSubCommand.java | 6 +- .../besu/services/BesuEventsImpl.java | 2 +- .../cli/operator/OperatorSubCommandTest.java | 2 +- build.gradle | 3 +- .../besu/consensus/common/VoteTallyCache.java | 2 +- .../support/StubbedSynchronizerUpdater.java | 2 +- .../ibft/support/TestContextBuilder.java | 8 +- .../ibft/tests/SpuriousBehaviourTest.java | 2 +- .../besu/consensus/ibft/IbftProcessor.java | 2 +- .../blockcreation/IbftMiningCoordinator.java | 2 +- .../ibft/validation/MessageValidator.java | 2 +- .../statemachine/FutureMessageBufferTest.java | 2 +- .../ibft/validation/MessageValidatorTest.java | 10 +- .../RoundChangeMessageValidatorTest.java | 2 +- .../crypto/altbn128/AltBn128Fq2Point.java | 2 +- .../besu/enclave/EnclaveServerException.java | 2 +- .../besu/enclave/types/ReceiveRequest.java | 4 +- .../besu/enclave/types/SendRequest.java | 4 +- .../besu/enclave/types/SendRequestBesu.java | 2 +- .../besu/enclave/types/SendRequestLegacy.java | 2 +- .../besu/enclave/types/SendResponse.java | 2 +- ...vGetPrivateTransactionIntegrationTest.java | 4 +- .../besu/ethereum/api/jsonrpc/RpcMethod.java | 2 +- .../api/jsonrpc/authentication/TomlUser.java | 2 +- .../parameters/TraceTypeParameter.java | 2 +- .../MultiTenancyRpcMethodDecorator.java | 2 +- .../methods/PrivacySendTransaction.java | 2 +- .../methods/eea/EeaSendRawTransaction.java | 6 +- .../methods/priv/PrivCreatePrivacyGroup.java | 4 +- .../methods/priv/PrivDeletePrivacyGroup.java | 4 +- .../priv/PrivDistributeRawTransaction.java | 2 +- .../methods/priv/PrivFindPrivacyGroup.java | 4 +- .../priv/PrivGetEeaTransactionCount.java | 4 +- .../priv/PrivGetPrivateTransaction.java | 2 +- .../methods/priv/PrivGetTransactionCount.java | 2 +- .../priv/PrivGetTransactionReceipt.java | 6 +- .../internal/results/tracing/Action.java | 20 ++-- .../internal/results/tracing/FlatTrace.java | 12 +- .../internal/results/tracing/Result.java | 8 +- .../api/query/TransactionLogsIndexer.java | 2 +- .../AbstractJsonRpcHttpBySpecTest.java | 2 +- .../api/jsonrpc/LatestNonceProviderTest.java | 6 +- .../AuthenticationUtilsTest.java | 6 +- .../priv/PrivGetTransactionCountTest.java | 3 +- .../priv/PrivGetTransactionReceiptTest.java | 3 +- .../blockcreation/AbstractBlockCreator.java | 2 +- ...acyPrecompiledContractIntegrationTest.java | 2 +- .../besu/ethereum/chain/BlockAddedEvent.java | 2 +- .../besu/ethereum/core/DefaultEvmAccount.java | 2 +- .../PrivacyKeyValueStorageProvider.java | 2 +- .../besu/ethereum/worldstate/Pruner.java | 4 +- .../ethereum/core/BlockDataGenerator.java | 2 +- .../core/PrivateTransactionTestFixture.java | 2 +- .../BLAKE2BFPrecompileContractTest.java | 2 +- .../ECRECPrecompiledContractTest.java | 2 +- .../proof/WorldStateProofProviderTest.java | 2 +- .../manager/DeterministicEthScheduler.java | 2 +- .../ethereum/eth/manager/MockEthTask.java | 4 +- .../eth/manager/RespondingEthPeer.java | 2 +- .../internal/PeerDiscoveryController.java | 2 +- .../p2p/network/DefaultP2PNetwork.java | 2 +- .../permissions/PeerPermissionsBlacklist.java | 2 +- .../internal/PeerDiscoveryControllerTest.java | 2 +- .../p2p/peers/MaintainedPeersTest.java | 2 +- .../AbstractPeerConnectionTest.java | 2 +- .../MockConnectionInitializer.java | 5 +- .../PermissioningConfiguration.java | 4 +- .../permissioning/WhitelistPersistor.java | 4 +- ...ncStatusNodePermissioningProviderTest.java | 2 +- .../besu/metrics/RunnableCounter.java | 2 +- .../RocksDBKeyValueStorageFactory.java | 2 +- .../configuration/DatabaseMetadata.java | 2 +- .../hyperledger/besu/util/Subscribers.java | 2 +- .../besu/util/number/Fraction.java | 2 +- .../besu/util/number/Percentage.java | 2 +- .../besu/util/number/PositiveNumber.java | 2 +- 95 files changed, 374 insertions(+), 339 deletions(-) diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/blockchain/Amount.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/blockchain/Amount.java index ed2e00cb9c..fe1d6ae55e 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/blockchain/Amount.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/blockchain/Amount.java @@ -25,8 +25,8 @@ import org.web3j.utils.Convert.Unit; public class Amount { - private BigDecimal value; - private Unit unit; + private final BigDecimal value; + private final Unit unit; private Amount(final BigDecimal value, final Unit unit) { this.value = value; diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/clique/ExpectedBlockHasProposer.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/clique/ExpectedBlockHasProposer.java index facca88b12..16b3a6786c 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/clique/ExpectedBlockHasProposer.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/clique/ExpectedBlockHasProposer.java @@ -30,7 +30,7 @@ import org.web3j.protocol.core.methods.response.EthBlock.Block; public class ExpectedBlockHasProposer implements Condition { private final EthTransactions eth; - private Address proposer; + private final Address proposer; public ExpectedBlockHasProposer(final EthTransactions eth, final Address proposer) { this.eth = eth; diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/ethsigner/testutil/EthSignerConfig.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/ethsigner/testutil/EthSignerConfig.java index 269aec712d..a08631e862 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/ethsigner/testutil/EthSignerConfig.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/ethsigner/testutil/EthSignerConfig.java @@ -25,7 +25,7 @@ public class EthSignerConfig implements Config { private final Level logLevel; private final String downstreamHttpHost; private final Integer downStreamHttpPort; - private Duration downstreamHttpRequestTimeout; + private final Duration downstreamHttpRequestTimeout; private final String httpListenHost; private final Integer httpListenPort; private final ChainIdProvider chainId; diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/cluster/Cluster.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/cluster/Cluster.java index e0b4d91571..2fd522ec65 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/cluster/Cluster.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/cluster/Cluster.java @@ -44,7 +44,7 @@ public class Cluster implements AutoCloseable { private final NetConditions net; private final ClusterConfiguration clusterConfiguration; private List originalNodes = emptyList(); - private List bootnodes = new ArrayList<>(); + private final List bootnodes = new ArrayList<>(); public Cluster(final NetConditions net) { this(new ClusterConfigurationBuilder().build(), net, BesuNodeRunner.instance()); diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfigurationBuilder.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfigurationBuilder.java index de7d09bf3d..3608b43476 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfigurationBuilder.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfigurationBuilder.java @@ -47,12 +47,12 @@ public class BesuNodeConfigurationBuilder { private boolean devMode = true; private GenesisConfigurationProvider genesisConfigProvider = ignore -> Optional.empty(); private Boolean p2pEnabled = true; - private NetworkingConfiguration networkingConfiguration = NetworkingConfiguration.create(); + private final NetworkingConfiguration networkingConfiguration = NetworkingConfiguration.create(); private boolean discoveryEnabled = true; private boolean bootnodeEligible = true; private boolean revertReasonEnabled = false; - private List plugins = new ArrayList<>(); - private List extraCLIOptions = new ArrayList<>(); + private final List plugins = new ArrayList<>(); + private final List extraCLIOptions = new ArrayList<>(); private List staticNodes = new ArrayList<>(); public BesuNodeConfigurationBuilder() { diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/contract/LoadPrivateSmartContractTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/contract/LoadPrivateSmartContractTransaction.java index 9555f4d4f3..a42cb80bcd 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/contract/LoadPrivateSmartContractTransaction.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/contract/LoadPrivateSmartContractTransaction.java @@ -41,7 +41,7 @@ public class LoadPrivateSmartContractTransaction implements private final long chainId; private final Base64String privateFrom; private final List privateFor; - private String contractAddress; + private final String contractAddress; public LoadPrivateSmartContractTransaction( final String contractAddress, diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/FindPrivacyGroupTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/FindPrivacyGroupTransaction.java index 35a6c791e5..0b15b4c0c8 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/FindPrivacyGroupTransaction.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/FindPrivacyGroupTransaction.java @@ -26,7 +26,7 @@ import org.web3j.protocol.besu.response.privacy.PrivacyGroup; import org.web3j.utils.Base64String; public class FindPrivacyGroupTransaction implements Transaction> { - private List nodes; + private final List nodes; public FindPrivacyGroupTransaction(final List nodeEnclaveKeys) { diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/PrivDistributeTransactionTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/PrivDistributeTransactionTransaction.java index fad9a3dcab..d05836aede 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/PrivDistributeTransactionTransaction.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/PrivDistributeTransactionTransaction.java @@ -20,7 +20,7 @@ import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; import java.io.IOException; public class PrivDistributeTransactionTransaction implements Transaction { - private String signedPrivateTransaction; + private final String signedPrivateTransaction; public PrivDistributeTransactionTransaction(final String signedPrivateTransaction) { this.signedPrivateTransaction = signedPrivateTransaction; diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/web3j/generated/CrossContractReader.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/web3j/generated/CrossContractReader.java index 9ce0c0fafd..ef87c493c5 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/web3j/generated/CrossContractReader.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/web3j/generated/CrossContractReader.java @@ -75,41 +75,41 @@ public class CrossContractReader extends Contract { @Deprecated protected CrossContractReader( - String contractAddress, - Web3j web3j, - Credentials credentials, - BigInteger gasPrice, - BigInteger gasLimit) { + final String contractAddress, + final Web3j web3j, + final Credentials credentials, + final BigInteger gasPrice, + final BigInteger gasLimit) { super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit); } protected CrossContractReader( - String contractAddress, - Web3j web3j, - Credentials credentials, - ContractGasProvider contractGasProvider) { + final String contractAddress, + final Web3j web3j, + final Credentials credentials, + final ContractGasProvider contractGasProvider) { super(BINARY, contractAddress, web3j, credentials, contractGasProvider); } @Deprecated protected CrossContractReader( - String contractAddress, - Web3j web3j, - TransactionManager transactionManager, - BigInteger gasPrice, - BigInteger gasLimit) { + final String contractAddress, + final Web3j web3j, + final TransactionManager transactionManager, + final BigInteger gasPrice, + final BigInteger gasLimit) { super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit); } protected CrossContractReader( - String contractAddress, - Web3j web3j, - TransactionManager transactionManager, - ContractGasProvider contractGasProvider) { + final String contractAddress, + final Web3j web3j, + final TransactionManager transactionManager, + final ContractGasProvider contractGasProvider) { super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider); } - public RemoteFunctionCall remoteDestroy(String crossAddress) { + public RemoteFunctionCall remoteDestroy(final String crossAddress) { final Function function = new Function( FUNC_REMOTEDESTROY, @@ -118,7 +118,7 @@ public class CrossContractReader extends Contract { return executeRemoteCallTransaction(function); } - public RemoteFunctionCall deployRemote(String crossAddress) { + public RemoteFunctionCall deployRemote(final String crossAddress) { final Function function = new Function( FUNC_DEPLOYREMOTE, @@ -140,7 +140,7 @@ public class CrossContractReader extends Contract { return executeRemoteCallTransaction(function); } - public RemoteFunctionCall read(String emitter_address) { + public RemoteFunctionCall read(final String emitter_address) { final Function function = new Function( FUNC_READ, @@ -156,7 +156,7 @@ public class CrossContractReader extends Contract { return executeRemoteCallTransaction(function); } - public RemoteFunctionCall incrementRemote(String crossAddress) { + public RemoteFunctionCall incrementRemote(final String crossAddress) { final Function function = new Function( FUNC_INCREMENTREMOTE, @@ -166,7 +166,7 @@ public class CrossContractReader extends Contract { } public List getNewEventEmitterEvents( - TransactionReceipt transactionReceipt) { + final TransactionReceipt transactionReceipt) { List valueList = extractEventParametersWithLog(NEWEVENTEMITTER_EVENT, transactionReceipt); ArrayList responses = @@ -180,13 +180,14 @@ public class CrossContractReader extends Contract { return responses; } - public Flowable newEventEmitterEventFlowable(EthFilter filter) { + public Flowable newEventEmitterEventFlowable( + final EthFilter filter) { return web3j .ethLogFlowable(filter) .map( new io.reactivex.functions.Function() { @Override - public NewEventEmitterEventResponse apply(Log log) { + public NewEventEmitterEventResponse apply(final Log log) { Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(NEWEVENTEMITTER_EVENT, log); NewEventEmitterEventResponse typedResponse = new NewEventEmitterEventResponse(); @@ -199,7 +200,7 @@ public class CrossContractReader extends Contract { } public Flowable newEventEmitterEventFlowable( - DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + final DefaultBlockParameter startBlock, final DefaultBlockParameter endBlock) { EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); filter.addSingleTopic(EventEncoder.encode(NEWEVENTEMITTER_EVENT)); return newEventEmitterEventFlowable(filter); @@ -207,65 +208,72 @@ public class CrossContractReader extends Contract { @Deprecated public static CrossContractReader load( - String contractAddress, - Web3j web3j, - Credentials credentials, - BigInteger gasPrice, - BigInteger gasLimit) { + final String contractAddress, + final Web3j web3j, + final Credentials credentials, + final BigInteger gasPrice, + final BigInteger gasLimit) { return new CrossContractReader(contractAddress, web3j, credentials, gasPrice, gasLimit); } @Deprecated public static CrossContractReader load( - String contractAddress, - Web3j web3j, - TransactionManager transactionManager, - BigInteger gasPrice, - BigInteger gasLimit) { + final String contractAddress, + final Web3j web3j, + final TransactionManager transactionManager, + final BigInteger gasPrice, + final BigInteger gasLimit) { return new CrossContractReader(contractAddress, web3j, transactionManager, gasPrice, gasLimit); } public static CrossContractReader load( - String contractAddress, - Web3j web3j, - Credentials credentials, - ContractGasProvider contractGasProvider) { + final String contractAddress, + final Web3j web3j, + final Credentials credentials, + final ContractGasProvider contractGasProvider) { return new CrossContractReader(contractAddress, web3j, credentials, contractGasProvider); } public static CrossContractReader load( - String contractAddress, - Web3j web3j, - TransactionManager transactionManager, - ContractGasProvider contractGasProvider) { + final String contractAddress, + final Web3j web3j, + final TransactionManager transactionManager, + final ContractGasProvider contractGasProvider) { return new CrossContractReader(contractAddress, web3j, transactionManager, contractGasProvider); } public static RemoteCall deploy( - Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { + final Web3j web3j, + final Credentials credentials, + final ContractGasProvider contractGasProvider) { return deployRemoteCall( CrossContractReader.class, web3j, credentials, contractGasProvider, BINARY, ""); } @Deprecated public static RemoteCall deploy( - Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { + final Web3j web3j, + final Credentials credentials, + final BigInteger gasPrice, + final BigInteger gasLimit) { return deployRemoteCall( CrossContractReader.class, web3j, credentials, gasPrice, gasLimit, BINARY, ""); } public static RemoteCall deploy( - Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { + final Web3j web3j, + final TransactionManager transactionManager, + final ContractGasProvider contractGasProvider) { return deployRemoteCall( CrossContractReader.class, web3j, transactionManager, contractGasProvider, BINARY, ""); } @Deprecated public static RemoteCall deploy( - Web3j web3j, - TransactionManager transactionManager, - BigInteger gasPrice, - BigInteger gasLimit) { + final Web3j web3j, + final TransactionManager transactionManager, + final BigInteger gasPrice, + final BigInteger gasLimit) { return deployRemoteCall( CrossContractReader.class, web3j, transactionManager, gasPrice, gasLimit, BINARY, ""); } diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/web3j/generated/EventEmitter.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/web3j/generated/EventEmitter.java index d850739f74..6153433b0b 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/web3j/generated/EventEmitter.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/web3j/generated/EventEmitter.java @@ -71,37 +71,37 @@ public class EventEmitter extends Contract { @Deprecated protected EventEmitter( - String contractAddress, - Web3j web3j, - Credentials credentials, - BigInteger gasPrice, - BigInteger gasLimit) { + final String contractAddress, + final Web3j web3j, + final Credentials credentials, + final BigInteger gasPrice, + final BigInteger gasLimit) { super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit); } protected EventEmitter( - String contractAddress, - Web3j web3j, - Credentials credentials, - ContractGasProvider contractGasProvider) { + final String contractAddress, + final Web3j web3j, + final Credentials credentials, + final ContractGasProvider contractGasProvider) { super(BINARY, contractAddress, web3j, credentials, contractGasProvider); } @Deprecated protected EventEmitter( - String contractAddress, - Web3j web3j, - TransactionManager transactionManager, - BigInteger gasPrice, - BigInteger gasLimit) { + final String contractAddress, + final Web3j web3j, + final TransactionManager transactionManager, + final BigInteger gasPrice, + final BigInteger gasLimit) { super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit); } protected EventEmitter( - String contractAddress, - Web3j web3j, - TransactionManager transactionManager, - ContractGasProvider contractGasProvider) { + final String contractAddress, + final Web3j web3j, + final TransactionManager transactionManager, + final ContractGasProvider contractGasProvider) { super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider); } @@ -114,7 +114,7 @@ public class EventEmitter extends Contract { return executeRemoteCallSingleValueReturn(function, BigInteger.class); } - public RemoteFunctionCall store(BigInteger _amount) { + public RemoteFunctionCall store(final BigInteger _amount) { final Function function = new Function( FUNC_STORE, @@ -132,7 +132,7 @@ public class EventEmitter extends Contract { return executeRemoteCallSingleValueReturn(function, String.class); } - public List getStoredEvents(TransactionReceipt transactionReceipt) { + public List getStoredEvents(final TransactionReceipt transactionReceipt) { List valueList = extractEventParametersWithLog(STORED_EVENT, transactionReceipt); ArrayList responses = new ArrayList(valueList.size()); @@ -146,13 +146,13 @@ public class EventEmitter extends Contract { return responses; } - public Flowable storedEventFlowable(EthFilter filter) { + public Flowable storedEventFlowable(final EthFilter filter) { return web3j .ethLogFlowable(filter) .map( new io.reactivex.functions.Function() { @Override - public StoredEventResponse apply(Log log) { + public StoredEventResponse apply(final Log log) { Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(STORED_EVENT, log); StoredEventResponse typedResponse = new StoredEventResponse(); @@ -166,7 +166,7 @@ public class EventEmitter extends Contract { } public Flowable storedEventFlowable( - DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + final DefaultBlockParameter startBlock, final DefaultBlockParameter endBlock) { EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); filter.addSingleTopic(EventEncoder.encode(STORED_EVENT)); return storedEventFlowable(filter); @@ -174,64 +174,71 @@ public class EventEmitter extends Contract { @Deprecated public static EventEmitter load( - String contractAddress, - Web3j web3j, - Credentials credentials, - BigInteger gasPrice, - BigInteger gasLimit) { + final String contractAddress, + final Web3j web3j, + final Credentials credentials, + final BigInteger gasPrice, + final BigInteger gasLimit) { return new EventEmitter(contractAddress, web3j, credentials, gasPrice, gasLimit); } @Deprecated public static EventEmitter load( - String contractAddress, - Web3j web3j, - TransactionManager transactionManager, - BigInteger gasPrice, - BigInteger gasLimit) { + final String contractAddress, + final Web3j web3j, + final TransactionManager transactionManager, + final BigInteger gasPrice, + final BigInteger gasLimit) { return new EventEmitter(contractAddress, web3j, transactionManager, gasPrice, gasLimit); } public static EventEmitter load( - String contractAddress, - Web3j web3j, - Credentials credentials, - ContractGasProvider contractGasProvider) { + final String contractAddress, + final Web3j web3j, + final Credentials credentials, + final ContractGasProvider contractGasProvider) { return new EventEmitter(contractAddress, web3j, credentials, contractGasProvider); } public static EventEmitter load( - String contractAddress, - Web3j web3j, - TransactionManager transactionManager, - ContractGasProvider contractGasProvider) { + final String contractAddress, + final Web3j web3j, + final TransactionManager transactionManager, + final ContractGasProvider contractGasProvider) { return new EventEmitter(contractAddress, web3j, transactionManager, contractGasProvider); } public static RemoteCall deploy( - Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { + final Web3j web3j, + final Credentials credentials, + final ContractGasProvider contractGasProvider) { return deployRemoteCall( EventEmitter.class, web3j, credentials, contractGasProvider, BINARY, ""); } public static RemoteCall deploy( - Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { + final Web3j web3j, + final TransactionManager transactionManager, + final ContractGasProvider contractGasProvider) { return deployRemoteCall( EventEmitter.class, web3j, transactionManager, contractGasProvider, BINARY, ""); } @Deprecated public static RemoteCall deploy( - Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { + final Web3j web3j, + final Credentials credentials, + final BigInteger gasPrice, + final BigInteger gasLimit) { return deployRemoteCall(EventEmitter.class, web3j, credentials, gasPrice, gasLimit, BINARY, ""); } @Deprecated public static RemoteCall deploy( - Web3j web3j, - TransactionManager transactionManager, - BigInteger gasPrice, - BigInteger gasLimit) { + final Web3j web3j, + final TransactionManager transactionManager, + final BigInteger gasPrice, + final BigInteger gasLimit) { return deployRemoteCall( EventEmitter.class, web3j, transactionManager, gasPrice, gasLimit, BINARY, ""); } diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/web3j/generated/RevertReason.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/web3j/generated/RevertReason.java index 762f4e6748..5fdea67f4b 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/web3j/generated/RevertReason.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/web3j/generated/RevertReason.java @@ -50,37 +50,37 @@ public class RevertReason extends Contract { @Deprecated protected RevertReason( - String contractAddress, - Web3j web3j, - Credentials credentials, - BigInteger gasPrice, - BigInteger gasLimit) { + final String contractAddress, + final Web3j web3j, + final Credentials credentials, + final BigInteger gasPrice, + final BigInteger gasLimit) { super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit); } protected RevertReason( - String contractAddress, - Web3j web3j, - Credentials credentials, - ContractGasProvider contractGasProvider) { + final String contractAddress, + final Web3j web3j, + final Credentials credentials, + final ContractGasProvider contractGasProvider) { super(BINARY, contractAddress, web3j, credentials, contractGasProvider); } @Deprecated protected RevertReason( - String contractAddress, - Web3j web3j, - TransactionManager transactionManager, - BigInteger gasPrice, - BigInteger gasLimit) { + final String contractAddress, + final Web3j web3j, + final TransactionManager transactionManager, + final BigInteger gasPrice, + final BigInteger gasLimit) { super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit); } protected RevertReason( - String contractAddress, - Web3j web3j, - TransactionManager transactionManager, - ContractGasProvider contractGasProvider) { + final String contractAddress, + final Web3j web3j, + final TransactionManager transactionManager, + final ContractGasProvider contractGasProvider) { super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider); } @@ -104,64 +104,71 @@ public class RevertReason extends Contract { @Deprecated public static RevertReason load( - String contractAddress, - Web3j web3j, - Credentials credentials, - BigInteger gasPrice, - BigInteger gasLimit) { + final String contractAddress, + final Web3j web3j, + final Credentials credentials, + final BigInteger gasPrice, + final BigInteger gasLimit) { return new RevertReason(contractAddress, web3j, credentials, gasPrice, gasLimit); } @Deprecated public static RevertReason load( - String contractAddress, - Web3j web3j, - TransactionManager transactionManager, - BigInteger gasPrice, - BigInteger gasLimit) { + final String contractAddress, + final Web3j web3j, + final TransactionManager transactionManager, + final BigInteger gasPrice, + final BigInteger gasLimit) { return new RevertReason(contractAddress, web3j, transactionManager, gasPrice, gasLimit); } public static RevertReason load( - String contractAddress, - Web3j web3j, - Credentials credentials, - ContractGasProvider contractGasProvider) { + final String contractAddress, + final Web3j web3j, + final Credentials credentials, + final ContractGasProvider contractGasProvider) { return new RevertReason(contractAddress, web3j, credentials, contractGasProvider); } public static RevertReason load( - String contractAddress, - Web3j web3j, - TransactionManager transactionManager, - ContractGasProvider contractGasProvider) { + final String contractAddress, + final Web3j web3j, + final TransactionManager transactionManager, + final ContractGasProvider contractGasProvider) { return new RevertReason(contractAddress, web3j, transactionManager, contractGasProvider); } public static RemoteCall deploy( - Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { + final Web3j web3j, + final Credentials credentials, + final ContractGasProvider contractGasProvider) { return deployRemoteCall( RevertReason.class, web3j, credentials, contractGasProvider, BINARY, ""); } @Deprecated public static RemoteCall deploy( - Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { + final Web3j web3j, + final Credentials credentials, + final BigInteger gasPrice, + final BigInteger gasLimit) { return deployRemoteCall(RevertReason.class, web3j, credentials, gasPrice, gasLimit, BINARY, ""); } public static RemoteCall deploy( - Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { + final Web3j web3j, + final TransactionManager transactionManager, + final ContractGasProvider contractGasProvider) { return deployRemoteCall( RevertReason.class, web3j, transactionManager, contractGasProvider, BINARY, ""); } @Deprecated public static RemoteCall deploy( - Web3j web3j, - TransactionManager transactionManager, - BigInteger gasPrice, - BigInteger gasLimit) { + final Web3j web3j, + final TransactionManager transactionManager, + final BigInteger gasPrice, + final BigInteger gasLimit) { return deployRemoteCall( RevertReason.class, web3j, transactionManager, gasPrice, gasLimit, BINARY, ""); } diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/web3j/generated/SimpleStorage.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/web3j/generated/SimpleStorage.java index 3e592eb1f6..323bfc216b 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/web3j/generated/SimpleStorage.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/web3j/generated/SimpleStorage.java @@ -52,41 +52,41 @@ public class SimpleStorage extends Contract { @Deprecated protected SimpleStorage( - String contractAddress, - Web3j web3j, - Credentials credentials, - BigInteger gasPrice, - BigInteger gasLimit) { + final String contractAddress, + final Web3j web3j, + final Credentials credentials, + final BigInteger gasPrice, + final BigInteger gasLimit) { super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit); } protected SimpleStorage( - String contractAddress, - Web3j web3j, - Credentials credentials, - ContractGasProvider contractGasProvider) { + final String contractAddress, + final Web3j web3j, + final Credentials credentials, + final ContractGasProvider contractGasProvider) { super(BINARY, contractAddress, web3j, credentials, contractGasProvider); } @Deprecated protected SimpleStorage( - String contractAddress, - Web3j web3j, - TransactionManager transactionManager, - BigInteger gasPrice, - BigInteger gasLimit) { + final String contractAddress, + final Web3j web3j, + final TransactionManager transactionManager, + final BigInteger gasPrice, + final BigInteger gasLimit) { super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit); } protected SimpleStorage( - String contractAddress, - Web3j web3j, - TransactionManager transactionManager, - ContractGasProvider contractGasProvider) { + final String contractAddress, + final Web3j web3j, + final TransactionManager transactionManager, + final ContractGasProvider contractGasProvider) { super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider); } - public RemoteCall set(BigInteger value) { + public RemoteCall set(final BigInteger value) { final Function function = new Function( FUNC_SET, @@ -106,65 +106,72 @@ public class SimpleStorage extends Contract { @Deprecated public static SimpleStorage load( - String contractAddress, - Web3j web3j, - Credentials credentials, - BigInteger gasPrice, - BigInteger gasLimit) { + final String contractAddress, + final Web3j web3j, + final Credentials credentials, + final BigInteger gasPrice, + final BigInteger gasLimit) { return new SimpleStorage(contractAddress, web3j, credentials, gasPrice, gasLimit); } @Deprecated public static SimpleStorage load( - String contractAddress, - Web3j web3j, - TransactionManager transactionManager, - BigInteger gasPrice, - BigInteger gasLimit) { + final String contractAddress, + final Web3j web3j, + final TransactionManager transactionManager, + final BigInteger gasPrice, + final BigInteger gasLimit) { return new SimpleStorage(contractAddress, web3j, transactionManager, gasPrice, gasLimit); } public static SimpleStorage load( - String contractAddress, - Web3j web3j, - Credentials credentials, - ContractGasProvider contractGasProvider) { + final String contractAddress, + final Web3j web3j, + final Credentials credentials, + final ContractGasProvider contractGasProvider) { return new SimpleStorage(contractAddress, web3j, credentials, contractGasProvider); } public static SimpleStorage load( - String contractAddress, - Web3j web3j, - TransactionManager transactionManager, - ContractGasProvider contractGasProvider) { + final String contractAddress, + final Web3j web3j, + final TransactionManager transactionManager, + final ContractGasProvider contractGasProvider) { return new SimpleStorage(contractAddress, web3j, transactionManager, contractGasProvider); } public static RemoteCall deploy( - Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { + final Web3j web3j, + final Credentials credentials, + final ContractGasProvider contractGasProvider) { return deployRemoteCall( SimpleStorage.class, web3j, credentials, contractGasProvider, BINARY, ""); } @Deprecated public static RemoteCall deploy( - Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { + final Web3j web3j, + final Credentials credentials, + final BigInteger gasPrice, + final BigInteger gasLimit) { return deployRemoteCall( SimpleStorage.class, web3j, credentials, gasPrice, gasLimit, BINARY, ""); } public static RemoteCall deploy( - Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { + final Web3j web3j, + final TransactionManager transactionManager, + final ContractGasProvider contractGasProvider) { return deployRemoteCall( SimpleStorage.class, web3j, transactionManager, contractGasProvider, BINARY, ""); } @Deprecated public static RemoteCall deploy( - Web3j web3j, - TransactionManager transactionManager, - BigInteger gasPrice, - BigInteger gasLimit) { + final Web3j web3j, + final TransactionManager transactionManager, + final BigInteger gasPrice, + final BigInteger gasLimit) { return deployRemoteCall( SimpleStorage.class, web3j, transactionManager, gasPrice, gasLimit, BINARY, ""); } diff --git a/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java b/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java index 003e2e5578..d7d79811f3 100644 --- a/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java @@ -113,7 +113,7 @@ public class RunnerBuilder { private BesuController besuController; private NetworkingConfiguration networkingConfiguration = NetworkingConfiguration.create(); - private Collection bannedNodeIds = new ArrayList<>(); + private final Collection bannedNodeIds = new ArrayList<>(); private boolean p2pEnabled = true; private boolean discovery; private String p2pAdvertisedHost; diff --git a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java index 2d4abde7b6..e153aed480 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java @@ -339,7 +339,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable { + " (default: MAINNET)") private final NetworkName network = null; - @SuppressWarnings("FieldMayBeFinal") // Because PicoCLI requires Strings to not be final. + @SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"}) // PicoCLI requires non-final Strings. @Option( names = {"--p2p-host"}, paramLabel = MANDATORY_HOST_FORMAT_HELP, @@ -347,6 +347,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable { arity = "1") private String p2pHost = autoDiscoverDefaultIP().getHostAddress(); + @SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"}) // PicoCLI requires non-final Strings. @Option( names = {"--p2p-interface"}, paramLabel = MANDATORY_HOST_FORMAT_HELP, @@ -382,7 +383,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable { description = "Set to start the GraphQL HTTP service (default: ${DEFAULT-VALUE})") private final Boolean isGraphQLHttpEnabled = false; - @SuppressWarnings("FieldMayBeFinal") // Because PicoCLI requires Strings to not be final. + @SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"}) // PicoCLI requires non-final Strings. @Option( names = {"--graphql-http-host"}, paramLabel = MANDATORY_HOST_FORMAT_HELP, @@ -408,7 +409,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable { description = "Set to start the JSON-RPC HTTP service (default: ${DEFAULT-VALUE})") private final Boolean isRpcHttpEnabled = false; - @SuppressWarnings("FieldMayBeFinal") // Because PicoCLI requires Strings to not be final. + @SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"}) // PicoCLI requires non-final Strings. @Option( names = {"--rpc-http-host"}, paramLabel = MANDATORY_HOST_FORMAT_HELP, @@ -451,7 +452,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable { description = "Set to start the JSON-RPC WebSocket service (default: ${DEFAULT-VALUE})") private final Boolean isRpcWsEnabled = false; - @SuppressWarnings("FieldMayBeFinal") // Because PicoCLI requires Strings to not be final. + @SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"}) // PicoCLI requires non-final Strings. @Option( names = {"--rpc-ws-host"}, paramLabel = MANDATORY_HOST_FORMAT_HELP, @@ -487,7 +488,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable { description = "Set to start the metrics exporter (default: ${DEFAULT-VALUE})") private final Boolean isMetricsEnabled = false; - @SuppressWarnings("FieldMayBeFinal") // Because PicoCLI requires Strings to not be final. + @SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"}) // PicoCLI requires non-final Strings. @Option( names = {"--metrics-host"}, paramLabel = MANDATORY_HOST_FORMAT_HELP, @@ -516,7 +517,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable { description = "Enable the metrics push gateway integration (default: ${DEFAULT-VALUE})") private final Boolean isMetricsPushEnabled = false; - @SuppressWarnings("FieldMayBeFinal") // Because PicoCLI requires Strings to not be final. + @SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"}) // PicoCLI requires non-final Strings. @Option( names = {"--metrics-push-host"}, paramLabel = MANDATORY_HOST_FORMAT_HELP, @@ -539,7 +540,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable { arity = "1") private final Integer metricsPushInterval = 15; - @SuppressWarnings("FieldMayBeFinal") // Because PicoCLI requires Strings to not be final. + @SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"}) // PicoCLI requires non-final Strings. @Option( names = {"--metrics-push-prometheus-job"}, description = "Job name to use when in push mode (default: ${DEFAULT-VALUE})", @@ -571,7 +572,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable { description = "Set if node will perform Stratum mining (default: ${DEFAULT-VALUE})") private final Boolean iStratumMiningEnabled = false; - @SuppressWarnings("FieldMayBeFinal") // Because PicoCLI requires Strings to not be final. + @SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"}) // PicoCLI requires non-final Strings. @Option( names = {"--miner-stratum-host"}, description = "Host for Stratum network mining service (default: ${DEFAULT-VALUE})") @@ -582,7 +583,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable { description = "Stratum port binding (default: ${DEFAULT-VALUE})") private final Integer stratumPort = 8008; - @SuppressWarnings("FieldMayBeFinal") // Because PicoCLI requires Strings to not be final. + @SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"}) // PicoCLI requires non-final Strings. @Option( hidden = true, names = {"--Xminer-stratum-extranonce"}, @@ -717,7 +718,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable { private final Integer pendingTxRetentionPeriod = TransactionPoolConfiguration.DEFAULT_TX_RETENTION_HOURS; - @SuppressWarnings("FieldMayBeFinal") // Because PicoCLI requires Strings to not be final. + @SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"}) // PicoCLI requires non-final Strings. @Option( names = {"--key-value-storage"}, description = "Identity for the key-value storage to be used.", diff --git a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/PasswordSubCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/PasswordSubCommand.java index 09baa48985..017917b844 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/PasswordSubCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/PasswordSubCommand.java @@ -63,7 +63,7 @@ public class PasswordSubCommand implements Runnable { mixinStandardHelpOptions = true) static class HashSubCommand implements Runnable { - @SuppressWarnings("FieldMustBeFinal") + @SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"}) // PicoCLI requires non-final Strings. @Option( names = "--password", arity = "1..1", diff --git a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/PublicKeySubCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/PublicKeySubCommand.java index 78e528b393..9fc2d59386 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/PublicKeySubCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/PublicKeySubCommand.java @@ -103,7 +103,7 @@ public class PublicKeySubCommand implements Runnable { paramLabel = DefaultCommandValues.MANDATORY_FILE_FORMAT_HELP, description = "File to write public key to instead of standard output", arity = "1..1") - private File publicKeyExportFile = null; + private final File publicKeyExportFile = null; @SuppressWarnings("unused") @ParentCommand @@ -155,7 +155,7 @@ public class PublicKeySubCommand implements Runnable { paramLabel = DefaultCommandValues.MANDATORY_FILE_FORMAT_HELP, description = "File to write address to instead of standard output", arity = "1..1") - private File addressExportFile = null; + private final File addressExportFile = null; @SuppressWarnings("unused") @ParentCommand diff --git a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/RetestethSubCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/RetestethSubCommand.java index f412da725f..a4c536fada 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/RetestethSubCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/RetestethSubCommand.java @@ -64,7 +64,7 @@ public class RetestethSubCommand implements Runnable { "Logging verbosity levels: OFF, FATAL, ERROR, WARN, INFO, DEBUG, TRACE, ALL (default: ${DEFAULT-VALUE})") private final Level logLevel = LogManager.getRootLogger().getLevel(); - @SuppressWarnings("FieldMayBeFinal") // Because PicoCLI requires Strings to not be final. + @SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"}) // PicoCLI requires non-final Strings. @Option( names = {"--rpc-http-host"}, paramLabel = DefaultCommandValues.MANDATORY_HOST_FORMAT_HELP, diff --git a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/blocks/BlocksSubCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/blocks/BlocksSubCommand.java index d91bc61f75..1c13a8b044 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/blocks/BlocksSubCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/blocks/BlocksSubCommand.java @@ -253,7 +253,7 @@ public class BlocksSubCommand implements Runnable { paramLabel = DefaultCommandValues.MANDATORY_FILE_FORMAT_HELP, description = "File to write the block list to.", arity = "1..1") - private File blocksExportFile = null; + private final File blocksExportFile = null; @SuppressWarnings("unused") @Spec diff --git a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/GenerateBlockchainConfig.java b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/GenerateBlockchainConfig.java index 79185cb918..32a235e04c 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/GenerateBlockchainConfig.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/GenerateBlockchainConfig.java @@ -60,7 +60,7 @@ class GenerateBlockchainConfig implements Runnable { paramLabel = DefaultCommandValues.MANDATORY_FILE_FORMAT_HELP, description = "Configuration file.", arity = "1..1") - private File configurationFile = null; + private final File configurationFile = null; @Option( required = true, @@ -68,8 +68,9 @@ class GenerateBlockchainConfig implements Runnable { paramLabel = DefaultCommandValues.MANDATORY_DIRECTORY_FORMAT_HELP, description = "Directory to write output files to.", arity = "1..1") - private File outputDirectory = null; + private final File outputDirectory = null; + @SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"}) // PicoCLI requires non-final Strings. @Option( names = "--genesis-file-name", paramLabel = DefaultCommandValues.MANDATORY_PATH_FORMAT_HELP, @@ -77,6 +78,7 @@ class GenerateBlockchainConfig implements Runnable { arity = "1..1") private String genesisFileName = "genesis.json"; + @SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"}) // PicoCLI requires non-final Strings. @Option( names = "--private-key-file-name", paramLabel = DefaultCommandValues.MANDATORY_PATH_FORMAT_HELP, @@ -84,6 +86,7 @@ class GenerateBlockchainConfig implements Runnable { arity = "1..1") private String privateKeyFileName = "key.priv"; + @SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"}) // PicoCLI requires non-final Strings. @Option( names = "--public-key-file-name", paramLabel = DefaultCommandValues.MANDATORY_PATH_FORMAT_HELP, @@ -99,7 +102,7 @@ class GenerateBlockchainConfig implements Runnable { private ObjectNode blockchainConfig; private ObjectNode nodesConfig; private boolean generateNodesKeys; - private List
addressesForGenesisExtraData = new ArrayList<>(); + private final List
addressesForGenesisExtraData = new ArrayList<>(); private Path keysDirectory; @Override diff --git a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/rlp/RLPSubCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/rlp/RLPSubCommand.java index 5e555735f4..271da4689c 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/rlp/RLPSubCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/rlp/RLPSubCommand.java @@ -95,21 +95,21 @@ public class RLPSubCommand implements Runnable { description = "Type of the RLP data to encode, possible values are ${COMPLETION-CANDIDATES}. (default: ${DEFAULT-VALUE})", arity = "1..1") - private RLPType type = RLPType.IBFT_EXTRA_DATA; + private final RLPType type = RLPType.IBFT_EXTRA_DATA; @Option( names = "--from", paramLabel = DefaultCommandValues.MANDATORY_FILE_FORMAT_HELP, description = "File containing JSON object to encode", arity = "1..1") - private File jsonSourceFile = null; + private final File jsonSourceFile = null; @Option( names = "--to", paramLabel = DefaultCommandValues.MANDATORY_FILE_FORMAT_HELP, description = "File to write encoded RLP string to.", arity = "1..1") - private File rlpTargetFile = null; + private final File rlpTargetFile = null; @Override public void run() { diff --git a/besu/src/main/java/org/hyperledger/besu/services/BesuEventsImpl.java b/besu/src/main/java/org/hyperledger/besu/services/BesuEventsImpl.java index 7dc2578eb7..9856377339 100644 --- a/besu/src/main/java/org/hyperledger/besu/services/BesuEventsImpl.java +++ b/besu/src/main/java/org/hyperledger/besu/services/BesuEventsImpl.java @@ -38,7 +38,7 @@ import java.util.function.Supplier; import org.apache.tuweni.bytes.Bytes; public class BesuEventsImpl implements BesuEvents { - private Blockchain blockchain; + private final Blockchain blockchain; private final BlockBroadcaster blockBroadcaster; private final TransactionPool transactionPool; private final SyncState syncState; diff --git a/besu/src/test/java/org/hyperledger/besu/cli/operator/OperatorSubCommandTest.java b/besu/src/test/java/org/hyperledger/besu/cli/operator/OperatorSubCommandTest.java index 14bf8779b1..28b0ab48f5 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/operator/OperatorSubCommandTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/operator/OperatorSubCommandTest.java @@ -245,7 +245,7 @@ public class OperatorSubCommandTest extends CommandTestAbstract { } static class Cmd { - private List args; + private final List args; private Cmd(final List args) { this.args = args; diff --git a/build.gradle b/build.gradle index cc88b641cd..3ed5678c6e 100644 --- a/build.gradle +++ b/build.gradle @@ -189,8 +189,6 @@ allprojects { check('ImmutableEnumChecker', CheckSeverity.OFF) // This is a style check instead of an error-prone pattern. check('UnnecessaryParentheses', CheckSeverity.OFF) - // Lazy impl causes excess CPU usage O(n) of non-final fiield when it should be O(1). - check('FieldCanBeFinal', CheckSeverity.OFF) // This check is broken in Java 12. See https://github.com/google/error-prone/issues/1257 if (JavaVersion.current() == JavaVersion.VERSION_12) { @@ -201,6 +199,7 @@ allprojects { check('TypeParameterUnusedInFormals', CheckSeverity.OFF) } + check('FieldCanBeFinal', CheckSeverity.WARN) check('InsecureCryptoUsage', CheckSeverity.WARN) check('WildcardImport', CheckSeverity.WARN) } diff --git a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/VoteTallyCache.java b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/VoteTallyCache.java index d1639a9ef4..f1c4ad955e 100644 --- a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/VoteTallyCache.java +++ b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/VoteTallyCache.java @@ -36,7 +36,7 @@ public class VoteTallyCache { private final Cache voteTallyCache = CacheBuilder.newBuilder().maximumSize(100).build(); - private BlockInterface blockInterface; + private final BlockInterface blockInterface; public VoteTallyCache( final Blockchain blockchain, diff --git a/consensus/ibft/src/integration-test/java/org/hyperledger/besu/consensus/ibft/support/StubbedSynchronizerUpdater.java b/consensus/ibft/src/integration-test/java/org/hyperledger/besu/consensus/ibft/support/StubbedSynchronizerUpdater.java index d7bc4c5be1..d45b3a2af5 100644 --- a/consensus/ibft/src/integration-test/java/org/hyperledger/besu/consensus/ibft/support/StubbedSynchronizerUpdater.java +++ b/consensus/ibft/src/integration-test/java/org/hyperledger/besu/consensus/ibft/support/StubbedSynchronizerUpdater.java @@ -26,7 +26,7 @@ import java.util.stream.Collectors; public class StubbedSynchronizerUpdater implements SynchronizerUpdater { - private Map validatorNodes = new HashMap<>(); + private final Map validatorNodes = new HashMap<>(); @Override public void updatePeerChainState( diff --git a/consensus/ibft/src/integration-test/java/org/hyperledger/besu/consensus/ibft/support/TestContextBuilder.java b/consensus/ibft/src/integration-test/java/org/hyperledger/besu/consensus/ibft/support/TestContextBuilder.java index f18f8f7c42..42d322d6bf 100644 --- a/consensus/ibft/src/integration-test/java/org/hyperledger/besu/consensus/ibft/support/TestContextBuilder.java +++ b/consensus/ibft/src/integration-test/java/org/hyperledger/besu/consensus/ibft/support/TestContextBuilder.java @@ -89,14 +89,14 @@ import org.apache.tuweni.bytes.Bytes; public class TestContextBuilder { - private static MetricsSystem metricsSystem = new NoOpMetricsSystem(); + private static final MetricsSystem metricsSystem = new NoOpMetricsSystem(); private static class ControllerAndState { private final IbftExecutors ibftExecutors; - private IbftController controller; - private IbftFinalState finalState; - private EventMultiplexer eventMultiplexer; + private final IbftController controller; + private final IbftFinalState finalState; + private final EventMultiplexer eventMultiplexer; public ControllerAndState( final IbftExecutors ibftExecutors, diff --git a/consensus/ibft/src/integration-test/java/org/hyperledger/besu/consensus/ibft/tests/SpuriousBehaviourTest.java b/consensus/ibft/src/integration-test/java/org/hyperledger/besu/consensus/ibft/tests/SpuriousBehaviourTest.java index 25c04c6a15..3af24ecebd 100644 --- a/consensus/ibft/src/integration-test/java/org/hyperledger/besu/consensus/ibft/tests/SpuriousBehaviourTest.java +++ b/consensus/ibft/src/integration-test/java/org/hyperledger/besu/consensus/ibft/tests/SpuriousBehaviourTest.java @@ -63,7 +63,7 @@ public class SpuriousBehaviourTest { private final ConsensusRoundIdentifier roundId = new ConsensusRoundIdentifier(1, 0); private final RoundSpecificPeers peers = context.roundSpecificPeers(roundId); - private Block proposedBlock = context.createBlockForProposalFromChainHead(0, 30); + private final Block proposedBlock = context.createBlockForProposalFromChainHead(0, 30); private Prepare expectedPrepare; private Commit expectedCommit; diff --git a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/IbftProcessor.java b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/IbftProcessor.java index 9f7fd892f6..86ad206bd3 100644 --- a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/IbftProcessor.java +++ b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/IbftProcessor.java @@ -31,7 +31,7 @@ public class IbftProcessor implements Runnable { private final IbftEventQueue incomingQueue; private volatile boolean shutdown = false; private final EventMultiplexer eventMultiplexer; - private CountDownLatch shutdownLatch = new CountDownLatch(1); + private final CountDownLatch shutdownLatch = new CountDownLatch(1); /** * Construct a new IbftProcessor diff --git a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/blockcreation/IbftMiningCoordinator.java b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/blockcreation/IbftMiningCoordinator.java index fe33f249d6..b983f4eb97 100644 --- a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/blockcreation/IbftMiningCoordinator.java +++ b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/blockcreation/IbftMiningCoordinator.java @@ -56,7 +56,7 @@ public class IbftMiningCoordinator implements MiningCoordinator, BlockAddedObser private final IbftExecutors ibftExecutors; private long blockAddedObserverId; - private AtomicReference state = new AtomicReference<>(State.IDLE); + private final AtomicReference state = new AtomicReference<>(State.IDLE); public IbftMiningCoordinator( final IbftExecutors ibftExecutors, diff --git a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/validation/MessageValidator.java b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/validation/MessageValidator.java index ff3877a205..3eb3980ef6 100644 --- a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/validation/MessageValidator.java +++ b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/validation/MessageValidator.java @@ -39,7 +39,7 @@ public class MessageValidator { private final ProposalBlockConsistencyValidator proposalConsistencyValidator; private final BlockValidator blockValidator; private final ProtocolContext protocolContext; - private RoundChangeCertificateValidator roundChangeCertificateValidator; + private final RoundChangeCertificateValidator roundChangeCertificateValidator; public MessageValidator( final SignedDataValidator signedDataValidator, diff --git a/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/statemachine/FutureMessageBufferTest.java b/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/statemachine/FutureMessageBufferTest.java index 033c1ac7d3..e082c27670 100644 --- a/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/statemachine/FutureMessageBufferTest.java +++ b/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/statemachine/FutureMessageBufferTest.java @@ -36,7 +36,7 @@ import org.junit.Test; public class FutureMessageBufferTest { private Message message; private FutureMessageBuffer futureMsgBuffer; - private PeerConnection peerConnection = MockPeerFactory.create(AddressHelpers.ofValue(9)); + private final PeerConnection peerConnection = MockPeerFactory.create(AddressHelpers.ofValue(9)); @Before public void setup() { diff --git a/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/validation/MessageValidatorTest.java b/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/validation/MessageValidatorTest.java index efda797b29..f54413600c 100644 --- a/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/validation/MessageValidatorTest.java +++ b/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/validation/MessageValidatorTest.java @@ -55,12 +55,12 @@ import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class MessageValidatorTest { - private KeyPair keyPair = KeyPair.generate(); - private MessageFactory messageFactory = new MessageFactory(keyPair); - private ConsensusRoundIdentifier roundIdentifier = new ConsensusRoundIdentifier(1, 0); + private final KeyPair keyPair = KeyPair.generate(); + private final MessageFactory messageFactory = new MessageFactory(keyPair); + private final ConsensusRoundIdentifier roundIdentifier = new ConsensusRoundIdentifier(1, 0); - private SignedDataValidator signedDataValidator = mock(SignedDataValidator.class); - private ProposalBlockConsistencyValidator proposalBlockConsistencyValidator = + private final SignedDataValidator signedDataValidator = mock(SignedDataValidator.class); + private final ProposalBlockConsistencyValidator proposalBlockConsistencyValidator = mock(ProposalBlockConsistencyValidator.class); @Mock private BlockValidator blockValidator; diff --git a/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/validation/RoundChangeMessageValidatorTest.java b/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/validation/RoundChangeMessageValidatorTest.java index 1bc52197f4..0761fe5086 100644 --- a/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/validation/RoundChangeMessageValidatorTest.java +++ b/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/validation/RoundChangeMessageValidatorTest.java @@ -34,7 +34,7 @@ public class RoundChangeMessageValidatorTest { private final MessageFactory messageFactory = new MessageFactory(keyPair); private final ConsensusRoundIdentifier roundIdentifier = new ConsensusRoundIdentifier(1, 1); - private ProposalBlockConsistencyValidator proposalBlockConsistencyValidator = + private final ProposalBlockConsistencyValidator proposalBlockConsistencyValidator = mock(ProposalBlockConsistencyValidator.class); private final RoundChangeMessageValidator validator = diff --git a/crypto/src/main/java/org/hyperledger/besu/crypto/altbn128/AltBn128Fq2Point.java b/crypto/src/main/java/org/hyperledger/besu/crypto/altbn128/AltBn128Fq2Point.java index 5b438b4c75..2285ba8e0c 100644 --- a/crypto/src/main/java/org/hyperledger/besu/crypto/altbn128/AltBn128Fq2Point.java +++ b/crypto/src/main/java/org/hyperledger/besu/crypto/altbn128/AltBn128Fq2Point.java @@ -21,7 +21,7 @@ import java.math.BigInteger; * https://github.com/ethereum/py_ecc/blob/master/py_ecc/bn128/bn128_field_elements.py */ public class AltBn128Fq2Point extends AbstractFieldPoint { - private static BigInteger CURVE_ORDER = + private static final BigInteger CURVE_ORDER = new BigInteger( "21888242871839275222246405745257275088548364400416034343698204186575808495617", 10); diff --git a/enclave/src/main/java/org/hyperledger/besu/enclave/EnclaveServerException.java b/enclave/src/main/java/org/hyperledger/besu/enclave/EnclaveServerException.java index a0e0fd4032..33bd1bb595 100644 --- a/enclave/src/main/java/org/hyperledger/besu/enclave/EnclaveServerException.java +++ b/enclave/src/main/java/org/hyperledger/besu/enclave/EnclaveServerException.java @@ -15,7 +15,7 @@ package org.hyperledger.besu.enclave; public class EnclaveServerException extends RuntimeException { - private int statusCode; + private final int statusCode; public EnclaveServerException(final int statusCode, final String message) { super(message); diff --git a/enclave/src/main/java/org/hyperledger/besu/enclave/types/ReceiveRequest.java b/enclave/src/main/java/org/hyperledger/besu/enclave/types/ReceiveRequest.java index 0b6e3649a7..ee2e3cb0cd 100644 --- a/enclave/src/main/java/org/hyperledger/besu/enclave/types/ReceiveRequest.java +++ b/enclave/src/main/java/org/hyperledger/besu/enclave/types/ReceiveRequest.java @@ -19,8 +19,8 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder; @JsonPropertyOrder({"key", "to"}) public class ReceiveRequest { - private String key; - private String to; + private final String key; + private final String to; public ReceiveRequest( @JsonProperty(value = "key") final String key, @JsonProperty(value = "to") final String to) { diff --git a/enclave/src/main/java/org/hyperledger/besu/enclave/types/SendRequest.java b/enclave/src/main/java/org/hyperledger/besu/enclave/types/SendRequest.java index 0f380c747f..fd85138b19 100644 --- a/enclave/src/main/java/org/hyperledger/besu/enclave/types/SendRequest.java +++ b/enclave/src/main/java/org/hyperledger/besu/enclave/types/SendRequest.java @@ -17,8 +17,8 @@ package org.hyperledger.besu.enclave.types; import static java.nio.charset.StandardCharsets.UTF_8; public abstract class SendRequest { - private byte[] payload; - private String from; + private final byte[] payload; + private final String from; public SendRequest(final String payload, final String from) { this.payload = payload.getBytes(UTF_8); diff --git a/enclave/src/main/java/org/hyperledger/besu/enclave/types/SendRequestBesu.java b/enclave/src/main/java/org/hyperledger/besu/enclave/types/SendRequestBesu.java index 54e92c1f0a..40ea28dfe9 100644 --- a/enclave/src/main/java/org/hyperledger/besu/enclave/types/SendRequestBesu.java +++ b/enclave/src/main/java/org/hyperledger/besu/enclave/types/SendRequestBesu.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder; @JsonPropertyOrder({"payload", "from", "privacyGroupId"}) public class SendRequestBesu extends SendRequest { - private String privacyGroupId; + private final String privacyGroupId; public SendRequestBesu( @JsonProperty(value = "payload") final String payload, diff --git a/enclave/src/main/java/org/hyperledger/besu/enclave/types/SendRequestLegacy.java b/enclave/src/main/java/org/hyperledger/besu/enclave/types/SendRequestLegacy.java index abd429bd1e..986b27f13f 100644 --- a/enclave/src/main/java/org/hyperledger/besu/enclave/types/SendRequestLegacy.java +++ b/enclave/src/main/java/org/hyperledger/besu/enclave/types/SendRequestLegacy.java @@ -21,7 +21,7 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder; @JsonPropertyOrder({"payload", "from", "to"}) public class SendRequestLegacy extends SendRequest { - private List to; + private final List to; public SendRequestLegacy( @JsonProperty(value = "payload") final String payload, diff --git a/enclave/src/main/java/org/hyperledger/besu/enclave/types/SendResponse.java b/enclave/src/main/java/org/hyperledger/besu/enclave/types/SendResponse.java index 969e10bbce..411fa50045 100644 --- a/enclave/src/main/java/org/hyperledger/besu/enclave/types/SendResponse.java +++ b/enclave/src/main/java/org/hyperledger/besu/enclave/types/SendResponse.java @@ -20,7 +20,7 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder; @JsonPropertyOrder({"key"}) public class SendResponse { - private String key; + private final String key; @JsonCreator public SendResponse(@JsonProperty("key") final String key) { diff --git a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/PrivGetPrivateTransactionIntegrationTest.java b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/PrivGetPrivateTransactionIntegrationTest.java index ee54531158..b583015ef3 100644 --- a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/PrivGetPrivateTransactionIntegrationTest.java +++ b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/PrivGetPrivateTransactionIntegrationTest.java @@ -75,9 +75,9 @@ public class PrivGetPrivateTransactionIntegrationTest { private final Transaction justTransaction = mock(Transaction.class); - private static Vertx vertx = Vertx.vertx(); + private static final Vertx vertx = Vertx.vertx(); - private EnclavePublicKeyProvider enclavePublicKeyProvider = (user) -> ENCLAVE_PUBLIC_KEY; + private final EnclavePublicKeyProvider enclavePublicKeyProvider = (user) -> ENCLAVE_PUBLIC_KEY; @BeforeClass public static void setUpOnce() throws Exception { diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/RpcMethod.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/RpcMethod.java index f525912923..a695643ec9 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/RpcMethod.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/RpcMethod.java @@ -118,7 +118,7 @@ public enum RpcMethod { private final String methodName; - private static Collection allMethodNames; + private static final Collection allMethodNames; public String getMethodName() { return methodName; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/authentication/TomlUser.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/authentication/TomlUser.java index 856d8858a5..79a2d28807 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/authentication/TomlUser.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/authentication/TomlUser.java @@ -30,7 +30,7 @@ public class TomlUser extends AbstractUser { private final List groups; private final List permissions; private final List roles; - private Optional privacyPublicKey; + private final Optional privacyPublicKey; TomlUser( final String username, diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/TraceTypeParameter.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/TraceTypeParameter.java index 6adb5b52d1..93203c6e62 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/TraceTypeParameter.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/TraceTypeParameter.java @@ -47,7 +47,7 @@ public class TraceTypeParameter { } } - private Set traceTypes; + private final Set traceTypes; @JsonCreator public TraceTypeParameter(final List traceTypesInput) { diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/MultiTenancyRpcMethodDecorator.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/MultiTenancyRpcMethodDecorator.java index fdd2b64331..cb443a169e 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/MultiTenancyRpcMethodDecorator.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/MultiTenancyRpcMethodDecorator.java @@ -29,7 +29,7 @@ import org.apache.logging.log4j.Logger; public class MultiTenancyRpcMethodDecorator implements JsonRpcMethod { private static final Logger LOG = getLogger(); - private JsonRpcMethod rpcMethod; + private final JsonRpcMethod rpcMethod; public MultiTenancyRpcMethodDecorator(final JsonRpcMethod rpcMethod) { this.rpcMethod = rpcMethod; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/PrivacySendTransaction.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/PrivacySendTransaction.java index 8750a1f349..b2640e0926 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/PrivacySendTransaction.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/PrivacySendTransaction.java @@ -37,7 +37,7 @@ public class PrivacySendTransaction { private static final Logger LOG = LogManager.getLogger(); protected final PrivacyController privacyController; - private EnclavePublicKeyProvider enclavePublicKeyProvider; + private final EnclavePublicKeyProvider enclavePublicKeyProvider; public PrivacySendTransaction( final PrivacyController privacyController, diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/EeaSendRawTransaction.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/EeaSendRawTransaction.java index 918b1d2c52..ac5206f9f1 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/EeaSendRawTransaction.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/EeaSendRawTransaction.java @@ -34,9 +34,9 @@ import org.hyperledger.besu.ethereum.privacy.SendTransactionResponse; public class EeaSendRawTransaction implements JsonRpcMethod { private final PrivacySendTransaction privacySendTransaction; - private EnclavePublicKeyProvider enclavePublicKeyProvider; - private TransactionPool transactionPool; - private PrivacyController privacyController; + private final EnclavePublicKeyProvider enclavePublicKeyProvider; + private final TransactionPool transactionPool; + private final PrivacyController privacyController; public EeaSendRawTransaction( final TransactionPool transactionPool, diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivCreatePrivacyGroup.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivCreatePrivacyGroup.java index 23e9241216..0bb9d00d42 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivCreatePrivacyGroup.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivCreatePrivacyGroup.java @@ -33,8 +33,8 @@ import org.apache.logging.log4j.Logger; public class PrivCreatePrivacyGroup implements JsonRpcMethod { private static final Logger LOG = getLogger(); - private PrivacyController privacyController; - private EnclavePublicKeyProvider enclavePublicKeyProvider; + private final PrivacyController privacyController; + private final EnclavePublicKeyProvider enclavePublicKeyProvider; public PrivCreatePrivacyGroup( final PrivacyController privacyController, diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivDeletePrivacyGroup.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivDeletePrivacyGroup.java index c5cc9eb311..82881d50bb 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivDeletePrivacyGroup.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivDeletePrivacyGroup.java @@ -31,8 +31,8 @@ import org.apache.logging.log4j.Logger; public class PrivDeletePrivacyGroup implements JsonRpcMethod { private static final Logger LOG = getLogger(); - private PrivacyController privacyController; - private EnclavePublicKeyProvider enclavePublicKeyProvider; + private final PrivacyController privacyController; + private final EnclavePublicKeyProvider enclavePublicKeyProvider; public PrivDeletePrivacyGroup( final PrivacyController privacyController, diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivDistributeRawTransaction.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivDistributeRawTransaction.java index 68fd288947..31de976a1b 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivDistributeRawTransaction.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivDistributeRawTransaction.java @@ -36,7 +36,7 @@ public class PrivDistributeRawTransaction implements JsonRpcMethod { private final PrivacyController privacyController; private final PrivacySendTransaction privacySendTransaction; - private EnclavePublicKeyProvider enclavePublicKeyProvider; + private final EnclavePublicKeyProvider enclavePublicKeyProvider; public PrivDistributeRawTransaction( final PrivacyController privacyController, diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivFindPrivacyGroup.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivFindPrivacyGroup.java index 16df647db8..7bd8dcfd2b 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivFindPrivacyGroup.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivFindPrivacyGroup.java @@ -34,8 +34,8 @@ import org.apache.logging.log4j.Logger; public class PrivFindPrivacyGroup implements JsonRpcMethod { private static final Logger LOG = getLogger(); - private PrivacyController privacyController; - private EnclavePublicKeyProvider enclavePublicKeyProvider; + private final PrivacyController privacyController; + private final EnclavePublicKeyProvider enclavePublicKeyProvider; public PrivFindPrivacyGroup( final PrivacyController privacyController, diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetEeaTransactionCount.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetEeaTransactionCount.java index dbdc8d55a3..507bf664bc 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetEeaTransactionCount.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetEeaTransactionCount.java @@ -34,8 +34,8 @@ public class PrivGetEeaTransactionCount implements JsonRpcMethod { private static final Logger LOG = getLogger(); - private PrivacyController privacyController; - private EnclavePublicKeyProvider enclavePublicKeyProvider; + private final PrivacyController privacyController; + private final EnclavePublicKeyProvider enclavePublicKeyProvider; public PrivGetEeaTransactionCount( final PrivacyController privacyController, diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetPrivateTransaction.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetPrivateTransaction.java index f1c9e1f5df..ae5501bfa9 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetPrivateTransaction.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetPrivateTransaction.java @@ -42,7 +42,7 @@ public class PrivGetPrivateTransaction implements JsonRpcMethod { private final BlockchainQueries blockchain; private final PrivacyController privacyController; - private EnclavePublicKeyProvider enclavePublicKeyProvider; + private final EnclavePublicKeyProvider enclavePublicKeyProvider; public PrivGetPrivateTransaction( final BlockchainQueries blockchain, diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetTransactionCount.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetTransactionCount.java index dd7d750dc4..7be179791c 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetTransactionCount.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetTransactionCount.java @@ -29,7 +29,7 @@ import org.hyperledger.besu.ethereum.privacy.PrivacyController; public class PrivGetTransactionCount implements JsonRpcMethod { private final PrivacyController privacyController; - private EnclavePublicKeyProvider enclavePublicKeyProvider; + private final EnclavePublicKeyProvider enclavePublicKeyProvider; public PrivGetTransactionCount( final PrivacyController privacyController, diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetTransactionReceipt.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetTransactionReceipt.java index d3dd65a100..d4f97e87b5 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetTransactionReceipt.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetTransactionReceipt.java @@ -55,9 +55,9 @@ public class PrivGetTransactionReceipt implements JsonRpcMethod { private static final Logger LOG = getLogger(); private final BlockchainQueries blockchain; - private PrivacyParameters privacyParameters; - private PrivacyController privacyController; - private EnclavePublicKeyProvider enclavePublicKeyProvider; + private final PrivacyParameters privacyParameters; + private final PrivacyController privacyController; + private final EnclavePublicKeyProvider enclavePublicKeyProvider; public PrivGetTransactionReceipt( final BlockchainQueries blockchain, diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/Action.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/Action.java index 0aeb865053..27cea5d88f 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/Action.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/Action.java @@ -35,16 +35,16 @@ import org.apache.tuweni.bytes.Bytes32; @JsonInclude(NON_NULL) public class Action { - private String callType; - private String from; - private String gas; - private String input; - private String to; - private String init; - private String value; - private String address; - private String balance; - private String refundAddress; + private final String callType; + private final String from; + private final String gas; + private final String input; + private final String to; + private final String init; + private final String value; + private final String address; + private final String balance; + private final String refundAddress; private Action( final String callType, diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/FlatTrace.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/FlatTrace.java index ed997e14ef..f2bfc01adc 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/FlatTrace.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/FlatTrace.java @@ -20,11 +20,11 @@ import java.util.ArrayList; import java.util.List; public class FlatTrace implements Trace { - private Action action; - private Result result; - private int subtraces; - private List traceAddress; - private String type; + private final Action action; + private final Result result; + private final int subtraces; + private final List traceAddress; + private final String type; private FlatTrace( final Action.Builder actionBuilder, @@ -85,7 +85,7 @@ public class FlatTrace implements Trace { public static class Context { - private Builder builder; + private final Builder builder; private boolean returned; private boolean isSubtrace = false; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/Result.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/Result.java index 3206472048..9488e215b0 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/Result.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/Result.java @@ -20,9 +20,9 @@ import com.fasterxml.jackson.annotation.JsonInclude; @JsonInclude(NON_NULL) public class Result { - private String gasUsed; - private String output; - private String code; + private final String gasUsed; + private final String output; + private final String code; public Result( final String gasUsed, final String output, final String code, final String address) { @@ -32,7 +32,7 @@ public class Result { this.address = address; } - private String address; + private final String address; public String getGasUsed() { return gasUsed; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/TransactionLogsIndexer.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/TransactionLogsIndexer.java index 8a566a847d..2de41bc9a3 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/TransactionLogsIndexer.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/TransactionLogsIndexer.java @@ -51,7 +51,7 @@ public class TransactionLogsIndexer { private final Blockchain blockchain; private final Path cacheDir; - private IndexingStatus indexingStatus = new IndexingStatus(); + private final IndexingStatus indexingStatus = new IndexingStatus(); public TransactionLogsIndexer( final Blockchain blockchain, final Path cacheDir, final EthScheduler scheduler) { diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/AbstractJsonRpcHttpBySpecTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/AbstractJsonRpcHttpBySpecTest.java index 1466698b75..29f4e1c75e 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/AbstractJsonRpcHttpBySpecTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/AbstractJsonRpcHttpBySpecTest.java @@ -43,7 +43,7 @@ import org.junit.runners.Parameterized; @RunWith(Parameterized.class) public abstract class AbstractJsonRpcHttpBySpecTest extends AbstractJsonRpcHttpServiceTest { - private static ObjectMapper objectMapper = new ObjectMapper(); + private static final ObjectMapper objectMapper = new ObjectMapper(); private final URL specURL; public AbstractJsonRpcHttpBySpecTest(final String specName, final URL specURL) { diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/LatestNonceProviderTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/LatestNonceProviderTest.java index 43c1d71f27..bc3bb3874f 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/LatestNonceProviderTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/LatestNonceProviderTest.java @@ -30,9 +30,9 @@ public class LatestNonceProviderTest { private final Address senderAdress = Address.fromHexString("1"); - private PendingTransactions pendingTransactions = mock(PendingTransactions.class); - private BlockchainQueries blockchainQueries = mock(BlockchainQueries.class); - private LatestNonceProvider nonceProvider = + private final PendingTransactions pendingTransactions = mock(PendingTransactions.class); + private final BlockchainQueries blockchainQueries = mock(BlockchainQueries.class); + private final LatestNonceProvider nonceProvider = new LatestNonceProvider(blockchainQueries, pendingTransactions); @Test diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/authentication/AuthenticationUtilsTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/authentication/AuthenticationUtilsTest.java index b33c2d7cdd..a3dda2ed72 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/authentication/AuthenticationUtilsTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/authentication/AuthenticationUtilsTest.java @@ -30,13 +30,13 @@ import org.junit.Test; public class AuthenticationUtilsTest { - private static String INVALID_TOKEN_WITHOUT_EXP = + private static final String INVALID_TOKEN_WITHOUT_EXP = "ewogICJhbGciOiAibm9uZSIsCiAgInR5cCI6ICJKV1QiCn" + "0.eyJpYXQiOjE1MTYyMzkwMjIsInBlcm1pc3Npb25zIjpbIm5ldDpwZWVyQ291bnQiXX0"; - private static String VALID_TOKEN = + private static final String VALID_TOKEN = "ewogICJhbGciOiAibm9uZSIsCiAgInR5cCI6ICJKV1QiCn0.eyJpYXQiOjE1" + "MTYyMzkwMjIsImV4cCI6NDcyOTM2MzIwMCwicGVybWlzc2lvbnMiOlsibmV0OnBlZXJDb3VudCJdfQ"; - private static String VALID_TOKEN_DECODED_PAYLOAD = + private static final String VALID_TOKEN_DECODED_PAYLOAD = "{\"iat\": 1516239022,\"exp\": 4729363200," + "\"permissions\": [\"net:peerCount\"]}"; @Test diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetTransactionCountTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetTransactionCountTest.java index 4060aab333..bfb88870ed 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetTransactionCountTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetTransactionCountTest.java @@ -46,7 +46,8 @@ public class PrivGetTransactionCountTest { private final Address senderAddress = Address.fromHexString("0x627306090abab3a6e1400e9345bc60c78a8bef57"); private final long NONCE = 5; - private User user = new JWTUser(new JsonObject().put("privacyPublicKey", ENCLAVE_PUBLIC_KEY), ""); + private final User user = + new JWTUser(new JsonObject().put("privacyPublicKey", ENCLAVE_PUBLIC_KEY), ""); private final EnclavePublicKeyProvider enclavePublicKeyProvider = (user) -> ENCLAVE_PUBLIC_KEY; @Before diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetTransactionReceiptTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetTransactionReceiptTest.java index a8552f6755..28b66b298e 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetTransactionReceiptTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetTransactionReceiptTest.java @@ -142,7 +142,8 @@ public class PrivGetTransactionReceiptTest { null, Quantity.create(Bytes.of(1).toUnsignedBigInteger())); - private User user = new JWTUser(new JsonObject().put("privacyPublicKey", ENCLAVE_PUBLIC_KEY), ""); + private final User user = + new JWTUser(new JsonObject().put("privacyPublicKey", ENCLAVE_PUBLIC_KEY), ""); private final EnclavePublicKeyProvider enclavePublicKeyProvider = (user) -> ENCLAVE_PUBLIC_KEY; private final BlockchainQueries blockchainQueries = mock(BlockchainQueries.class); diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java index 8e43f1bbde..6e34ef5d9e 100644 --- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java @@ -285,7 +285,7 @@ public abstract class AbstractBlockCreator implements AsyncBlockCreator { final ProcessableBlockHeader header, final List ommers, final Wei blockReward, - boolean skipZeroBlockRewards) { + final boolean skipZeroBlockRewards) { // TODO(tmm): Added to make this work, should come from blockProcessor. final int MAX_GENERATION = 6; diff --git a/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPrecompiledContractIntegrationTest.java b/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPrecompiledContractIntegrationTest.java index 1f4ad192a4..5028a2e8e4 100644 --- a/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPrecompiledContractIntegrationTest.java +++ b/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPrecompiledContractIntegrationTest.java @@ -83,7 +83,7 @@ public class PrivacyPrecompiledContractIntegrationTest { private static OrionTestHarness testHarness; private static WorldStateArchive worldStateArchive; private static PrivateStateStorage privateStateStorage; - private static Vertx vertx = Vertx.vertx(); + private static final Vertx vertx = Vertx.vertx(); private PrivateTransactionProcessor mockPrivateTxProcessor() { final PrivateTransactionProcessor mockPrivateTransactionProcessor = diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/chain/BlockAddedEvent.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/chain/BlockAddedEvent.java index 9a4573452c..1dadea7ee8 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/chain/BlockAddedEvent.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/chain/BlockAddedEvent.java @@ -27,7 +27,7 @@ public class BlockAddedEvent { private final List addedTransactions; private final List removedTransactions; private final EventType eventType; - private List logsWithMetadata; + private final List logsWithMetadata; public enum EventType { HEAD_ADVANCED, diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/DefaultEvmAccount.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/DefaultEvmAccount.java index 6581e64d2c..93f48d335a 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/DefaultEvmAccount.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/DefaultEvmAccount.java @@ -21,7 +21,7 @@ import org.apache.tuweni.bytes.Bytes32; import org.apache.tuweni.units.bigints.UInt256; public class DefaultEvmAccount implements EvmAccount { - private MutableAccount mutableAccount; + private final MutableAccount mutableAccount; public boolean isImmutable() { return isImmutable; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/storage/keyvalue/PrivacyKeyValueStorageProvider.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/storage/keyvalue/PrivacyKeyValueStorageProvider.java index 3326b4d740..1b9b67831a 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/storage/keyvalue/PrivacyKeyValueStorageProvider.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/storage/keyvalue/PrivacyKeyValueStorageProvider.java @@ -31,7 +31,7 @@ public class PrivacyKeyValueStorageProvider implements PrivacyStorageProvider { private final KeyValueStorage privateWorldStatePreimageStorage; private final KeyValueStorage privateStateStorage; - private int factoryVersion; + private final int factoryVersion; public PrivacyKeyValueStorageProvider( final KeyValueStorage privateWorldStateStorage, diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/Pruner.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/Pruner.java index 0de65e217e..0ee7efaf60 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/Pruner.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/Pruner.java @@ -44,9 +44,9 @@ public class Pruner { new AtomicReference<>(PruningPhase.IDLE); private volatile long markBlockNumber = 0; private volatile BlockHeader markedBlockHeader; - private long blockConfirmations; + private final long blockConfirmations; - private AtomicReference state = new AtomicReference<>(State.IDLE); + private final AtomicReference state = new AtomicReference<>(State.IDLE); private final Supplier executorServiceSupplier; private ExecutorService executorService; diff --git a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockDataGenerator.java b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockDataGenerator.java index 605a5b8a25..78902f4d37 100644 --- a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockDataGenerator.java +++ b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockDataGenerator.java @@ -487,7 +487,7 @@ public class BlockDataGenerator { private Optional parentHash = Optional.empty(); private Optional stateRoot = Optional.empty(); private Optional difficulty = Optional.empty(); - private List transactions = new ArrayList<>(); + private final List transactions = new ArrayList<>(); private Optional extraData = Optional.empty(); private Optional blockHeaderFunctions = Optional.empty(); diff --git a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/PrivateTransactionTestFixture.java b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/PrivateTransactionTestFixture.java index 07e670061b..3ab3f288fa 100644 --- a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/PrivateTransactionTestFixture.java +++ b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/PrivateTransactionTestFixture.java @@ -52,7 +52,7 @@ public class PrivateTransactionTestFixture { private Optional privacyGroupId = Optional.empty(); - private Restriction restriction = Restriction.RESTRICTED; + private final Restriction restriction = Restriction.RESTRICTED; public PrivateTransaction createTransaction(final KeyPair keys) { final PrivateTransaction.Builder builder = PrivateTransaction.builder(); diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLAKE2BFPrecompileContractTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLAKE2BFPrecompileContractTest.java index fea801e1cc..193ed28127 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLAKE2BFPrecompileContractTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLAKE2BFPrecompileContractTest.java @@ -33,7 +33,7 @@ public class BLAKE2BFPrecompileContractTest { public BLAKE2BFPrecompileContractTest() {} - private MessageFrame messageFrame = mock(MessageFrame.class); + private final MessageFrame messageFrame = mock(MessageFrame.class); @Parameterized.Parameters public static Object[][] parameters() { diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/ECRECPrecompiledContractTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/ECRECPrecompiledContractTest.java index 1491e5aee8..5501087b31 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/ECRECPrecompiledContractTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/ECRECPrecompiledContractTest.java @@ -36,7 +36,7 @@ public class ECRECPrecompiledContractTest { public ECRECPrecompiledContractTest() {} - private MessageFrame messageFrame = mock(MessageFrame.class); + private final MessageFrame messageFrame = mock(MessageFrame.class); @Parameters public static Object[][] parameters() { diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/proof/WorldStateProofProviderTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/proof/WorldStateProofProviderTest.java index 67fb3e414d..921c924d3a 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/proof/WorldStateProofProviderTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/proof/WorldStateProofProviderTest.java @@ -47,7 +47,7 @@ public class WorldStateProofProviderTest { private static final Address address = Address.fromHexString("0x1234567890123456789012345678901234567890"); - private WorldStateStorage worldStateStorage = + private final WorldStateStorage worldStateStorage = new WorldStateKeyValueStorage(new InMemoryKeyValueStorage()); private WorldStateProofProvider worldStateProofProvider; diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/DeterministicEthScheduler.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/DeterministicEthScheduler.java index 4d3ce49253..839bb9b2a1 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/DeterministicEthScheduler.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/DeterministicEthScheduler.java @@ -30,7 +30,7 @@ public class DeterministicEthScheduler extends EthScheduler { private final TimeoutPolicy timeoutPolicy; private final List executors; - private List> pendingTimeouts = new ArrayList<>(); + private final List> pendingTimeouts = new ArrayList<>(); public DeterministicEthScheduler() { this(TimeoutPolicy.NEVER_TIMEOUT); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/MockEthTask.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/MockEthTask.java index 75b50b774c..72ce77aab1 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/MockEthTask.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/MockEthTask.java @@ -21,8 +21,8 @@ import java.util.concurrent.CountDownLatch; public class MockEthTask extends AbstractEthTask { - private CountDownLatch startedLatch = new CountDownLatch(1); - private CountDownLatch countdown; + private final CountDownLatch startedLatch = new CountDownLatch(1); + private final CountDownLatch countdown; MockEthTask(final int count) { super(new NoOpMetricsSystem()); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/RespondingEthPeer.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/RespondingEthPeer.java index ac9cc7c73b..2051f7de0e 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/RespondingEthPeer.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/RespondingEthPeer.java @@ -341,7 +341,7 @@ public class RespondingEthPeer { private Hash chainHeadHash = gen.hash(); private Difficulty totalDifficulty = Difficulty.of(1000L); private OptionalLong estimatedHeight = OptionalLong.of(1000L); - private List peerValidators = new ArrayList<>(); + private final List peerValidators = new ArrayList<>(); public RespondingEthPeer build() { checkNotNull(ethProtocolManager, "Must configure EthProtocolManager"); diff --git a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/internal/PeerDiscoveryController.java b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/internal/PeerDiscoveryController.java index d615755f80..b5be52e2aa 100644 --- a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/internal/PeerDiscoveryController.java +++ b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/internal/PeerDiscoveryController.java @@ -655,7 +655,7 @@ public class PeerDiscoveryController { private PeerPermissions peerPermissions = PeerPermissions.noop(); private long tableRefreshIntervalMs = MILLISECONDS.convert(30, TimeUnit.MINUTES); private long cleanPeerTableIntervalMs = MILLISECONDS.convert(1, TimeUnit.MINUTES); - private List bootstrapNodes = new ArrayList<>(); + private final List bootstrapNodes = new ArrayList<>(); private PeerTable peerTable; private Subscribers peerBondedObservers = Subscribers.create(); diff --git a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/network/DefaultP2PNetwork.java b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/network/DefaultP2PNetwork.java index 0c6124f79a..51a61194b6 100644 --- a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/network/DefaultP2PNetwork.java +++ b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/network/DefaultP2PNetwork.java @@ -123,7 +123,7 @@ public class DefaultP2PNetwork implements P2PNetwork { private final PeerPermissions peerPermissions; private final MaintainedPeers maintainedPeers; - private Optional natManager; + private final Optional natManager; private Optional natExternalAddress; private OptionalLong peerBondedObserverId = OptionalLong.empty(); diff --git a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/permissions/PeerPermissionsBlacklist.java b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/permissions/PeerPermissionsBlacklist.java index fd9bb2111a..b312f7f55b 100644 --- a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/permissions/PeerPermissionsBlacklist.java +++ b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/permissions/PeerPermissionsBlacklist.java @@ -27,7 +27,7 @@ import io.vertx.core.impl.ConcurrentHashSet; import org.apache.tuweni.bytes.Bytes; public class PeerPermissionsBlacklist extends PeerPermissions { - private static int DEFAULT_INITIAL_CAPACITY = 20; + private static final int DEFAULT_INITIAL_CAPACITY = 20; private final Set blacklist; diff --git a/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/internal/PeerDiscoveryControllerTest.java b/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/internal/PeerDiscoveryControllerTest.java index d8f964332c..ae53881632 100644 --- a/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/internal/PeerDiscoveryControllerTest.java +++ b/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/internal/PeerDiscoveryControllerTest.java @@ -1242,7 +1242,7 @@ public class PeerDiscoveryControllerTest { private PeerTable peerTable; private OutboundMessageHandler outboundMessageHandler = OutboundMessageHandler.NOOP; private static final PeerDiscoveryTestHelper helper = new PeerDiscoveryTestHelper(); - private Subscribers peerBondedObservers = Subscribers.create(); + private final Subscribers peerBondedObservers = Subscribers.create(); private PeerPermissions peerPermissions = PeerPermissions.noop(); public static ControllerBuilder create() { diff --git a/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/peers/MaintainedPeersTest.java b/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/peers/MaintainedPeersTest.java index 1a6291a5d5..407ec23bf5 100644 --- a/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/peers/MaintainedPeersTest.java +++ b/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/peers/MaintainedPeersTest.java @@ -26,7 +26,7 @@ import org.junit.Test; public class MaintainedPeersTest { - private MaintainedPeers maintainedPeers = new MaintainedPeers(); + private final MaintainedPeers maintainedPeers = new MaintainedPeers(); @Test public void add_newPeer() { diff --git a/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/AbstractPeerConnectionTest.java b/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/AbstractPeerConnectionTest.java index bd85a66f62..046e5c6d19 100644 --- a/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/AbstractPeerConnectionTest.java +++ b/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/AbstractPeerConnectionTest.java @@ -161,7 +161,7 @@ public class AbstractPeerConnectionTest { } private static class TestPeerConnection extends AbstractPeerConnection { - private List sentMessages = new ArrayList<>(); + private final List sentMessages = new ArrayList<>(); private int closedCount = 0; TestPeerConnection( diff --git a/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/MockConnectionInitializer.java b/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/MockConnectionInitializer.java index f3a33afb6d..248cb62f4b 100644 --- a/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/MockConnectionInitializer.java +++ b/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/MockConnectionInitializer.java @@ -26,12 +26,13 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.atomic.AtomicInteger; public class MockConnectionInitializer implements ConnectionInitializer { - private static AtomicInteger NEXT_PORT = new AtomicInteger(0); + private static final AtomicInteger NEXT_PORT = new AtomicInteger(0); private final PeerConnectionEventDispatcher eventDispatcher; private final Subscribers connectCallbacks = Subscribers.create(); private boolean autocompleteConnections = true; - private Map> incompleteConnections = new HashMap<>(); + private final Map> incompleteConnections = + new HashMap<>(); public MockConnectionInitializer(final PeerConnectionEventDispatcher eventDispatcher) { this.eventDispatcher = eventDispatcher; diff --git a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/PermissioningConfiguration.java b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/PermissioningConfiguration.java index 0499b5e6f9..e08ec6edbd 100644 --- a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/PermissioningConfiguration.java +++ b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/PermissioningConfiguration.java @@ -17,8 +17,8 @@ package org.hyperledger.besu.ethereum.permissioning; import java.util.Optional; public class PermissioningConfiguration { - private Optional localConfig; - private Optional smartContractConfig; + private final Optional localConfig; + private final Optional smartContractConfig; public PermissioningConfiguration( final Optional localConfig, diff --git a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/WhitelistPersistor.java b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/WhitelistPersistor.java index f803c67f2d..3962bd0479 100644 --- a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/WhitelistPersistor.java +++ b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/WhitelistPersistor.java @@ -34,13 +34,13 @@ import org.apache.tuweni.toml.TomlParseResult; public class WhitelistPersistor { - private File configurationFile; + private final File configurationFile; public enum WHITELIST_TYPE { ACCOUNTS("accounts-whitelist"), NODES("nodes-whitelist"); - private String tomlKey; + private final String tomlKey; WHITELIST_TYPE(final String tomlKey) { this.tomlKey = tomlKey; diff --git a/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/node/provider/SyncStatusNodePermissioningProviderTest.java b/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/node/provider/SyncStatusNodePermissioningProviderTest.java index 4ccd4e1536..74d7b09cef 100644 --- a/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/node/provider/SyncStatusNodePermissioningProviderTest.java +++ b/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/node/provider/SyncStatusNodePermissioningProviderTest.java @@ -59,7 +59,7 @@ public class SyncStatusNodePermissioningProviderTest { "enode://6f8a80d14311c39f35f516fa664deaaaa13e85b2f7493f37f6144d86991ec012937307647bd3b9a82abe2974e1407241d54947bbb39763a4cac9f77166ad92a0@192.168.0.3:5678"); @Mock private Synchronizer synchronizer; - private Collection bootnodes = new ArrayList<>(); + private final Collection bootnodes = new ArrayList<>(); private SyncStatusNodePermissioningProvider provider; private InSyncListener inSyncListener; diff --git a/metrics/core/src/main/java/org/hyperledger/besu/metrics/RunnableCounter.java b/metrics/core/src/main/java/org/hyperledger/besu/metrics/RunnableCounter.java index 4682d6e8cc..65fb6acb4d 100644 --- a/metrics/core/src/main/java/org/hyperledger/besu/metrics/RunnableCounter.java +++ b/metrics/core/src/main/java/org/hyperledger/besu/metrics/RunnableCounter.java @@ -24,7 +24,7 @@ public class RunnableCounter implements Counter { private final Counter backedCounter; private final Runnable task; private final int step; - private AtomicLong stepCounter; + private final AtomicLong stepCounter; public RunnableCounter(final Counter backedCounter, final Runnable task, final int step) { this.backedCounter = backedCounter; diff --git a/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/RocksDBKeyValueStorageFactory.java b/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/RocksDBKeyValueStorageFactory.java index c093306e9e..f21cb31a61 100644 --- a/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/RocksDBKeyValueStorageFactory.java +++ b/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/RocksDBKeyValueStorageFactory.java @@ -49,7 +49,7 @@ public class RocksDBKeyValueStorageFactory implements KeyValueStorageFactory { private static final String NAME = "rocksdb"; private final RocksDBMetricsFactory rocksDBMetricsFactory; - private int defaultVersion; + private final int defaultVersion; private Integer databaseVersion; private Boolean isSegmentIsolationSupported; private SegmentedKeyValueStorage segmentedStorage; diff --git a/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/configuration/DatabaseMetadata.java b/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/configuration/DatabaseMetadata.java index ae94e20e70..3ef5e124ba 100644 --- a/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/configuration/DatabaseMetadata.java +++ b/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/configuration/DatabaseMetadata.java @@ -34,7 +34,7 @@ public class DatabaseMetadata { private static final Logger LOG = LogManager.getLogger(); private static final String METADATA_FILENAME = "DATABASE_METADATA.json"; - private static ObjectMapper MAPPER = new ObjectMapper(); + private static final ObjectMapper MAPPER = new ObjectMapper(); private final int version; private Optional privacyVersion; diff --git a/util/src/main/java/org/hyperledger/besu/util/Subscribers.java b/util/src/main/java/org/hyperledger/besu/util/Subscribers.java index e81f735e55..d9151f04b3 100644 --- a/util/src/main/java/org/hyperledger/besu/util/Subscribers.java +++ b/util/src/main/java/org/hyperledger/besu/util/Subscribers.java @@ -43,7 +43,7 @@ import org.apache.logging.log4j.Logger; * @param the type of subscribers */ public class Subscribers { - private static Subscribers NONE = new EmptySubscribers<>(); + private static final Subscribers NONE = new EmptySubscribers<>(); private static final Logger LOG = LogManager.getLogger(); private final AtomicLong subscriberId = new AtomicLong(); diff --git a/util/src/main/java/org/hyperledger/besu/util/number/Fraction.java b/util/src/main/java/org/hyperledger/besu/util/number/Fraction.java index 87772c1e0d..8adbbd28f0 100644 --- a/util/src/main/java/org/hyperledger/besu/util/number/Fraction.java +++ b/util/src/main/java/org/hyperledger/besu/util/number/Fraction.java @@ -21,7 +21,7 @@ import java.util.Objects; public class Fraction { - private float value; + private final float value; private Fraction(final float value) { this.value = value; diff --git a/util/src/main/java/org/hyperledger/besu/util/number/Percentage.java b/util/src/main/java/org/hyperledger/besu/util/number/Percentage.java index 50f5701f26..a0565668d8 100644 --- a/util/src/main/java/org/hyperledger/besu/util/number/Percentage.java +++ b/util/src/main/java/org/hyperledger/besu/util/number/Percentage.java @@ -21,7 +21,7 @@ import java.util.Objects; public class Percentage { - private int value; + private final int value; private Percentage(final int value) { this.value = value; diff --git a/util/src/main/java/org/hyperledger/besu/util/number/PositiveNumber.java b/util/src/main/java/org/hyperledger/besu/util/number/PositiveNumber.java index 66a4cba72e..061117ec1d 100644 --- a/util/src/main/java/org/hyperledger/besu/util/number/PositiveNumber.java +++ b/util/src/main/java/org/hyperledger/besu/util/number/PositiveNumber.java @@ -21,7 +21,7 @@ import java.util.Objects; public class PositiveNumber { - private int value; + private final int value; private PositiveNumber(final int value) { this.value = value;