diff --git a/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/tests/GossipTest.java b/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/tests/GossipTest.java index 3dc94e7c4a..131f906e3c 100644 --- a/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/tests/GossipTest.java +++ b/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/tests/GossipTest.java @@ -13,7 +13,7 @@ package tech.pegasys.pantheon.consensus.ibft.tests; import static java.util.Collections.emptyList; -import static java.util.Collections.singleton; +import static java.util.Collections.singletonList; import tech.pegasys.pantheon.consensus.ibft.ConsensusRoundIdentifier; import tech.pegasys.pantheon.consensus.ibft.IbftHelpers; @@ -90,7 +90,7 @@ public class GossipTest { final RoundChange roundChange = msgFactory.createRoundChange(roundId, Optional.empty()); final RoundChangeCertificate roundChangeCert = - new RoundChangeCertificate(singleton(roundChange.getSignedPayload())); + new RoundChangeCertificate(singletonList(roundChange.getSignedPayload())); final Proposal nextRoundProposal = sender.injectProposalForFutureRound(roundId, roundChangeCert, proposal.getBlock()); diff --git a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/Vote.java b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/Vote.java index 9c0fadd3d9..0591caf6c3 100644 --- a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/Vote.java +++ b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/Vote.java @@ -18,7 +18,8 @@ import tech.pegasys.pantheon.ethereum.rlp.RLPException; import tech.pegasys.pantheon.ethereum.rlp.RLPInput; import tech.pegasys.pantheon.ethereum.rlp.RLPOutput; -import com.google.common.base.Objects; +import java.util.Objects; + import com.google.common.collect.ImmutableBiMap; /** @@ -76,7 +77,7 @@ public class Vote { @Override public int hashCode() { - return Objects.hashCode(recipient, voteType); + return Objects.hash(recipient, voteType); } public void writeTo(final RLPOutput rlpOutput) { diff --git a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/payload/PreparedCertificate.java b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/payload/PreparedCertificate.java index 27fcbecd74..2781bf3edf 100644 --- a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/payload/PreparedCertificate.java +++ b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/payload/PreparedCertificate.java @@ -15,25 +15,25 @@ package tech.pegasys.pantheon.consensus.ibft.payload; import tech.pegasys.pantheon.ethereum.rlp.RLPInput; import tech.pegasys.pantheon.ethereum.rlp.RLPOutput; -import java.util.ArrayList; import java.util.Collection; +import java.util.List; import java.util.Objects; import java.util.StringJoiner; public class PreparedCertificate { private final SignedData proposalPayload; - private final Collection> preparePayloads; + private final List> preparePayloads; public PreparedCertificate( final SignedData proposalPayload, - final Collection> preparePayloads) { + final List> preparePayloads) { this.proposalPayload = proposalPayload; this.preparePayloads = preparePayloads; } public static PreparedCertificate readFrom(final RLPInput rlpInput) { final SignedData proposalMessage; - final Collection> prepareMessages; + final List> prepareMessages; rlpInput.enterList(); proposalMessage = SignedData.readSignedProposalPayloadFrom(rlpInput); @@ -68,7 +68,7 @@ public class PreparedCertificate { } final PreparedCertificate that = (PreparedCertificate) o; return Objects.equals(proposalPayload, that.proposalPayload) - && Objects.equals(new ArrayList<>(preparePayloads), new ArrayList<>(that.preparePayloads)); + && Objects.equals(preparePayloads, that.preparePayloads); } @Override diff --git a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/payload/RoundChangeCertificate.java b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/payload/RoundChangeCertificate.java index 6f887b4493..1c22a18686 100644 --- a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/payload/RoundChangeCertificate.java +++ b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/payload/RoundChangeCertificate.java @@ -16,7 +16,6 @@ import tech.pegasys.pantheon.consensus.ibft.messagewrappers.RoundChange; import tech.pegasys.pantheon.ethereum.rlp.RLPInput; import tech.pegasys.pantheon.ethereum.rlp.RLPOutput; -import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Objects; @@ -27,15 +26,14 @@ import com.google.common.collect.Lists; public class RoundChangeCertificate { - private final Collection> roundChangePayloads; + private final List> roundChangePayloads; - public RoundChangeCertificate( - final Collection> roundChangePayloads) { + public RoundChangeCertificate(final List> roundChangePayloads) { this.roundChangePayloads = roundChangePayloads; } public static RoundChangeCertificate readFrom(final RLPInput rlpInput) { - final Collection> roundChangePayloads; + final List> roundChangePayloads; rlpInput.enterList(); roundChangePayloads = rlpInput.readList(SignedData::readSignedRoundChangePayloadFrom); @@ -81,8 +79,7 @@ public class RoundChangeCertificate { return false; } final RoundChangeCertificate that = (RoundChangeCertificate) o; - return Objects.equals( - new ArrayList<>(roundChangePayloads), new ArrayList<>(that.roundChangePayloads)); + return Objects.equals(roundChangePayloads, that.roundChangePayloads); } @Override diff --git a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/RoundChangeArtifacts.java b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/RoundChangeArtifacts.java index 7092725595..a3f4742fa5 100644 --- a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/RoundChangeArtifacts.java +++ b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/RoundChangeArtifacts.java @@ -20,17 +20,17 @@ import tech.pegasys.pantheon.ethereum.core.Block; import java.util.Collection; import java.util.Comparator; +import java.util.List; import java.util.Optional; import java.util.stream.Collectors; public class RoundChangeArtifacts { private final Optional block; - private final Collection> roundChangePayloads; + private final List> roundChangePayloads; public RoundChangeArtifacts( - final Optional block, - final Collection> roundChangePayloads) { + final Optional block, final List> roundChangePayloads) { this.block = block; this.roundChangePayloads = roundChangePayloads; } @@ -58,7 +58,7 @@ public class RoundChangeArtifacts { .compareTo(o2.getPreparedCertificateRound().get()); }; - final Collection> payloads = + final List> payloads = roundChanges.stream().map(RoundChange::getSignedPayload).collect(Collectors.toList()); final Optional roundChangeWithNewestPrepare = diff --git a/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/payload/PreparedCertificateTest.java b/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/payload/PreparedCertificateTest.java index c6abf5dee1..2f9c086f2d 100644 --- a/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/payload/PreparedCertificateTest.java +++ b/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/payload/PreparedCertificateTest.java @@ -26,8 +26,8 @@ import tech.pegasys.pantheon.ethereum.rlp.RLP; import tech.pegasys.pantheon.ethereum.rlp.RLPInput; import java.math.BigInteger; -import java.util.Collection; import java.util.Collections; +import java.util.List; import org.assertj.core.util.Lists; import org.junit.Test; @@ -40,7 +40,7 @@ public class PreparedCertificateTest { @Test public void roundTripRlpWithNoPreparePayloads() { final SignedData signedProposalPayload = signedProposal(); - final Collection> preparePayloads = Collections.emptyList(); + final List> preparePayloads = Collections.emptyList(); final PreparedCertificate preparedCert = new PreparedCertificate(signedProposalPayload, preparePayloads); diff --git a/crypto/src/main/java/tech/pegasys/pantheon/crypto/SECP256K1.java b/crypto/src/main/java/tech/pegasys/pantheon/crypto/SECP256K1.java index cc52cb0853..a8f57443b7 100644 --- a/crypto/src/main/java/tech/pegasys/pantheon/crypto/SECP256K1.java +++ b/crypto/src/main/java/tech/pegasys/pantheon/crypto/SECP256K1.java @@ -37,10 +37,10 @@ import java.security.Security; import java.security.spec.ECGenParameterSpec; import java.util.Arrays; import java.util.List; +import java.util.Objects; import java.util.Optional; import java.util.function.UnaryOperator; -import com.google.common.base.Objects; import org.bouncycastle.asn1.sec.SECNamedCurves; import org.bouncycastle.asn1.x9.X9ECParameters; import org.bouncycastle.asn1.x9.X9IntegerConverter; @@ -552,7 +552,7 @@ public class SECP256K1 { @Override public int hashCode() { - return Objects.hashCode(privateKey, publicKey); + return Objects.hash(privateKey, publicKey); } @Override @@ -664,7 +664,7 @@ public class SECP256K1 { @Override public int hashCode() { - return Objects.hashCode(r, s, recId); + return Objects.hash(r, s, recId); } public byte getRecId() { diff --git a/crypto/src/main/java/tech/pegasys/pantheon/crypto/altbn128/AbstractFieldPoint.java b/crypto/src/main/java/tech/pegasys/pantheon/crypto/altbn128/AbstractFieldPoint.java index d7135a48a5..eab4468ae3 100644 --- a/crypto/src/main/java/tech/pegasys/pantheon/crypto/altbn128/AbstractFieldPoint.java +++ b/crypto/src/main/java/tech/pegasys/pantheon/crypto/altbn128/AbstractFieldPoint.java @@ -13,9 +13,9 @@ package tech.pegasys.pantheon.crypto.altbn128; import java.math.BigInteger; +import java.util.Objects; import com.google.common.base.MoreObjects; -import com.google.common.base.Objects; /** * Adapted from the pc_ecc (Apache 2 License) implementation: @@ -120,7 +120,7 @@ public abstract class AbstractFieldPoint implement @Override public int hashCode() { - return Objects.hashCode(x, y); + return Objects.hash(x, y); } @SuppressWarnings("rawtypes") @@ -134,6 +134,6 @@ public abstract class AbstractFieldPoint implement } final AbstractFieldPoint other = (AbstractFieldPoint) obj; - return Objects.equal(x, other.x) && Objects.equal(y, other.y); + return Objects.equals(x, other.x) && Objects.equals(y, other.y); } } diff --git a/crypto/src/main/java/tech/pegasys/pantheon/crypto/altbn128/AbstractFqp.java b/crypto/src/main/java/tech/pegasys/pantheon/crypto/altbn128/AbstractFqp.java index c60cd903be..8738d3cc07 100644 --- a/crypto/src/main/java/tech/pegasys/pantheon/crypto/altbn128/AbstractFqp.java +++ b/crypto/src/main/java/tech/pegasys/pantheon/crypto/altbn128/AbstractFqp.java @@ -14,9 +14,9 @@ package tech.pegasys.pantheon.crypto.altbn128; import java.math.BigInteger; import java.util.Arrays; +import java.util.Objects; import com.google.common.base.MoreObjects; -import com.google.common.base.Objects; /** * Adapted from the pc_ecc (Apache 2 License) implementation: @@ -266,7 +266,7 @@ public abstract class AbstractFqp implements FieldElement @Override public int hashCode() { - return Objects.hashCode( + return Objects.hash( degree, Arrays.hashCode(modulusCoefficients), Arrays.hashCode(coefficients)); } diff --git a/errorprone-checks/src/main/java/tech/pegasys/errorpronechecks/BannedMethod.java b/errorprone-checks/src/main/java/tech/pegasys/errorpronechecks/BannedMethod.java new file mode 100644 index 0000000000..28e065c70a --- /dev/null +++ b/errorprone-checks/src/main/java/tech/pegasys/errorpronechecks/BannedMethod.java @@ -0,0 +1,55 @@ +/* + * Copyright 2019 ConsenSys AG. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package tech.pegasys.errorpronechecks; + +import static com.google.errorprone.BugPattern.SeverityLevel.WARNING; +import static com.google.errorprone.bugpatterns.BugChecker.MethodInvocationTreeMatcher; +import static com.google.errorprone.matchers.Description.NO_MATCH; +import static com.google.errorprone.matchers.Matchers.allOf; +import static com.google.errorprone.matchers.method.MethodMatchers.staticMethod; + +import java.util.Map; + +import com.google.auto.service.AutoService; +import com.google.common.collect.ImmutableMap; +import com.google.errorprone.BugPattern; +import com.google.errorprone.VisitorState; +import com.google.errorprone.bugpatterns.BugChecker; +import com.google.errorprone.matchers.Description; +import com.google.errorprone.matchers.Matcher; +import com.sun.source.tree.ExpressionTree; +import com.sun.source.tree.MethodInvocationTree; + +@AutoService(BugChecker.class) +@BugPattern( + name = "BannedMethod", + summary = "Some methods should not be used, make sure that doesn't happen.", + severity = WARNING) +public class BannedMethod extends BugChecker implements MethodInvocationTreeMatcher { + + private static final ImmutableMap, String> BANNED_METHOD_LIST = + ImmutableMap.of( + allOf(staticMethod().onClass("com.google.common.base.Objects").withAnyName()), + "Do not use com.google.common.base.Objects methods, use java.util.Objects methods instead."); + + @Override + public Description matchMethodInvocation( + final MethodInvocationTree tree, final VisitorState state) { + for (final Map.Entry, String> entry : BANNED_METHOD_LIST.entrySet()) { + if (entry.getKey().matches(tree, state)) { + return buildDescriptionFromChecker(tree, this).setMessage(entry.getValue()).build(); + } + } + return NO_MATCH; + } +} diff --git a/errorprone-checks/src/test/java/tech/pegasys/errorpronechecks/BannedMethodTest.java b/errorprone-checks/src/test/java/tech/pegasys/errorpronechecks/BannedMethodTest.java new file mode 100644 index 0000000000..1e260bc298 --- /dev/null +++ b/errorprone-checks/src/test/java/tech/pegasys/errorpronechecks/BannedMethodTest.java @@ -0,0 +1,37 @@ +/* + * Copyright 2018 ConsenSys AG. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package tech.pegasys.errorpronechecks; + +import com.google.errorprone.CompilationTestHelper; +import org.junit.Before; +import org.junit.Test; + +public class BannedMethodTest { + + private CompilationTestHelper compilationHelper; + + @Before + public void setup() { + compilationHelper = CompilationTestHelper.newInstance(BannedMethod.class, getClass()); + } + + @Test + public void doNotReturnNullPositiveCases() { + compilationHelper.addSourceFile("BannedMethodPositiveCases.java").doTest(); + } + + @Test + public void doNotReturnNullNegativeCases() { + compilationHelper.addSourceFile("BannedMethodNegativeCases.java").doTest(); + } +} diff --git a/errorprone-checks/src/test/resources/tech/pegasys/errorpronechecks/BannedMethodNegativeCases.java b/errorprone-checks/src/test/resources/tech/pegasys/errorpronechecks/BannedMethodNegativeCases.java new file mode 100644 index 0000000000..e8e236a2d6 --- /dev/null +++ b/errorprone-checks/src/test/resources/tech/pegasys/errorpronechecks/BannedMethodNegativeCases.java @@ -0,0 +1,26 @@ +/* + * Copyright 2018 ConsenSys AG. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package tech.pegasys.errorpronechecks; + +import java.util.Objects; + +public class BannedMethodNegativeCases { + + public void callsObjectsEquals() throws Exception { + Objects.equals("1", "1"); + } + + public void callsObjectsHashCode() throws Exception { + Objects.hash("1", "1"); + } +} diff --git a/errorprone-checks/src/test/resources/tech/pegasys/errorpronechecks/BannedMethodPositiveCases.java b/errorprone-checks/src/test/resources/tech/pegasys/errorpronechecks/BannedMethodPositiveCases.java new file mode 100644 index 0000000000..31818f8119 --- /dev/null +++ b/errorprone-checks/src/test/resources/tech/pegasys/errorpronechecks/BannedMethodPositiveCases.java @@ -0,0 +1,30 @@ +/* + * Copyright 2018 ConsenSys AG. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package tech.pegasys.errorpronechecks; + +import com.google.common.base.Objects; + +public class BannedMethodPositiveCases { + + public void callsObjectsEquals() throws Exception { + // BUG: Diagnostic contains: Do not use com.google.common.base.Objects methods, use + // java.util.Objects methods instead. + Objects.equal("1", "1"); + } + + public void callsObjectsHashCode() throws Exception { + // BUG: Diagnostic contains: Do not use com.google.common.base.Objects methods, use + // java.util.Objects methods instead. + Objects.hashCode("1", "1"); + } +} diff --git a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/core/SyncStatus.java b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/core/SyncStatus.java index 5ecf753a7f..165df0e95d 100644 --- a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/core/SyncStatus.java +++ b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/core/SyncStatus.java @@ -12,7 +12,7 @@ */ package tech.pegasys.pantheon.ethereum.core; -import com.google.common.base.Objects; +import java.util.Objects; public final class SyncStatus { @@ -58,6 +58,6 @@ public final class SyncStatus { @Override public int hashCode() { - return Objects.hashCode(startingBlock, currentBlock, highestBlock); + return Objects.hash(startingBlock, currentBlock, highestBlock); } } diff --git a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/transaction/CallParameter.java b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/transaction/CallParameter.java index 3379f50be4..8f5014adf1 100644 --- a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/transaction/CallParameter.java +++ b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/transaction/CallParameter.java @@ -16,7 +16,7 @@ import tech.pegasys.pantheon.ethereum.core.Address; import tech.pegasys.pantheon.ethereum.core.Wei; import tech.pegasys.pantheon.util.bytes.BytesValue; -import com.google.common.base.Objects; +import java.util.Objects; // Represents parameters for a eth_call or eth_estimateGas JSON-RPC methods. public class CallParameter { @@ -82,15 +82,15 @@ public class CallParameter { } final CallParameter that = (CallParameter) o; return gasLimit == that.gasLimit - && Objects.equal(from, that.from) - && Objects.equal(to, that.to) - && Objects.equal(gasPrice, that.gasPrice) - && Objects.equal(value, that.value) - && Objects.equal(payload, that.payload); + && Objects.equals(from, that.from) + && Objects.equals(to, that.to) + && Objects.equals(gasPrice, that.gasPrice) + && Objects.equals(value, that.value) + && Objects.equals(payload, that.payload); } @Override public int hashCode() { - return Objects.hashCode(from, to, gasLimit, gasPrice, value, payload); + return Objects.hash(from, to, gasLimit, gasPrice, value, payload); } } diff --git a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/transaction/TransactionSimulatorResult.java b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/transaction/TransactionSimulatorResult.java index d5fbce93de..367e78474b 100644 --- a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/transaction/TransactionSimulatorResult.java +++ b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/transaction/TransactionSimulatorResult.java @@ -18,7 +18,7 @@ import tech.pegasys.pantheon.ethereum.mainnet.TransactionValidator.TransactionIn import tech.pegasys.pantheon.ethereum.mainnet.ValidationResult; import tech.pegasys.pantheon.util.bytes.BytesValue; -import com.google.common.base.Objects; +import java.util.Objects; public class TransactionSimulatorResult { @@ -59,11 +59,11 @@ public class TransactionSimulatorResult { return false; } final TransactionSimulatorResult that = (TransactionSimulatorResult) o; - return Objects.equal(transaction, that.transaction) && Objects.equal(result, that.result); + return Objects.equals(transaction, that.transaction) && Objects.equals(result, that.result); } @Override public int hashCode() { - return Objects.hashCode(transaction, result); + return Objects.hash(transaction, result); } } diff --git a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/worldstate/TrieNodeDataRequest.java b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/worldstate/TrieNodeDataRequest.java index e99c3c4c75..1e5aacfafa 100644 --- a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/worldstate/TrieNodeDataRequest.java +++ b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/worldstate/TrieNodeDataRequest.java @@ -18,10 +18,9 @@ import tech.pegasys.pantheon.ethereum.trie.TrieNodeDecoder; import tech.pegasys.pantheon.util.bytes.BytesValue; import java.util.List; +import java.util.Objects; import java.util.stream.Stream; -import com.google.common.base.Objects; - abstract class TrieNodeDataRequest extends NodeDataRequest { TrieNodeDataRequest(final RequestType kind, final Hash hash) { @@ -50,7 +49,7 @@ abstract class TrieNodeDataRequest extends NodeDataRequest { } private boolean nodeIsHashReferencedDescendant(final Node node) { - return !Objects.equal(node.getHash(), getHash()) && node.isReferencedByHash(); + return !Objects.equals(node.getHash(), getHash()) && node.isReferencedByHash(); } protected abstract NodeDataRequest createChildNodeDataRequest(final Hash childHash); diff --git a/ethereum/graphqlrpc/src/main/java/tech/pegasys/pantheon/ethereum/graphqlrpc/GraphQLRpcConfiguration.java b/ethereum/graphqlrpc/src/main/java/tech/pegasys/pantheon/ethereum/graphqlrpc/GraphQLRpcConfiguration.java index 7705499195..0bcf1703a2 100644 --- a/ethereum/graphqlrpc/src/main/java/tech/pegasys/pantheon/ethereum/graphqlrpc/GraphQLRpcConfiguration.java +++ b/ethereum/graphqlrpc/src/main/java/tech/pegasys/pantheon/ethereum/graphqlrpc/GraphQLRpcConfiguration.java @@ -17,10 +17,10 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.List; +import java.util.Objects; import com.google.common.base.MoreObjects; -import com.google.common.base.Objects; -import com.google.common.collect.Lists; public class GraphQLRpcConfiguration { private static final String DEFAULT_GRAPHQL_RPC_HOST = "127.0.0.1"; @@ -29,8 +29,8 @@ public class GraphQLRpcConfiguration { private boolean enabled; private int port; private String host; - private Collection corsAllowedDomains = Collections.emptyList(); - private Collection hostsWhitelist = Arrays.asList("localhost", "127.0.0.1"); + private List corsAllowedDomains = Collections.emptyList(); + private List hostsWhitelist = Arrays.asList("localhost", "127.0.0.1"); public static GraphQLRpcConfiguration createDefault() { final GraphQLRpcConfiguration config = new GraphQLRpcConfiguration(); @@ -70,7 +70,7 @@ public class GraphQLRpcConfiguration { return corsAllowedDomains; } - public void setCorsAllowedDomains(final Collection corsAllowedDomains) { + public void setCorsAllowedDomains(final List corsAllowedDomains) { checkNotNull(corsAllowedDomains); this.corsAllowedDomains = corsAllowedDomains; } @@ -79,7 +79,7 @@ public class GraphQLRpcConfiguration { return Collections.unmodifiableCollection(this.hostsWhitelist); } - public void setHostsWhitelist(final Collection hostsWhitelist) { + public void setHostsWhitelist(final List hostsWhitelist) { checkNotNull(hostsWhitelist); this.hostsWhitelist = hostsWhitelist; } @@ -106,15 +106,13 @@ public class GraphQLRpcConfiguration { final GraphQLRpcConfiguration that = (GraphQLRpcConfiguration) o; return enabled == that.enabled && port == that.port - && Objects.equal(host, that.host) - && Objects.equal( - Lists.newArrayList(corsAllowedDomains), Lists.newArrayList(that.corsAllowedDomains)) - && Objects.equal( - Lists.newArrayList(hostsWhitelist), Lists.newArrayList(that.hostsWhitelist)); + && Objects.equals(host, that.host) + && Objects.equals(corsAllowedDomains, that.corsAllowedDomains) + && Objects.equals(hostsWhitelist, that.hostsWhitelist); } @Override public int hashCode() { - return Objects.hashCode(enabled, port, host, corsAllowedDomains, hostsWhitelist); + return Objects.hash(enabled, port, host, corsAllowedDomains, hostsWhitelist); } } diff --git a/ethereum/graphqlrpc/src/main/java/tech/pegasys/pantheon/ethereum/graphqlrpc/internal/response/GraphQLRpcResponse.java b/ethereum/graphqlrpc/src/main/java/tech/pegasys/pantheon/ethereum/graphqlrpc/internal/response/GraphQLRpcResponse.java index ac9fe579e3..d429587339 100644 --- a/ethereum/graphqlrpc/src/main/java/tech/pegasys/pantheon/ethereum/graphqlrpc/internal/response/GraphQLRpcResponse.java +++ b/ethereum/graphqlrpc/src/main/java/tech/pegasys/pantheon/ethereum/graphqlrpc/internal/response/GraphQLRpcResponse.java @@ -12,7 +12,7 @@ */ package tech.pegasys.pantheon.ethereum.graphqlrpc.internal.response; -import com.google.common.base.Objects; +import java.util.Objects; public abstract class GraphQLRpcResponse { public abstract GraphQLRpcResponseType getType(); @@ -36,7 +36,7 @@ public abstract class GraphQLRpcResponse { return false; } final GraphQLRpcResponse that = (GraphQLRpcResponse) o; - return Objects.equal(result, that.result); + return Objects.equals(result, that.result); } @Override diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcConfiguration.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcConfiguration.java index d2eb46fe00..f5297ec56a 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcConfiguration.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcConfiguration.java @@ -16,10 +16,10 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.List; +import java.util.Objects; import com.google.common.base.MoreObjects; -import com.google.common.base.Objects; -import com.google.common.collect.Lists; public class JsonRpcConfiguration { private static final String DEFAULT_JSON_RPC_HOST = "127.0.0.1"; @@ -28,9 +28,9 @@ public class JsonRpcConfiguration { private boolean enabled; private int port; private String host; - private Collection corsAllowedDomains = Collections.emptyList(); - private Collection rpcApis; - private Collection hostsWhitelist = Arrays.asList("localhost", "127.0.0.1");; + private List corsAllowedDomains = Collections.emptyList(); + private List rpcApis; + private List hostsWhitelist = Arrays.asList("localhost", "127.0.0.1"); private boolean authenticationEnabled = false; private String authenticationCredentialsFile; @@ -73,7 +73,7 @@ public class JsonRpcConfiguration { return corsAllowedDomains; } - public void setCorsAllowedDomains(final Collection corsAllowedDomains) { + public void setCorsAllowedDomains(final List corsAllowedDomains) { if (corsAllowedDomains != null) { this.corsAllowedDomains = corsAllowedDomains; } @@ -83,7 +83,7 @@ public class JsonRpcConfiguration { return rpcApis; } - public void setRpcApis(final Collection rpcApis) { + public void setRpcApis(final List rpcApis) { this.rpcApis = rpcApis; } @@ -96,7 +96,7 @@ public class JsonRpcConfiguration { return Collections.unmodifiableCollection(this.hostsWhitelist); } - public void setHostsWhitelist(final Collection hostsWhitelist) { + public void setHostsWhitelist(final List hostsWhitelist) { this.hostsWhitelist = hostsWhitelist; } @@ -125,17 +125,15 @@ public class JsonRpcConfiguration { final JsonRpcConfiguration that = (JsonRpcConfiguration) o; return enabled == that.enabled && port == that.port - && Objects.equal(host, that.host) - && Objects.equal( - Lists.newArrayList(corsAllowedDomains), Lists.newArrayList(that.corsAllowedDomains)) - && Objects.equal( - Lists.newArrayList(hostsWhitelist), Lists.newArrayList(that.hostsWhitelist)) - && Objects.equal(Lists.newArrayList(rpcApis), Lists.newArrayList(that.rpcApis)); + && Objects.equals(host, that.host) + && Objects.equals(corsAllowedDomains, that.corsAllowedDomains) + && Objects.equals(hostsWhitelist, that.hostsWhitelist) + && Objects.equals(rpcApis, that.rpcApis); } @Override public int hashCode() { - return Objects.hashCode(enabled, port, host, corsAllowedDomains, hostsWhitelist, rpcApis); + return Objects.hash(enabled, port, host, corsAllowedDomains, hostsWhitelist, rpcApis); } public boolean isAuthenticationEnabled() { diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/RpcApi.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/RpcApi.java index b758ac6343..624770f5d4 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/RpcApi.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/RpcApi.java @@ -12,7 +12,7 @@ */ package tech.pegasys.pantheon.ethereum.jsonrpc; -import com.google.common.base.Objects; +import java.util.Objects; public class RpcApi { private final String cliValue; @@ -34,7 +34,7 @@ public class RpcApi { return false; } final RpcApi rpcApi = (RpcApi) o; - return Objects.equal(cliValue, rpcApi.cliValue); + return Objects.equals(cliValue, rpcApi.cliValue); } @Override diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/RpcApis.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/RpcApis.java index b9f0f071ad..78387d16dc 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/RpcApis.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/RpcApis.java @@ -13,7 +13,7 @@ package tech.pegasys.pantheon.ethereum.jsonrpc; import java.util.Arrays; -import java.util.Collection; +import java.util.List; import java.util.Optional; public class RpcApis { @@ -28,7 +28,7 @@ public class RpcApis { public static final RpcApi EEA = new RpcApi("EEA"); public static final RpcApi TX_POOL = new RpcApi("TXPOOL"); - public static final Collection DEFAULT_JSON_RPC_APIS = Arrays.asList(ETH, NET, WEB3); + public static final List DEFAULT_JSON_RPC_APIS = Arrays.asList(ETH, NET, WEB3); public static Optional valueOf(final String name) { if (name.equals(ETH.getCliValue())) { diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/JsonRpcRequest.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/JsonRpcRequest.java index 15364555b1..58c15421b8 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/JsonRpcRequest.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/JsonRpcRequest.java @@ -15,6 +15,7 @@ package tech.pegasys.pantheon.ethereum.jsonrpc.internal; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.exception.InvalidJsonRpcRequestException; import java.util.Arrays; +import java.util.Objects; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonGetter; @@ -24,7 +25,6 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSetter; -import com.google.common.base.Objects; @JsonIgnoreProperties(ignoreUnknown = true) public class JsonRpcRequest { @@ -112,14 +112,14 @@ public class JsonRpcRequest { } final JsonRpcRequest that = (JsonRpcRequest) o; return isNotification == that.isNotification - && Objects.equal(id, that.id) - && Objects.equal(method, that.method) + && Objects.equals(id, that.id) + && Objects.equals(method, that.method) && Arrays.equals(params, that.params) - && Objects.equal(version, that.version); + && Objects.equals(version, that.version); } @Override public int hashCode() { - return Objects.hashCode(id, method, Arrays.hashCode(params), version, isNotification); + return Objects.hash(id, method, Arrays.hashCode(params), version, isNotification); } } diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/JsonRpcRequestId.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/JsonRpcRequestId.java index ff2bb66e2c..6f12c130dc 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/JsonRpcRequestId.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/JsonRpcRequestId.java @@ -15,10 +15,10 @@ package tech.pegasys.pantheon.ethereum.jsonrpc.internal; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.exception.InvalidJsonRpcRequestException; import java.math.BigInteger; +import java.util.Objects; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -import com.google.common.base.Objects; public class JsonRpcRequestId { @@ -73,7 +73,7 @@ public class JsonRpcRequestId { return false; } final JsonRpcRequestId that = (JsonRpcRequestId) o; - return Objects.equal(id, that.id); + return Objects.equals(id, that.id); } @Override diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/response/JsonRpcErrorResponse.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/response/JsonRpcErrorResponse.java index 5eddab85c8..b7571fc8ba 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/response/JsonRpcErrorResponse.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/response/JsonRpcErrorResponse.java @@ -12,10 +12,11 @@ */ package tech.pegasys.pantheon.ethereum.jsonrpc.internal.response; +import java.util.Objects; + import com.fasterxml.jackson.annotation.JsonGetter; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.google.common.base.Objects; @JsonPropertyOrder({"jsonrpc", "id", "error"}) public class JsonRpcErrorResponse implements JsonRpcResponse { @@ -53,11 +54,11 @@ public class JsonRpcErrorResponse implements JsonRpcResponse { return false; } final JsonRpcErrorResponse that = (JsonRpcErrorResponse) o; - return Objects.equal(id, that.id) && error == that.error; + return Objects.equals(id, that.id) && error == that.error; } @Override public int hashCode() { - return Objects.hashCode(id, error); + return Objects.hash(id, error); } } diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/response/JsonRpcSuccessResponse.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/response/JsonRpcSuccessResponse.java index 35e9f29b09..50a0cc3ecd 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/response/JsonRpcSuccessResponse.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/response/JsonRpcSuccessResponse.java @@ -12,10 +12,11 @@ */ package tech.pegasys.pantheon.ethereum.jsonrpc.internal.response; +import java.util.Objects; + import com.fasterxml.jackson.annotation.JsonGetter; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.google.common.base.Objects; @JsonPropertyOrder({"jsonrpc", "id", "result"}) public class JsonRpcSuccessResponse implements JsonRpcResponse { @@ -58,11 +59,11 @@ public class JsonRpcSuccessResponse implements JsonRpcResponse { return false; } final JsonRpcSuccessResponse that = (JsonRpcSuccessResponse) o; - return Objects.equal(id, that.id) && Objects.equal(result, that.result); + return Objects.equals(id, that.id) && Objects.equals(result, that.result); } @Override public int hashCode() { - return Objects.hashCode(id, result); + return Objects.hash(id, result); } } diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/response/JsonRpcUnauthorizedResponse.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/response/JsonRpcUnauthorizedResponse.java index 26c8c98365..11e0894855 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/response/JsonRpcUnauthorizedResponse.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/response/JsonRpcUnauthorizedResponse.java @@ -12,10 +12,11 @@ */ package tech.pegasys.pantheon.ethereum.jsonrpc.internal.response; +import java.util.Objects; + import com.fasterxml.jackson.annotation.JsonGetter; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.google.common.base.Objects; @JsonPropertyOrder({"jsonrpc", "id", "error"}) public class JsonRpcUnauthorizedResponse implements JsonRpcResponse { @@ -53,11 +54,11 @@ public class JsonRpcUnauthorizedResponse implements JsonRpcResponse { return false; } final JsonRpcUnauthorizedResponse that = (JsonRpcUnauthorizedResponse) o; - return Objects.equal(id, that.id) && error == that.error; + return Objects.equals(id, that.id) && error == that.error; } @Override public int hashCode() { - return Objects.hashCode(id, error); + return Objects.hash(id, error); } } diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/websocket/WebSocketConfiguration.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/websocket/WebSocketConfiguration.java index 27c39ba0dc..04c1848b78 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/websocket/WebSocketConfiguration.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/websocket/WebSocketConfiguration.java @@ -15,25 +15,24 @@ package tech.pegasys.pantheon.ethereum.jsonrpc.websocket; import tech.pegasys.pantheon.ethereum.jsonrpc.RpcApi; import tech.pegasys.pantheon.ethereum.jsonrpc.RpcApis; -import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.List; +import java.util.Objects; import com.google.common.base.MoreObjects; -import com.google.common.base.Objects; -import com.google.common.collect.Lists; public class WebSocketConfiguration { public static final String DEFAULT_WEBSOCKET_HOST = "127.0.0.1"; public static final int DEFAULT_WEBSOCKET_PORT = 8546; - public static final Collection DEFAULT_WEBSOCKET_APIS = + public static final List DEFAULT_WEBSOCKET_APIS = Arrays.asList(RpcApis.ETH, RpcApis.NET, RpcApis.WEB3); private boolean enabled; private int port; private String host; - private Collection rpcApis; + private List rpcApis; private boolean authenticationEnabled = false; private String authenticationCredentialsFile; private Collection hostsWhitelist = Collections.singletonList("localhost"); @@ -77,15 +76,10 @@ public class WebSocketConfiguration { return rpcApis; } - public void setRpcApis(final Collection rpcApis) { + public void setRpcApis(final List rpcApis) { this.rpcApis = rpcApis; } - public void addRpcApi(final RpcApi rpcApi) { - this.rpcApis = new ArrayList<>(rpcApis); - rpcApis.add(rpcApi); - } - @Override public String toString() { return MoreObjects.toStringHelper(this) @@ -109,13 +103,13 @@ public class WebSocketConfiguration { final WebSocketConfiguration that = (WebSocketConfiguration) o; return enabled == that.enabled && port == that.port - && Objects.equal(host, that.host) - && Objects.equal(Lists.newArrayList(rpcApis), Lists.newArrayList(that.rpcApis)); + && Objects.equals(host, that.host) + && Objects.equals(rpcApis, that.rpcApis); } @Override public int hashCode() { - return Objects.hashCode(enabled, port, host, rpcApis); + return Objects.hash(enabled, port, host, rpcApis); } public boolean isAuthenticationEnabled() { diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/websocket/subscription/Subscription.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/websocket/subscription/Subscription.java index ab6cb3b89a..7c87fd9be4 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/websocket/subscription/Subscription.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/websocket/subscription/Subscription.java @@ -14,8 +14,9 @@ package tech.pegasys.pantheon.ethereum.jsonrpc.websocket.subscription; import tech.pegasys.pantheon.ethereum.jsonrpc.websocket.subscription.request.SubscriptionType; +import java.util.Objects; + import com.google.common.base.MoreObjects; -import com.google.common.base.Objects; public class Subscription { @@ -63,11 +64,11 @@ public class Subscription { return false; } final Subscription that = (Subscription) o; - return Objects.equal(id, that.id) && subscriptionType == that.subscriptionType; + return Objects.equals(id, that.id) && subscriptionType == that.subscriptionType; } @Override public int hashCode() { - return Objects.hashCode(id, subscriptionType); + return Objects.hash(id, subscriptionType); } } diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/websocket/subscription/request/SubscribeRequest.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/websocket/subscription/request/SubscribeRequest.java index 3d0fd26a6b..da34119334 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/websocket/subscription/request/SubscribeRequest.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/websocket/subscription/request/SubscribeRequest.java @@ -14,7 +14,7 @@ package tech.pegasys.pantheon.ethereum.jsonrpc.websocket.subscription.request; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.parameters.FilterParameter; -import com.google.common.base.Objects; +import java.util.Objects; public class SubscribeRequest { @@ -74,13 +74,13 @@ public class SubscribeRequest { } final SubscribeRequest that = (SubscribeRequest) o; return subscriptionType == that.subscriptionType - && Objects.equal(includeTransaction, that.includeTransaction) - && Objects.equal(filterParameter, that.filterParameter) - && Objects.equal(connectionId, that.connectionId); + && Objects.equals(includeTransaction, that.includeTransaction) + && Objects.equals(filterParameter, that.filterParameter) + && Objects.equals(connectionId, that.connectionId); } @Override public int hashCode() { - return Objects.hashCode(subscriptionType, includeTransaction, filterParameter, connectionId); + return Objects.hash(subscriptionType, includeTransaction, filterParameter, connectionId); } } diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/websocket/subscription/request/UnsubscribeRequest.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/websocket/subscription/request/UnsubscribeRequest.java index 9a330726ad..00cba6a225 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/websocket/subscription/request/UnsubscribeRequest.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/websocket/subscription/request/UnsubscribeRequest.java @@ -12,7 +12,7 @@ */ package tech.pegasys.pantheon.ethereum.jsonrpc.websocket.subscription.request; -import com.google.common.base.Objects; +import java.util.Objects; public class UnsubscribeRequest { @@ -51,12 +51,12 @@ public class UnsubscribeRequest { return false; } final UnsubscribeRequest that = (UnsubscribeRequest) o; - return Objects.equal(subscriptionId, that.subscriptionId) - && Objects.equal(connectionId, that.connectionId); + return Objects.equals(subscriptionId, that.subscriptionId) + && Objects.equals(connectionId, that.connectionId); } @Override public int hashCode() { - return Objects.hashCode(subscriptionId, connectionId); + return Objects.hash(subscriptionId, connectionId); } } diff --git a/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/rlpx/handshake/HandshakeSecrets.java b/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/rlpx/handshake/HandshakeSecrets.java index 97f5b01590..d05769db76 100644 --- a/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/rlpx/handshake/HandshakeSecrets.java +++ b/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/rlpx/handshake/HandshakeSecrets.java @@ -157,6 +157,7 @@ public class HandshakeSecrets { return out; } + @SuppressWarnings("EqualsWhichDoesntCheckParameterClass") // checked in delegated method @Override public boolean equals(final Object obj) { return equals(obj, false); diff --git a/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/wire/AbstractMessageData.java b/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/wire/AbstractMessageData.java index 0ff7a35994..42721fd258 100644 --- a/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/wire/AbstractMessageData.java +++ b/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/wire/AbstractMessageData.java @@ -15,7 +15,7 @@ package tech.pegasys.pantheon.ethereum.p2p.wire; import tech.pegasys.pantheon.ethereum.p2p.api.MessageData; import tech.pegasys.pantheon.util.bytes.BytesValue; -import com.google.common.base.Objects; +import java.util.Objects; public abstract class AbstractMessageData implements MessageData { @@ -44,7 +44,7 @@ public abstract class AbstractMessageData implements MessageData { return false; } final AbstractMessageData that = (AbstractMessageData) o; - return Objects.equal(data, that.data); + return Objects.equals(data, that.data); } @Override diff --git a/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/node/NodeWhitelistUpdatedEvent.java b/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/node/NodeWhitelistUpdatedEvent.java index 4654c5a189..c59b8a915e 100644 --- a/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/node/NodeWhitelistUpdatedEvent.java +++ b/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/node/NodeWhitelistUpdatedEvent.java @@ -16,8 +16,7 @@ import tech.pegasys.pantheon.util.enode.EnodeURL; import java.util.Collections; import java.util.List; - -import com.google.common.base.Objects; +import java.util.Objects; public class NodeWhitelistUpdatedEvent { @@ -47,12 +46,12 @@ public class NodeWhitelistUpdatedEvent { return false; } NodeWhitelistUpdatedEvent that = (NodeWhitelistUpdatedEvent) o; - return Objects.equal(addedNodes, that.addedNodes) - && Objects.equal(removedNodes, that.removedNodes); + return Objects.equals(addedNodes, that.addedNodes) + && Objects.equals(removedNodes, that.removedNodes); } @Override public int hashCode() { - return Objects.hashCode(addedNodes, removedNodes); + return Objects.hash(addedNodes, removedNodes); } } diff --git a/metrics/core/src/main/java/tech/pegasys/pantheon/metrics/prometheus/MetricsConfiguration.java b/metrics/core/src/main/java/tech/pegasys/pantheon/metrics/prometheus/MetricsConfiguration.java index ae18aa2e82..7e9b4a0dc5 100644 --- a/metrics/core/src/main/java/tech/pegasys/pantheon/metrics/prometheus/MetricsConfiguration.java +++ b/metrics/core/src/main/java/tech/pegasys/pantheon/metrics/prometheus/MetricsConfiguration.java @@ -19,11 +19,10 @@ import tech.pegasys.pantheon.metrics.MetricCategory; import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.List; import java.util.Objects; import java.util.Set; -import com.google.common.collect.Lists; - public class MetricsConfiguration { private static final String DEFAULT_METRICS_HOST = "127.0.0.1"; public static final int DEFAULT_METRICS_PORT = 9545; @@ -40,7 +39,7 @@ public class MetricsConfiguration { private String pushHost; private int pushInterval; private String prometheusJob; - private Collection hostsWhitelist = Arrays.asList("localhost", "127.0.0.1"); + private List hostsWhitelist = Arrays.asList("localhost", "127.0.0.1"); public static MetricsConfiguration createDefault() { final MetricsConfiguration metricsConfiguration = new MetricsConfiguration(); @@ -135,7 +134,7 @@ public class MetricsConfiguration { return Collections.unmodifiableCollection(this.hostsWhitelist); } - public void setHostsWhitelist(final Collection hostsWhitelist) { + public void setHostsWhitelist(final List hostsWhitelist) { this.hostsWhitelist = hostsWhitelist; } @@ -182,8 +181,7 @@ public class MetricsConfiguration { && Objects.equals(host, that.host) && Objects.equals(pushHost, that.pushHost) && Objects.equals(prometheusJob, that.prometheusJob) - && com.google.common.base.Objects.equal( - Lists.newArrayList(hostsWhitelist), Lists.newArrayList(that.hostsWhitelist)); + && Objects.equals(hostsWhitelist, that.hostsWhitelist); } @Override diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/cli/EthNetworkConfig.java b/pantheon/src/main/java/tech/pegasys/pantheon/cli/EthNetworkConfig.java index 41d68953ca..eea27f2165 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/cli/EthNetworkConfig.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/cli/EthNetworkConfig.java @@ -28,7 +28,6 @@ import java.util.List; import java.util.Objects; import com.google.common.base.Preconditions; -import com.google.common.collect.Lists; import com.google.common.io.Resources; public class EthNetworkConfig { @@ -78,7 +77,7 @@ public class EthNetworkConfig { final EthNetworkConfig that = (EthNetworkConfig) o; return networkId == that.networkId && Objects.equals(genesisConfig, that.genesisConfig) - && Objects.equals(Lists.newArrayList(bootNodes), Lists.newArrayList(that.bootNodes)); + && Objects.equals(bootNodes, that.bootNodes); } @Override diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java b/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java index 1962b5effc..7877dc281d 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java @@ -358,7 +358,7 @@ public class PantheonCommand implements DefaultCommandValues, Runnable { converter = RpcApisConverter.class, description = "Comma separated list of APIs to enable on JSON-RPC WebSocket service (default: ${DEFAULT-VALUE})") - private final Collection rpcWsApis = DEFAULT_JSON_RPC_APIS; + private final List rpcWsApis = DEFAULT_JSON_RPC_APIS; @Option( names = {"--rpc-ws-authentication-enabled"}, diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/cli/custom/CorsAllowedOriginsProperty.java b/pantheon/src/main/java/tech/pegasys/pantheon/cli/custom/CorsAllowedOriginsProperty.java index ea3d934e79..e1f3cc4d5f 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/cli/custom/CorsAllowedOriginsProperty.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/cli/custom/CorsAllowedOriginsProperty.java @@ -12,7 +12,7 @@ */ package tech.pegasys.pantheon.cli.custom; -import java.util.AbstractCollection; +import java.util.AbstractList; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -26,7 +26,7 @@ import javax.annotation.Nonnull; import com.google.common.base.Splitter; import com.google.common.base.Strings; -public class CorsAllowedOriginsProperty extends AbstractCollection { +public class CorsAllowedOriginsProperty extends AbstractList { private final List domains = new ArrayList<>(); @@ -52,6 +52,11 @@ public class CorsAllowedOriginsProperty extends AbstractCollection { return addAll(Collections.singleton(string)); } + @Override + public String get(final int index) { + return domains.get(index); + } + @Override public boolean addAll(final Collection collection) { final int initialSize = domains.size(); diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/cli/custom/JsonRPCWhitelistHostsProperty.java b/pantheon/src/main/java/tech/pegasys/pantheon/cli/custom/JsonRPCWhitelistHostsProperty.java index fdd39b057a..9058aa194e 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/cli/custom/JsonRPCWhitelistHostsProperty.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/cli/custom/JsonRPCWhitelistHostsProperty.java @@ -12,7 +12,7 @@ */ package tech.pegasys.pantheon.cli.custom; -import java.util.AbstractCollection; +import java.util.AbstractList; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -23,7 +23,7 @@ import javax.annotation.Nonnull; import com.google.common.base.Splitter; import com.google.common.base.Strings; -public class JsonRPCWhitelistHostsProperty extends AbstractCollection { +public class JsonRPCWhitelistHostsProperty extends AbstractList { private final List hostnamesWhitelist = new ArrayList<>(); @@ -49,6 +49,11 @@ public class JsonRPCWhitelistHostsProperty extends AbstractCollection { return addAll(Collections.singleton(string)); } + @Override + public String get(final int index) { + return hostnamesWhitelist.get(index); + } + @Override public boolean addAll(final Collection collection) { final int initialSize = hostnamesWhitelist.size(); diff --git a/pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java b/pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java index 0dd5caed7b..cf8ecdb383 100644 --- a/pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java +++ b/pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java @@ -60,7 +60,6 @@ import java.net.URL; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.List; @@ -277,7 +276,7 @@ public class PantheonCommandTest extends CommandTestAbstract { .replace("~/genesis.json", escapeTomlString(genesisFile.toString())); final Path toml = createTempFile("toml", updatedConfig.getBytes(UTF_8)); - final Collection expectedApis = asList(ETH, WEB3); + final List expectedApis = asList(ETH, WEB3); final JsonRpcConfiguration jsonRpcConfiguration = JsonRpcConfiguration.createDefault(); jsonRpcConfiguration.setEnabled(false); diff --git a/util/src/main/java/tech/pegasys/pantheon/util/enode/EnodeURL.java b/util/src/main/java/tech/pegasys/pantheon/util/enode/EnodeURL.java index d0b4f2bd6c..2509676045 100644 --- a/util/src/main/java/tech/pegasys/pantheon/util/enode/EnodeURL.java +++ b/util/src/main/java/tech/pegasys/pantheon/util/enode/EnodeURL.java @@ -20,11 +20,11 @@ import tech.pegasys.pantheon.util.bytes.BytesValue; import java.net.InetAddress; import java.net.URI; +import java.util.Objects; import java.util.OptionalInt; import java.util.regex.Matcher; import java.util.regex.Pattern; -import com.google.common.base.Objects; import com.google.common.net.InetAddresses; import com.google.common.primitives.Ints; @@ -128,9 +128,9 @@ public class EnodeURL { return false; } - return Objects.equal(enodeA.nodeId, enodeB.nodeId) - && Objects.equal(enodeA.ip, enodeB.ip) - && Objects.equal(enodeA.listeningPort, enodeB.listeningPort); + return Objects.equals(enodeA.nodeId, enodeB.nodeId) + && Objects.equals(enodeA.ip, enodeB.ip) + && Objects.equals(enodeA.listeningPort, enodeB.listeningPort); } public URI toURI() { @@ -209,15 +209,15 @@ public class EnodeURL { return false; } EnodeURL enodeURL = (EnodeURL) o; - return Objects.equal(nodeId, enodeURL.nodeId) - && Objects.equal(ip, enodeURL.ip) - && Objects.equal(listeningPort, enodeURL.listeningPort) - && Objects.equal(discoveryPort, enodeURL.discoveryPort); + return Objects.equals(nodeId, enodeURL.nodeId) + && Objects.equals(ip, enodeURL.ip) + && Objects.equals(listeningPort, enodeURL.listeningPort) + && Objects.equals(discoveryPort, enodeURL.discoveryPort); } @Override public int hashCode() { - return Objects.hashCode(nodeId, ip, listeningPort, discoveryPort); + return Objects.hash(nodeId, ip, listeningPort, discoveryPort); } @Override