Buggy code:
public class Tx extends Message implements Comparable < Tx > { public enum TxNotificationType { txSend ( 0 ) , txReceive ( 1 ) , txDoubleSpend ( 2 ) , txFromApi ( 3 ) ; private int mVal ; private TxNotificationType ( int val ) { } public int getValue ( ) { } } public enum SourceType { network ( 0 ) , self ( 1 ) ; private int mVal ; private SourceType ( int val ) { } public int getValue ( ) { } } private static final Logger log = LoggerFactory . getLogger ( Tx . class ) ; public static final int LOCKTIME_THRESHOLD = 500000000 ; public static final int MAX_STANDARD_TX_SIZE = 100 * 1024 ; public static final long REFERENCE_DEFAULT_MIN_TX_FEE = 1000 ; public static final long MIN_NONDUST_OUTPUT = 5460 ; public Tx ( ) { } public Tx ( Tx tx ) { } public Tx ( byte [ ] msg ) { } public Tx ( byte [ ] msg , int offset , int length ) { } public static final int TX_UNCONFIRMED = Integer . MAX_VALUE ; public static final long TX_VERSION = 1L ; public static final long TX_LOCKTIME = 0L ; private int blockNo ; private byte [ ] txHash ; private int txTime ; private long txVer ; private long txLockTime ; private int source ; private int sawByPeerCnt ; private List < In > ins ; private List < Out > outs ; private transient int optimalEncodingMessageSize ; public int getBlockNo ( ) { } public void setBlockNo ( int blockNo ) { } public byte [ ] getTxHash ( ) { } public void recaculateTxHash ( ) { } public void setTxHash ( byte [ ] txHash ) { } public int getTxTime ( ) { } public void setTxTime ( int txTime ) { } public long getTxVer ( ) { } public void setTxVer ( long txVer ) { } public long getTxLockTime ( ) { } public void setTxLockTime ( long txLockTime ) { } public int getSource ( ) { } public void setSource ( int source ) { } public List < In > getIns ( ) { } public void setIns ( List < In > ins ) { } public List < Out > getOuts ( ) { } public void setOuts ( List < Out > outs ) { } public int getSawByPeerCnt ( ) { } public void setSawByPeerCnt ( int sawByPeerCnt ) { } public void sawByPeer ( ) { } @ Override public boolean equals ( Object o ) { } @ Override public int compareTo ( @ Nonnull Tx tx ) { } public String getFirstOutAddressOtherThanChange ( String changeAddress ) { } public String getFirstOutAddress ( ) { } public String getFromAddress ( ) { } public long amountSentToAddress ( String address ) { } public long getFee ( ) { long amount = 0 ; for ( In in : getIns ( ) ) { Tx preTx = txProvider . getTxDetailByTxHash ( in . getPrevTxHash ( ) ) ; boolean hasOut = false ; for ( Out out : preTx . getOuts ( ) ) { if ( ( in . getPrevOutSn ( ) ) == ( out . getOutSn ( ) ) ) { <START_BUG> amount += preTx . getOuts ( ) . get ( in . getPrevOutSn ( ) ) . getOutValue ( ) ; <END_BUG> hasOut = true ; } } if ( ! hasOut ) { return Long . MAX_VALUE ; } } for ( Out out : getOuts ( ) ) { amount -= out . getOutValue ( ) ; } return amount ; } public String getHashAsString ( ) { } public Date getTxDate ( ) { } protected static int calcLength ( byte [ ] buf , int offset ) { } protected void parse ( ) throws ProtocolException { } public int getOptimalEncodingMessageSize ( ) { } public boolean isCoinBase ( ) { } public boolean isMature ( ) { } public void clearInputs ( ) { } public In addInput ( Out from ) { } public In addInput ( In input ) { } public In addSignedInput ( Out prevOut , Script scriptPubKey , ECKey sigKey , TransactionSignature . SigHash sigHash , boolean anyoneCanPay ) throws ScriptException { } public In addSignedInput ( Out prevOut , Script scriptPubKey , ECKey sigKey ) throws ScriptException { } public void clearOutputs ( ) { } public Out addOutput ( Out to ) { } public Out addOutput ( long value , String address ) { } public Out addOutput ( long value , ECKey pubkey ) { } public Out addOutput ( long value , Script script ) { } public synchronized void signInputs ( TransactionSignature . SigHash hashType , Address address ) throws ScriptException { } public synchronized void signInputs ( TransactionSignature . SigHash hashType , Address address , CharSequence password ) throws ScriptException { } public synchronized TransactionSignature calculateSignature ( int inputIndex , ECKey key , @ Nullable KeyParameter aesKey , byte [ ] connectedPubKeyScript , TransactionSignature . SigHash hashType , boolean anyoneCanPay ) { } public synchronized TransactionSignature calculateSignature ( int inputIndex , ECKey key , Script connectedPubKeyScript , TransactionSignature . SigHash hashType , boolean anyoneCanPay ) { } public synchronized byte [ ] hashForSignature ( int inputIndex , byte [ ] connectedScript , TransactionSignature . SigHash type , boolean anyoneCanPay ) { } public synchronized byte [ ] hashForSignature ( int inputIndex , Script connectedScript , TransactionSignature . SigHash type , boolean anyoneCanPay ) { } public synchronized byte [ ] hashForSignature ( int inputIndex , byte [ ] connectedScript , byte sigHashType ) { } @ Override protected void bitcoinSerializeToStream ( OutputStream stream ) throws IOException { } @ Override public int hashCode ( ) { } private void writeObject ( ObjectOutputStream out ) throws IOException { } public int getSigOpCount ( ) throws ScriptException { }

Fix:
amount += out . getOutValue ( ) ;