Program: 177180
Project: 177180
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,String> subcontextMap=(Map<String,String>)resource.getMetaData().get("String_Node_Str");
        if (subcontextMap != null) {
          type.setSubcontext(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());
  }
  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();
}