Program: 67488
Project: 67488
Buggy source:
/** 
 * Generates a Map of EclipseLink schema model Schema objects for a given list of XMLDescriptors. The descriptors are assumed to have been initialized.  One Schema  object will be generated  per namespace.
 * @param descriptorsToProcess list of XMLDescriptors which will be used to generate Schema objects
 * @param properties holds a namespace to Properties map containing schema settings, such as elementFormDefault 
 * @return a map of namespaces to EclipseLink schema model Schema objects
 * @throws DescriptorException if the reference descriptor for a composite mapping is not in the list of descriptors
 * @see Schema
 */
public Map<String,Schema> generateSchemas(List<XMLDescriptor> descriptorsToProcess,SchemaModelGeneratorProperties properties) throws DescriptorException {
  HashMap<String,Schema> schemaForNamespace=new HashMap<String,Schema>();
  Schema workingSchema=null;
  if (properties == null) {
    properties=new SchemaModelGeneratorProperties();
  }
  for (  XMLDescriptor desc : descriptorsToProcess) {
    String namespace;
    XMLSchemaReference schemaRef=desc.getSchemaReference();
    if (schemaRef != null) {
      namespace=schemaRef.getSchemaContextAsQName(desc.getNamespaceResolver()).getNamespaceURI();
      workingSchema=getSchema(namespace,desc.getNamespaceResolver(),schemaForNamespace,properties);
      addNamespacesToWorkingSchema(desc.getNamespaceResolver(),workingSchema);
    }
 else {
      for (      DatabaseTable table : desc.getTables()) {
        namespace=getDefaultRootElementAsQName(desc,table.getName()).getNamespaceURI();
        workingSchema=getSchema(namespace,desc.getNamespaceResolver(),schemaForNamespace,properties);
        addNamespacesToWorkingSchema(desc.getNamespaceResolver(),workingSchema);
      }
    }
  }
  for (  XMLDescriptor xdesc : descriptorsToProcess) {
    processDescriptor(xdesc,schemaForNamespace,workingSchema,properties,descriptorsToProcess);
  }
  return schemaForNamespace;
}

Fixed version (ground truth):
/** 
 * Generates a Map of EclipseLink schema model Schema objects for a given list of XMLDescriptors. The descriptors are assumed to have been initialized.  One Schema  object will be generated  per namespace.
 * @param descriptorsToProcess list of XMLDescriptors which will be used to generate Schema objects
 * @param properties holds a namespace to Properties map containing schema settings, such as elementFormDefault 
 * @return a map of namespaces to EclipseLink schema model Schema objects
 * @throws DescriptorException if the reference descriptor for a composite mapping is not in the list of descriptors
 * @see Schema
 */
public Map<String,Schema> generateSchemas(List<XMLDescriptor> descriptorsToProcess,SchemaModelGeneratorProperties properties,SchemaOutputResolver outputResolver) throws DescriptorException {
  Map<String,Schema> schemas=generateSchemas(descriptorsToProcess,properties);
  Project proj=new SchemaModelProject();
  XMLContext context=new XMLContext(proj);
  XMLMarshaller marshaller=context.createMarshaller();
  XMLDescriptor schemaDescriptor=(XMLDescriptor)proj.getDescriptor(Schema.class);
  int schemaCount=0;
  for (  String key : schemas.keySet()) {
    Schema schema=schemas.get(key);
    try {
      NamespaceResolver schemaNamespaces=schema.getNamespaceResolver();
      schemaNamespaces.put(XMLConstants.SCHEMA_PREFIX,"String_Node_Str");
      schemaDescriptor.setNamespaceResolver(schemaNamespaces);
      javax.xml.transform.Result target=outputResolver.createOutput(schema.getTargetNamespace(),schema.getName());
      marshaller.marshal(schema,target);
      schemaCount++;
    }
 catch (    IOException ex) {
      ex.printStackTrace();
    }
  }
  return schemas;
}