Not null annotations (#3708)

* NotNull -> Nonnull

Signed-off-by: Sally MacFarlane <sally.macfarlane@consensys.net>
pull/3712/head
Sally MacFarlane 3 years ago committed by GitHub
parent 6f8b7a5de4
commit 00851d042c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/backup/BackupRoundTripAcceptanceTest.java
  2. 4
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodesSmartContractPermissioningStaticNodesAcceptanceTest.java
  3. 6
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivCallAcceptanceTest.java
  4. 8
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/multitenancy/MultiTenancyAcceptanceTest.java
  5. 4
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulator.java
  6. 6
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/BackwardSyncContextTest.java
  7. 4
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/BackwardSyncLookupServiceTest.java
  8. 6
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/BackwardSyncPhaseTest.java
  9. 10
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/BackwardSyncTaskTest.java
  10. 4
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/ChainForTestCreator.java
  11. 8
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/ForwardSyncPhaseTest.java
  12. 10
      ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/netty/NettyConnectionInitializer.java
  13. 4
      ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/NodeSmartContractV2PermissioningController.java
  14. 3
      evm/src/main/java/org/hyperledger/besu/evm/precompile/BigIntegerModularExponentiationPrecompiledContract.java
  15. 3
      evm/src/main/java/org/hyperledger/besu/evm/precompile/SHA256PrecompiledContract.java
  16. 5
      services/tasks/src/main/java/org/hyperledger/besu/services/tasks/InMemoryTasksPriorityQueues.java
  17. 4
      testutil/src/main/java/org/hyperledger/enclave/testutil/TesseraTestHarnessFactory.java

@ -37,9 +37,9 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.function.UnaryOperator;
import javax.annotation.Nonnull;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.jetbrains.annotations.NotNull;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -139,10 +139,7 @@ public class BackupRoundTripAcceptanceTest extends AbstractPreexistingNodeTest {
besu.createNode(
"restore " + testName,
configureNodeCommands(
restorePath,
"operator",
"x-restore-state",
"--backup-path=" + backupPath.toString()));
restorePath, "operator", "x-restore-state", "--backup-path=" + backupPath));
cluster.startNode(restoreNode);
WaitUtils.waitFor(60, () -> restoreNode.verify(exitedSuccessfully));
@ -185,7 +182,7 @@ public class BackupRoundTripAcceptanceTest extends AbstractPreexistingNodeTest {
assertThat(rebackupManifest).isEqualTo(backupManifest);
}
@NotNull
@Nonnull
private UnaryOperator<BesuNodeConfigurationBuilder> configureNodeCommands(
final Path dataPath, final String... commands) {
return nodeBuilder -> super.configureNode(nodeBuilder).dataPath(dataPath).run(commands);

@ -22,8 +22,8 @@ import org.hyperledger.besu.tests.acceptance.dsl.node.RunnableNode;
import java.net.URI;
import java.util.Arrays;
import java.util.List;
import javax.annotation.Nonnull;
import org.jetbrains.annotations.NotNull;
import org.junit.Before;
import org.junit.Test;
@ -72,7 +72,7 @@ public class NodesSmartContractPermissioningStaticNodesAcceptanceTest
.build();
}
@NotNull
@Nonnull
private List<String> mapNodesToEnodeURLs(final List<Node> staticNodes) {
return staticNodes.stream()
.map(node -> (RunnableNode) node)

@ -30,8 +30,8 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import javax.annotation.Nonnull;
import org.jetbrains.annotations.NotNull;
import org.junit.Test;
import org.web3j.abi.FunctionEncoder;
import org.web3j.abi.TypeReference;
@ -191,7 +191,7 @@ public class PrivCallAcceptanceTest extends ParameterizedEnclaveTestBase {
assertThat(result.getResult()).isEqualTo("0x");
}
@NotNull
@Nonnull
private String constructInvalidString(final String privacyGroupId) {
final char[] chars = privacyGroupId.toCharArray();
if (chars[3] == '0') {
@ -202,7 +202,7 @@ public class PrivCallAcceptanceTest extends ParameterizedEnclaveTestBase {
return String.valueOf(chars);
}
@NotNull
@Nonnull
private Request<Object, EthCall> privCall(
final String privacyGroupId,
final Contract eventEmitter,

@ -46,6 +46,7 @@ import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
@ -54,7 +55,6 @@ import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32;
import org.jetbrains.annotations.NotNull;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
@ -256,7 +256,7 @@ public class MultiTenancyAcceptanceTest extends AcceptanceTestBase {
final String privateFrom = validSignedPrivateTransaction.getPrivateFrom().toBase64String();
final String[] privateFor =
validSignedPrivateTransaction.getPrivateFor().orElseThrow().stream()
.map(pf -> pf.toBase64String())
.map(Bytes::toBase64String)
.toArray(String[]::new);
node.verify(priv.getEeaTransactionCount(accountAddress, privateFrom, privateFor, 0));
@ -267,7 +267,7 @@ public class MultiTenancyAcceptanceTest extends AcceptanceTestBase {
node.verify(priv.getEeaTransactionCount(accountAddress, privateFrom, privateFor, 1));
}
@NotNull
@Nonnull
private Bytes32 getPrivacyGroupIdFromEeaTransaction(
final PrivateTransaction validSignedPrivateTransaction) {
return PrivacyGroupUtil.calculateEeaPrivacyGroupId(
@ -307,7 +307,7 @@ public class MultiTenancyAcceptanceTest extends AcceptanceTestBase {
members.add(tx.getPrivateFrom().toBase64String());
members.addAll(
tx.getPrivateFor().orElseThrow().stream()
.map(pf -> pf.toBase64String())
.map(Bytes::toBase64String)
.collect(Collectors.toList()));
final String retrieveGroupResponse =
mapper.writeValueAsString(testPrivacyGroupEea(members, PrivacyGroup.Type.LEGACY));

@ -43,11 +43,11 @@ import org.hyperledger.besu.evm.worldstate.WorldUpdater;
import java.math.BigInteger;
import java.util.Optional;
import javax.annotation.Nonnull;
import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
import org.apache.tuweni.bytes.Bytes;
import org.jetbrains.annotations.NotNull;
/*
* Used to process transactions for eth_call and eth_estimateGas.
@ -161,7 +161,7 @@ public class TransactionSimulator {
callParams, transactionValidationParams, operationTracer, header, updater);
}
@NotNull
@Nonnull
public Optional<TransactionSimulatorResult> processWithWorldUpdater(
final CallParameter callParams,
final TransactionValidationParams transactionValidationParams,

@ -49,8 +49,8 @@ import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import javax.annotation.Nonnull;
import org.jetbrains.annotations.NotNull;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -152,7 +152,7 @@ public class BackwardSyncContextTest {
}
@Test
public void shouldNotAppendWhenAlreadySyncingHash() throws Exception {
public void shouldNotAppendWhenAlreadySyncingHash() {
final Hash hash = getBlockByNumber(REMOTE_HEIGHT).getHash();
when(backwardSyncLookupService.lookup(hash))
.thenReturn(CompletableFuture.completedFuture(Collections.emptyList()));
@ -213,7 +213,7 @@ public class BackwardSyncContextTest {
peer.respondWhileOtherThreadsWork(responder, () -> !future.isDone());
}
@NotNull
@Nonnull
private Block getBlockByNumber(final int number) {
return remoteBlockchain.getBlockByNumber(number).orElseThrow();
}

@ -41,8 +41,8 @@ import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import javax.annotation.Nonnull;
import org.jetbrains.annotations.NotNull;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -125,7 +125,7 @@ public class BackwardSyncLookupServiceTest {
peer.respondWhileOtherThreadsWork(responder, () -> !future.isDone());
}
@NotNull
@Nonnull
private Block getBlockByNumber(final int number) {
return remoteBlockchain.getBlockByNumber(number).orElseThrow();
}

@ -44,8 +44,8 @@ import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
import javax.annotation.Nonnull;
import org.jetbrains.annotations.NotNull;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -278,13 +278,13 @@ public class BackwardSyncPhaseTest {
return chain;
}
@NotNull
@Nonnull
private BackwardChain createBackwardChain(final int number) {
return new BackwardChain(
headersStorage, blocksStorage, remoteBlockchain.getBlockByNumber(number).orElseThrow());
}
@NotNull
@Nonnull
private Block getBlockByNumber(final int number) {
return remoteBlockchain.getBlockByNumber(number).orElseThrow();
}

@ -27,9 +27,8 @@ import org.hyperledger.besu.services.kvstore.InMemoryKeyValueStorage;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import javax.annotation.Nonnull;
import org.jetbrains.annotations.NotNull;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -73,14 +72,14 @@ public class BackwardSyncTaskTest {
.hasMessageContaining("No pivot");
}
@NotNull
@Nonnull
private BackwardSyncTask createBackwardSyncTask() {
final BackwardChain backwardChain =
new BackwardChain(headersStorage, blocksStorage, blocks.get(1));
return createBackwardSyncTask(backwardChain);
}
@NotNull
@Nonnull
private BackwardSyncTask createBackwardSyncTask(final BackwardChain backwardChain) {
return new BackwardSyncTask(context, backwardChain) {
@Override
@ -91,8 +90,7 @@ public class BackwardSyncTaskTest {
}
@Test
public void shouldFinishImmediatellyFailWhenPivotIsDifferent()
throws ExecutionException, InterruptedException {
public void shouldFinishImmediatelyFailWhenPivotIsDifferent() {
final BackwardChain backwardChain =
new BackwardChain(headersStorage, blocksStorage, blocks.get(0));
when(context.getCurrentChain()).thenReturn(Optional.of(backwardChain));

@ -28,9 +28,9 @@ import org.hyperledger.besu.evm.log.LogsBloomFilter;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import javax.annotation.Nonnull;
import org.apache.tuweni.bytes.Bytes;
import org.jetbrains.annotations.NotNull;
public class ChainForTestCreator {
@ -105,7 +105,7 @@ public class ChainForTestCreator {
return prepareHeader(number, Optional.empty());
}
@NotNull
@Nonnull
private static BlockHeader prepareEmptyHeader(final BlockHeader parent) {
return new BlockHeader(
parent.getHash(),

@ -47,8 +47,8 @@ import org.hyperledger.besu.services.kvstore.InMemoryKeyValueStorage;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import javax.annotation.Nonnull;
import org.jetbrains.annotations.NotNull;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -240,7 +240,7 @@ public class ForwardSyncPhaseTest {
}
@Test
public void shouldAddSuccessorsWhenNoUnknownBlockSet() throws Exception {
public void shouldAddSuccessorsWhenNoUnknownBlockSet() {
BackwardChain backwardChain = createBackwardChain(LOCAL_HEIGHT - 3, LOCAL_HEIGHT);
backwardChain.appendExpectedBlock(getBlockByNumber(LOCAL_HEIGHT + 1));
backwardChain.appendExpectedBlock(getBlockByNumber(LOCAL_HEIGHT + 2));
@ -263,13 +263,13 @@ public class ForwardSyncPhaseTest {
return chain;
}
@NotNull
@Nonnull
private BackwardChain backwardChainFromBlock(final int number) {
return new BackwardChain(
headersStorage, blocksStorage, remoteBlockchain.getBlockByNumber(number).orElseThrow());
}
@NotNull
@Nonnull
private Block getBlockByNumber(final int number) {
return remoteBlockchain.getBlockByNumber(number).orElseThrow();
}

@ -42,6 +42,7 @@ import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.IntSupplier;
import java.util.stream.StreamSupport;
import javax.annotation.Nonnull;
import io.netty.bootstrap.Bootstrap;
import io.netty.bootstrap.ServerBootstrap;
@ -55,7 +56,6 @@ import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.util.concurrent.SingleThreadEventExecutor;
import org.jetbrains.annotations.NotNull;
public class NettyConnectionInitializer
implements ConnectionInitializer, HandshakerProvider, FramerProvider {
@ -194,7 +194,7 @@ public class NettyConnectionInitializer
}
/** @return a channel initializer for outbound connections */
@NotNull
@Nonnull
private ChannelInitializer<SocketChannel> outboundChannelInitializer(
final Peer peer, final CompletableFuture<PeerConnection> connectionFuture) {
return new ChannelInitializer<SocketChannel>() {
@ -229,7 +229,7 @@ public class NettyConnectionInitializer
};
}
@NotNull
@Nonnull
private HandshakeHandlerInbound inboundHandler(
final CompletableFuture<PeerConnection> connectionFuture) {
return new HandshakeHandlerInbound(
@ -243,7 +243,7 @@ public class NettyConnectionInitializer
this);
}
@NotNull
@Nonnull
private HandshakeHandlerOutbound outboundHandler(
final Peer peer, final CompletableFuture<PeerConnection> connectionFuture) {
return new HandshakeHandlerOutbound(
@ -258,7 +258,7 @@ public class NettyConnectionInitializer
this);
}
@NotNull
@Nonnull
private TimeoutHandler<Channel> timeoutHandler(
final CompletableFuture<PeerConnection> connectionFuture, final String s) {
return new TimeoutHandler<>(

@ -23,10 +23,10 @@ import org.hyperledger.besu.plugin.data.EnodeURL;
import org.hyperledger.besu.plugin.services.MetricsSystem;
import java.util.List;
import javax.annotation.Nonnull;
import com.google.common.net.InetAddresses;
import org.apache.tuweni.bytes.Bytes;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.web3j.abi.FunctionEncoder;
@ -75,7 +75,7 @@ public class NodeSmartContractV2PermissioningController
}
}
@NotNull
@Nonnull
private Boolean getCallResult(final EnodeURL enode) {
return transactionSimulator
.processAtHead(buildCallParameters(createPayload(enode)))

@ -23,7 +23,6 @@ import javax.annotation.Nonnull;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.MutableBytes;
import org.jetbrains.annotations.NotNull;
// The big integer modular exponentiation precompiled contract defined in EIP-198.
public class BigIntegerModularExponentiationPrecompiledContract
@ -53,7 +52,7 @@ public class BigIntegerModularExponentiationPrecompiledContract
return gasCalculator().modExpGasCost(input);
}
@NotNull
@Nonnull
@Override
public PrecompileContractResult computePrecompile(
final Bytes input, @Nonnull final MessageFrame messageFrame) {

@ -21,7 +21,6 @@ import org.hyperledger.besu.evm.gascalculator.GasCalculator;
import javax.annotation.Nonnull;
import org.apache.tuweni.bytes.Bytes;
import org.jetbrains.annotations.NotNull;
public class SHA256PrecompiledContract extends AbstractPrecompiledContract {
@ -34,7 +33,7 @@ public class SHA256PrecompiledContract extends AbstractPrecompiledContract {
return gasCalculator().sha256PrecompiledContractGasCost(input);
}
@NotNull
@Nonnull
@Override
public PrecompileContractResult computePrecompile(
final Bytes input, @Nonnull final MessageFrame messageFrame) {

@ -22,8 +22,7 @@ import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nonnull;
public class InMemoryTasksPriorityQueues<T extends TasksPriorityProvider>
implements TaskCollection<T> {
@ -42,7 +41,7 @@ public class InMemoryTasksPriorityQueues<T extends TasksPriorityProvider>
}
}
@NotNull
@Nonnull
private PriorityQueue<T> newEmptyQueue() {
return new PriorityQueue<>(Comparator.comparingLong(TasksPriorityProvider::getPriority));
}

@ -22,8 +22,8 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import javax.annotation.Nonnull;
import org.jetbrains.annotations.NotNull;
import org.testcontainers.containers.Network;
public class TesseraTestHarnessFactory {
@ -68,7 +68,7 @@ public class TesseraTestHarnessFactory {
containerNetwork);
}
@NotNull
@Nonnull
private static Path[] stringArrayToPathArray(final Path tempDir, final String[] privKeyPaths) {
return Arrays.stream(privKeyPaths)
.map(

Loading…
Cancel
Save