Program: 175149
Project: 175149
Buggy source:
/** 
 * @param geoms
 * @param fileOutput
 * @param geomType
 * @param transform
 * @throws IOException
 * @throws SchemaException
 */
public static void exportGeometriesToShapeFile(final List<Geometry> geoms,File fileOutput,String geomType,GeoTransform transform,SimpleFeatureType featureType,List<AttributesGeometry> atts) throws IOException, SchemaException {
  FileDataStoreFactorySpi factory=new ShapefileDataStoreFactory();
  Map map=Collections.singletonMap("String_Node_Str",fileOutput.toURI().toURL());
  DataStore data=factory.createNewDataStore(map);
  if (featureType == null)   featureType=DataUtilities.createType("String_Node_Str","String_Node_Str" + geomType + "String_Node_Str");
  data.createSchema(featureType);
  Transaction transaction=new DefaultTransaction();
  FeatureWriter<SimpleFeatureType,SimpleFeature> writer=data.getFeatureWriterAppend(data.getTypeNames()[0],transaction);
  SimpleFeatureBuilder featureBuilder=new SimpleFeatureBuilder(featureType);
  GeometryFactory gb=new GeometryFactory();
  try {
    int fid=0;
    for (    final Geometry g : geoms) {
      Geometry clone=gb.createGeometry(g);
      if (transform != null)       clone=transform.transformGeometryGeoFromPixel(clone);
      featureBuilder.add("String_Node_Str");
      featureBuilder.add(clone);
      SimpleFeature sf=featureBuilder.buildFeature("String_Node_Str" + fid++);
      SimpleFeature sfout=writer.next();
      sfout.setAttributes(sf.getAttributes());
      if (atts != null && !atts.isEmpty()) {
        AttributesGeometry att=atts.get(fid - 1);
        String sch[]=att.getSchema();
        for (int i=0; i < sch.length; i++) {
          Object val=att.get(sch[i]);
          if (val.getClass().isArray()) {
            Object o=ArrayUtils.toString(val);
            sfout.setAttribute(sch[i],o);
          }
 else {
            sfout.setAttribute(sch[i],val);
          }
        }
      }
      sfout.setDefaultGeometry(clone);
      writer.write();
    }
    transaction.commit();
    logger.info("String_Node_Str" + fileOutput.getAbsolutePath());
  }
 catch (  Exception problem) {
    problem.printStackTrace();
    transaction.rollback();
    logger.error("String_Node_Str",problem);
  }
 finally {
    writer.close();
    transaction.close();
    data.dispose();
  }
}

Fixed version (ground truth):
/** 
 * @param geoms
 * @param fileOutput
 * @param geomType
 * @param transform
 * @throws IOException
 * @throws SchemaException
 */
public static void exportGeometriesToShapeFile(final List<Geometry> geoms,File fileOutput,String geomType,GeoTransform transform,SimpleFeatureType featureType) throws IOException, SchemaException {
  FileDataStoreFactorySpi factory=new ShapefileDataStoreFactory();
  Map map=Collections.singletonMap("String_Node_Str",fileOutput.toURI().toURL());
  DataStore data=factory.createNewDataStore(map);
  boolean addAttr=true;
  if (featureType == null) {
    featureType=DataUtilities.createType("String_Node_Str","String_Node_Str" + geomType + "String_Node_Str");
    addAttr=false;
  }
  data.createSchema(featureType);
  Transaction transaction=new DefaultTransaction();
  FeatureWriter<SimpleFeatureType,SimpleFeature> writer=data.getFeatureWriterAppend(data.getTypeNames()[0],transaction);
  SimpleFeatureBuilder featureBuilder=new SimpleFeatureBuilder(featureType);
  GeometryFactory gb=new GeometryFactory();
  try {
    int fid=0;
    for (    final Geometry g : geoms) {
      Geometry clone=gb.createGeometry(g);
      if (transform != null)       clone=transform.transformGeometryGeoFromPixel(clone);
      featureBuilder.add("String_Node_Str");
      featureBuilder.add(clone);
      SimpleFeature sf=featureBuilder.buildFeature("String_Node_Str" + fid++);
      SimpleFeature sfout=writer.next();
      sfout.setAttributes(sf.getAttributes());
      AttributesGeometry att=(AttributesGeometry)g.getUserData();
      try {
        if (att != null && addAttr) {
          String sch[]=att.getSchema();
          for (int i=0; i < sch.length; i++) {
            Object val=att.get(sch[i]);
            if (val.getClass().isArray()) {
              Object o=ArrayUtils.toString(val);
              sfout.setAttribute(sch[i],o);
            }
 else {
              sfout.setAttribute(sch[i],val);
            }
          }
        }
      }
 catch (      Exception e) {
        logger.warn("String_Node_Str" + e.getMessage());
      }
      sfout.setDefaultGeometry(clone);
      writer.write();
    }
    transaction.commit();
    logger.info("String_Node_Str" + fileOutput.getAbsolutePath());
  }
 catch (  Exception problem) {
    problem.printStackTrace();
    transaction.rollback();
    logger.error("String_Node_Str",problem);
  }
 finally {
    writer.close();
    transaction.close();
    data.dispose();
  }
}