diff --git a/core/src/main/java/com/google/bitcoin/core/Peer.java b/core/src/main/java/com/google/bitcoin/core/Peer.java index 8725f93a..68e44c31 100644 --- a/core/src/main/java/com/google/bitcoin/core/Peer.java +++ b/core/src/main/java/com/google/bitcoin/core/Peer.java @@ -664,9 +664,9 @@ public class Peer extends PeerSocketHandler { log.info("{}: Downloading dependencies of {}", getAddress(), tx.getHashAsString()); final LinkedList results = new LinkedList(); // future will be invoked when the entire dependency tree has been walked and the results compiled. - final ListenableFuture future = downloadDependenciesInternal(tx, new Object(), results); + final ListenableFuture future = downloadDependenciesInternal(tx, new Object(), results); final SettableFuture> resultFuture = SettableFuture.create(); - Futures.addCallback(future, new FutureCallback() { + Futures.addCallback(future, new FutureCallback() { public void onSuccess(Object ignored) { resultFuture.set(results); } @@ -1083,6 +1083,10 @@ public class Peer extends PeerSocketHandler { * If you want the block right away and don't mind waiting for it, just call .get() on the result. Your thread * will block until the peer answers. */ + @SuppressWarnings("unchecked") + // The 'unchecked conversion' warning being suppressed here comes from the sendSingleGetData() formally returning + // ListenableFuture instead of ListenableFuture. This is okay as sendSingleGetData() actually returns + // ListenableFuture in this context. Note that sendSingleGetData() is also used for Transactions. public ListenableFuture getBlock(Sha256Hash blockHash) { // This does not need to be locked. log.info("Request to fetch block {}", blockHash); @@ -1096,6 +1100,10 @@ public class Peer extends PeerSocketHandler { * retrieved this way because peers don't have a transaction ID to transaction-pos-on-disk index, and besides, * in future many peers will delete old transaction data they don't need. */ + @SuppressWarnings("unchecked") + // The 'unchecked conversion' warning being suppressed here comes from the sendSingleGetData() formally returning + // ListenableFuture instead of ListenableFuture. This is okay as sendSingleGetData() actually returns + // ListenableFuture in this context. Note that sendSingleGetData() is also used for Blocks. public ListenableFuture getPeerMempoolTransaction(Sha256Hash hash) { // This does not need to be locked. // TODO: Unit test this method. diff --git a/core/src/main/java/com/google/bitcoin/net/ProtobufParser.java b/core/src/main/java/com/google/bitcoin/net/ProtobufParser.java index 1a7a8e92..1036532f 100644 --- a/core/src/main/java/com/google/bitcoin/net/ProtobufParser.java +++ b/core/src/main/java/com/google/bitcoin/net/ProtobufParser.java @@ -122,6 +122,9 @@ public class ProtobufParser extends AbstractTim // Deserializes and provides a listener event (buff must not have the length prefix in it) // Does set the buffers's position to its limit + @SuppressWarnings("unchecked") + // The warning 'unchecked cast' being suppressed here comes from the build() formally returning + // a MessageLite-derived class that cannot be statically guaranteed to be the MessageType. private void deserializeMessage(ByteBuffer buff) throws Exception { MessageType msg = (MessageType) prototype.newBuilderForType().mergeFrom(ByteString.copyFrom(buff)).build(); resetTimeout(); diff --git a/core/src/main/java/com/google/bitcoin/protocols/channels/ServerConnectionEventHandler.java b/core/src/main/java/com/google/bitcoin/protocols/channels/ServerConnectionEventHandler.java index 027e9795..bd4c159d 100644 --- a/core/src/main/java/com/google/bitcoin/protocols/channels/ServerConnectionEventHandler.java +++ b/core/src/main/java/com/google/bitcoin/protocols/channels/ServerConnectionEventHandler.java @@ -44,10 +44,13 @@ public abstract class ServerConnectionEventHandler { * {@link StoredPaymentChannelServerStates#getChannel(com.google.bitcoin.core.Sha256Hash)} with the id provided in * {@link ServerConnectionEventHandler#channelOpen(com.google.bitcoin.core.Sha256Hash)}

*/ + @SuppressWarnings("unchecked") + // The warning 'unchecked call to write(MessageType)' being suppressed here comes from the build() + // formally returning MessageLite-derived class that cannot be statically guaranteed to be the same MessageType + // that is used in connectionChannel. protected final synchronized void closeChannel() { if (connectionChannel == null) throw new IllegalStateException("Channel is not fully initialized/has already been closed"); - connectionChannel.write(Protos.TwoWayChannelMessage.newBuilder() .setType(Protos.TwoWayChannelMessage.MessageType.CLOSE) .build()); diff --git a/core/src/main/java/com/google/bitcoin/store/PostgresFullPrunedBlockStore.java b/core/src/main/java/com/google/bitcoin/store/PostgresFullPrunedBlockStore.java index 9aa511fe..2a872198 100644 --- a/core/src/main/java/com/google/bitcoin/store/PostgresFullPrunedBlockStore.java +++ b/core/src/main/java/com/google/bitcoin/store/PostgresFullPrunedBlockStore.java @@ -765,7 +765,7 @@ public class PostgresFullPrunedBlockStore implements FullPrunedBlockStore { // Calculate the toAddress (if any) String dbAddress = ""; int type = 0; - Script outputScript = null; + Script outputScript = null; try { outputScript = new Script(out.getScriptBytes()); diff --git a/core/src/test/java/com/google/bitcoin/core/WalletTest.java b/core/src/test/java/com/google/bitcoin/core/WalletTest.java index 12a25e7d..0d757340 100644 --- a/core/src/test/java/com/google/bitcoin/core/WalletTest.java +++ b/core/src/test/java/com/google/bitcoin/core/WalletTest.java @@ -335,6 +335,8 @@ public class WalletTest extends TestWithWallet { assertTrue(depthFuture.isDone()); } + @SuppressWarnings("deprecation") + // Having a test for deprecated method getFromAddress() is no evil so we suppress the warning here. private void basicSanityChecks(Wallet wallet, Transaction t, Address fromAddress, Address destination) throws VerificationException { assertEquals("Wrong number of tx inputs", 1, t.getInputs().size()); assertEquals(fromAddress, t.getInputs().get(0).getScriptSig().getFromAddress(params)); @@ -389,6 +391,8 @@ public class WalletTest extends TestWithWallet { } @Test + @SuppressWarnings("deprecation") + // Having a test for deprecated method getFromAddress() is no evil so we suppress the warning here. public void customTransactionSpending() throws Exception { // We'll set up a wallet that receives a coin, then sends a coin of lesser value and keeps the change. BigInteger v1 = Utils.toNanoCoins(3, 0); diff --git a/examples/src/main/java/com/google/bitcoin/examples/PrintPeers.java b/examples/src/main/java/com/google/bitcoin/examples/PrintPeers.java index 6e7b5875..d4600f88 100644 --- a/examples/src/main/java/com/google/bitcoin/examples/PrintPeers.java +++ b/examples/src/main/java/com/google/bitcoin/examples/PrintPeers.java @@ -82,7 +82,7 @@ public class PrintPeers { for (final InetAddress addr : addrs) { InetSocketAddress address = new InetSocketAddress(addr, params.getPort()); final Peer peer = new Peer(params, new VersionMessage(params, 0), null, new PeerAddress(address)); - final SettableFuture future = SettableFuture.create(); + final SettableFuture future = SettableFuture.create(); // Once the connection has completed version handshaking ... peer.addEventListener(new AbstractPeerEventListener() { public void onPeerConnected(Peer p, int peerCount) {