Program: 52891
Project: 52891
Buggy source:
/** 
 * @param outputFolder
 * @param level        //TODO: reduce memory usageConverts raw GADM shapefile into WikiBrain readable type Recommended JVM max heapsize = 4G
 */
public void convertShpFile(File rawFile,SpatialDataFolder outputFolder,int level) throws IOException, WikiBrainException {
  if ((level != 0) && (level != 1))   throw new IllegalArgumentException("String_Node_Str");
  File outputFile=new File(outputFolder.getRefSysFolder("String_Node_Str").getCanonicalPath() + "String_Node_Str" + "String_Node_Str"+ level+ "String_Node_Str");
  ListMultimap<String,String> countryStatePair=ArrayListMultimap.create();
  final SimpleFeatureType WIKITYPE=getOutputFeatureType(level);
  final SimpleFeatureSource outputFeatureSource=getOutputDataFeatureSource(outputFile,WIKITYPE);
  final Transaction transaction=new DefaultTransaction("String_Node_Str");
  final SimpleFeatureCollection inputCollection=getInputCollection(rawFile);
  SimpleFeatureIterator inputFeatures=inputCollection.features();
  final ConcurrentLinkedDeque<List<SimpleFeature>> writeQueue=new ConcurrentLinkedDeque<List<SimpleFeature>>();
  try {
    while (inputFeatures.hasNext()) {
      SimpleFeature feature=inputFeatures.next();
      String country=((String)feature.getAttribute(4)).intern();
      String state=((String)feature.getAttribute(6)).intern();
      if (!countryStatePair.containsEntry(country,state))       countryStatePair.put(country,state);
    }
    final Multimap<String,String> countryState=countryStatePair;
    inputFeatures.close();
    LOG.log(Level.INFO,"String_Node_Str" + level + "String_Node_Str");
    if (level == 1) {
      for (      String country : countryState.keySet()) {
        countInc();
        ParallelForEach.loop(countryState.get(country),new Procedure<String>(){
          @Override public void call(          String state) throws Exception {
            List<SimpleFeature> features=inputFeatureHandler(inputCollection,state,1,WIKITYPE,countryState);
            writeQueue.push(features);
            writeToShpFile(outputFeatureSource,WIKITYPE,transaction,writeQueue.pop());
          }
        }
);
      }
    }
 else {
      ParallelForEach.loop(countryState.keySet(),new Procedure<String>(){
        @Override public void call(        String country) throws Exception {
          countInc();
          List<SimpleFeature> features=inputFeatureHandler(inputCollection,country,0,WIKITYPE,countryState);
          writeQueue.push(features);
          writeToShpFile(outputFeatureSource,WIKITYPE,transaction,writeQueue.pop());
          ;
        }
      }
);
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
 finally {
    transaction.close();
    outputFolder.deleteSpecificFile("String_Node_Str",RefSys.EARTH);
    outputFolder.deleteLayer("String_Node_Str",RefSys.EARTH);
  }
}

Fixed version (ground truth):
/** 
 * @param outputFolder
 * @param level        //TODO: reduce memory usageConverts raw GADM shapefile into WikiBrain readable type Recommended JVM max heapsize = 4G
 */
public void convertShpFile(File rawFile,SpatialDataFolder outputFolder,int level) throws IOException, WikiBrainException {
  if ((level != 0) && (level != 1))   throw new IllegalArgumentException("String_Node_Str");
  File outputFile=new File(outputFolder.getRefSysFolder("String_Node_Str").getCanonicalPath() + "String_Node_Str" + "String_Node_Str"+ level+ "String_Node_Str");
  ListMultimap<String,String> countryStatePair=ArrayListMultimap.create();
  final SimpleFeatureType WIKITYPE=getOutputFeatureType(level);
  final SimpleFeatureSource outputFeatureSource=getOutputDataFeatureSource(outputFile,WIKITYPE);
  final Transaction transaction=new DefaultTransaction("String_Node_Str");
  final SimpleFeatureCollection inputCollection=getInputCollection(rawFile);
  SimpleFeatureIterator inputFeatures=inputCollection.features();
  final ConcurrentLinkedQueue<List<SimpleFeature>> writeQueue=new ConcurrentLinkedQueue<List<SimpleFeature>>();
  try {
    while (inputFeatures.hasNext()) {
      SimpleFeature feature=inputFeatures.next();
      String country=((String)feature.getAttribute(4)).intern();
      String state=((String)feature.getAttribute(6)).intern();
      if (!countryStatePair.containsEntry(country,state))       countryStatePair.put(country,state);
    }
    final Multimap<String,String> countryState=countryStatePair;
    inputFeatures.close();
    LOG.log(Level.INFO,"String_Node_Str" + level + "String_Node_Str");
    if (level == 1) {
      for (      String country : countryState.keySet()) {
        countInc();
        ParallelForEach.loop(countryState.get(country),new Procedure<String>(){
          @Override public void call(          String state) throws Exception {
            List<SimpleFeature> features=inputFeatureHandler(inputCollection,state,1,WIKITYPE,countryState);
            writeQueue.add(features);
            writeToShpFile(outputFeatureSource,WIKITYPE,transaction,writeQueue.poll());
          }
        }
);
      }
    }
 else {
      ParallelForEach.loop(countryState.keySet(),new Procedure<String>(){
        @Override public void call(        String country) throws Exception {
          countInc();
          List<SimpleFeature> features=inputFeatureHandler(inputCollection,country,0,WIKITYPE,countryState);
          writeQueue.add(features);
          writeToShpFile(outputFeatureSource,WIKITYPE,transaction,writeQueue.poll());
          ;
        }
      }
);
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
 finally {
    transaction.close();
    outputFolder.deleteSpecificFile("String_Node_Str",RefSys.EARTH);
    outputFolder.deleteLayer("String_Node_Str",RefSys.EARTH);
  }
}