Program: 82672
Project: 82672
Buggy source:
/** 
 * <p>If publishing in merge mode, guarantee that any merged elements appearing before <code>moduleElement</code> have been written.  This method should be called <i>before</i> we write the start tag of <code>moduleElement</code>. This covers cases where merged elements like "configurations" and "dependencies" appear in the parent descriptor, but are completely missing in the child descriptor.</p> <p>For example, if "moduleElement" is "dependencies", guarantees that "configurations" has been written.  If <code>moduleElement</code> is <code>null</code>, then all missing merged elements will be flushed.</p>
 * @param moduleElement a descriptor element name, for example "configurations" or "info"
 */
private void flushMergedElementsBefore(String moduleElement){
  if (options.isMerge() && context.size() == 1 && "String_Node_Str".equals(context.peek()) && !(mergedConfigurations && mergedDependencies)) {
    int position=moduleElement == null ? moduleElements.size() : moduleElements.indexOf(moduleElement);
    ModuleDescriptor merged=options.getMergedDescriptor();
    if (!mergedConfigurations && position > CONFIGURATIONS_POSITION && merged.getConfigurations().length > 0) {
      mergedConfigurations=true;
      writeInheritedItems(merged,merged.getConfigurations(),ConfigurationPrinter.INSTANCE,"String_Node_Str",true);
    }
    if (!mergedDependencies && position > DEPENDENCIES_POSITION && merged.getDependencies().length > 0) {
      mergedDependencies=true;
      writeInheritedItems(merged,merged.getDependencies(),DependencyPrinter.INSTANCE,"String_Node_Str",true);
    }
  }
}

Fixed version (ground truth):
/** 
 * <p>If publishing in merge mode, guarantee that any merged elements appearing before <code>moduleElement</code> have been written.  This method should be called <i>before</i> we write the start tag of <code>moduleElement</code>. This covers cases where merged elements like "configurations" and "dependencies" appear in the parent descriptor, but are completely missing in the child descriptor.</p> <p>For example, if "moduleElement" is "dependencies", guarantees that "configurations" has been written.  If <code>moduleElement</code> is <code>null</code>, then all missing merged elements will be flushed.</p>
 * @param moduleElement a descriptor element name, for example "configurations" or "info"
 */
private void flushMergedElementsBefore(String moduleElement){
  if (options.isMerge() && context.size() == 1 && "String_Node_Str".equals(context.peek()) && !(mergedConfigurations && mergedDependencies)) {
    int position=moduleElement == null ? MODULE_ELEMENTS.size() : MODULE_ELEMENTS.indexOf(moduleElement);
    ModuleDescriptor merged=options.getMergedDescriptor();
    if (!mergedConfigurations && position > CONFIGURATIONS_POSITION && merged.getConfigurations().length > 0) {
      mergedConfigurations=true;
      writeInheritedItems(merged,merged.getConfigurations(),ConfigurationPrinter.INSTANCE,"String_Node_Str",true);
    }
    if (!mergedDependencies && position > DEPENDENCIES_POSITION && merged.getDependencies().length > 0) {
      mergedDependencies=true;
      writeInheritedItems(merged,merged.getDependencies(),DependencyPrinter.INSTANCE,"String_Node_Str",true);
    }
  }
}