Program: 177166
Project: 177166
Buggy source:
public Object exec(List list) throws TemplateModelException {
  if (list.size() < 1) {
    throw new TemplateModelException("String_Node_Str");
  }
  Object object=BeansWrapper.getDefaultInstance().unwrap((TemplateModel)list.get(0));
  Collection<RESTResource> resourceList;
  if (object instanceof Collection) {
    resourceList=(Collection<RESTResource>)object;
  }
 else   if (object instanceof RESTResource) {
    resourceList=Arrays.asList((RESTResource)object);
  }
 else {
    throw new TemplateModelException("String_Node_Str" + object.getClass().getName());
  }
  TreeMap<String,SupportedContentTypeAtSubcontext> supported=new TreeMap<String,SupportedContentTypeAtSubcontext>();
  for (  RESTResource resource : resourceList) {
    for (    SupportedContentType contentType : resource.getSupportedContentTypes()) {
      SupportedContentTypeAtSubcontext type=supported.get(contentType.getType());
      if (type == null) {
        type=new SupportedContentTypeAtSubcontext();
        type.setType(contentType.getType());
        supported.put(contentType.getType(),type);
      }
      type.setProduceable(type.isProduceable() || contentType.isProduceable());
      type.setConsumable(type.isConsumable() || contentType.isConsumable());
      if (contentType.isProduceable()) {
        Map<String,Set<String>> subcontextMap=(Map<String,Set<String>>)resource.getMetaData().get("String_Node_Str");
        if (subcontextMap != null) {
          type.setSubcontexts(subcontextMap.get(contentType.getType()));
        }
      }
    }
  }
  return supported.values();
}

Fixed version (ground truth):
public Object exec(List list) throws TemplateModelException {
  if (list.size() < 1) {
    throw new TemplateModelException("String_Node_Str");
  }
  Object object=BeansWrapper.getDefaultInstance().unwrap((TemplateModel)list.get(0));
  Collection<RESTResource> resourceList;
  if (object instanceof Collection) {
    resourceList=(Collection<RESTResource>)object;
  }
 else   if (object instanceof RESTResource) {
    resourceList=Arrays.asList((RESTResource)object);
  }
 else {
    throw new TemplateModelException("String_Node_Str" + object.getClass().getName());
  }
  LinkedHashMap<String,SupportedContentTypeAtSubcontext> supported=new LinkedHashMap<String,SupportedContentTypeAtSubcontext>();
  for (  RESTResource resource : resourceList) {
    for (    SupportedContentType contentType : resource.getSupportedContentTypes()) {
      List<String> supportedTypeSet=findAllSupportedTypes(contentType);
      for (      String supportedType : supportedTypeSet) {
        SupportedContentTypeAtSubcontext type=supported.get(supportedType);
        if (type == null) {
          type=new SupportedContentTypeAtSubcontext();
          type.setType(supportedType);
          supported.put(supportedType,type);
        }
        type.setProduceable(type.isProduceable() || contentType.isProduceable());
        type.setConsumable(type.isConsumable() || contentType.isConsumable());
        if (contentType.isProduceable()) {
          Map<String,Set<String>> subcontextMap=(Map<String,Set<String>>)resource.getMetaData().get("String_Node_Str");
          if (subcontextMap != null) {
            type.setSubcontexts(subcontextMap.get(supportedType));
          }
        }
      }
    }
  }
  return supported.values();
}