Program: 85826
Project: 85826
Buggy source:
private void processInv(InventoryMessage inv) throws IOException {
  List<InventoryItem> items=inv.getItems();
  List<InventoryItem> transactions=new LinkedList<InventoryItem>();
  List<InventoryItem> blocks=new LinkedList<InventoryItem>();
  for (  InventoryItem item : items) {
switch (item.type) {
case Transaction:
      transactions.add(item);
    break;
case Block:
  blocks.add(item);
break;
default :
throw new IllegalStateException("String_Node_Str" + item.type);
}
}
final boolean downloadData=this.vDownloadData;
if (transactions.size() == 0 && blocks.size() == 1) {
if (downloadData) {
if (!blockChain.isOrphan(blocks.get(0).hash)) {
blocksAnnounced.incrementAndGet();
}
}
 else {
blocksAnnounced.incrementAndGet();
}
}
GetDataMessage getdata=new GetDataMessage(params);
Iterator<InventoryItem> it=transactions.iterator();
while (it.hasNext()) {
InventoryItem item=it.next();
if (memoryPool == null) {
if (downloadData) {
getdata.addItem(item);
}
}
 else {
if (memoryPool.maybeWasSeen(item.hash)) {
it.remove();
}
 else {
log.debug("String_Node_Str",vAddress,item.hash);
getdata.addItem(item);
}
memoryPool.seen(item.hash,this.getAddress());
}
}
boolean pingAfterGetData=false;
lock.lock();
try {
if (blocks.size() > 0 && downloadData && blockChain != null) {
for (InventoryItem item : blocks) {
if (blockChain.isOrphan(item.hash) && downloadBlockBodies) {
blockChainDownload(blockChain.getOrphanRoot(item.hash).getHash());
}
 else {
if (!pendingBlockDownloads.contains(item.hash)) {
  if (vPeerVersionMessage.isBloomFilteringSupported() && useFilteredBlocks) {
    getdata.addItem(new InventoryItem(InventoryItem.Type.FilteredBlock,item.hash));
    pingAfterGetData=true;
  }
 else {
    getdata.addItem(item);
  }
  pendingBlockDownloads.add(item.hash);
}
}
}
}
}
  finally {
lock.unlock();
}
if (!getdata.getItems().isEmpty()) {
sendMessage(getdata);
}
if (pingAfterGetData) sendMessage(new Ping((long)Math.random() * Long.MAX_VALUE));
}

Fixed version (ground truth):
private void processInv(InventoryMessage inv) throws IOException {
  List<InventoryItem> items=inv.getItems();
  List<InventoryItem> transactions=new LinkedList<InventoryItem>();
  List<InventoryItem> blocks=new LinkedList<InventoryItem>();
  for (  InventoryItem item : items) {
switch (item.type) {
case Transaction:
      transactions.add(item);
    break;
case Block:
  blocks.add(item);
break;
default :
throw new IllegalStateException("String_Node_Str" + item.type);
}
}
final boolean downloadData=this.vDownloadData;
if (transactions.size() == 0 && blocks.size() == 1) {
if (downloadData) {
if (!blockChain.isOrphan(blocks.get(0).hash)) {
blocksAnnounced.incrementAndGet();
}
}
 else {
blocksAnnounced.incrementAndGet();
}
}
GetDataMessage getdata=new GetDataMessage(params);
Iterator<InventoryItem> it=transactions.iterator();
while (it.hasNext()) {
InventoryItem item=it.next();
if (memoryPool == null) {
if (downloadData) {
getdata.addItem(item);
}
}
 else {
if (memoryPool.maybeWasSeen(item.hash)) {
it.remove();
}
 else {
log.debug("String_Node_Str",vAddress,item.hash);
getdata.addItem(item);
}
memoryPool.seen(item.hash,this.getAddress());
}
}
boolean pingAfterGetData=false;
lock.lock();
try {
if (blocks.size() > 0 && downloadData && blockChain != null) {
for (InventoryItem item : blocks) {
if (blockChain.isOrphan(item.hash) && downloadBlockBodies) {
blockChainDownload(blockChain.getOrphanRoot(item.hash).getHash());
}
 else {
if (!pendingBlockDownloads.contains(item.hash)) {
  if (vPeerVersionMessage.isBloomFilteringSupported() && useFilteredBlocks) {
    getdata.addItem(new InventoryItem(InventoryItem.Type.FilteredBlock,item.hash));
    pingAfterGetData=true;
  }
 else {
    getdata.addItem(item);
  }
  pendingBlockDownloads.add(item.hash);
}
}
}
}
}
  finally {
lock.unlock();
}
if (!getdata.getItems().isEmpty()) {
sendMessage(getdata);
}
if (pingAfterGetData) sendMessage(new Ping((long)(Math.random() * Long.MAX_VALUE)));
}