Program: 183898
Project: 183898
Buggy source:
public String execute(Map params,String body,RenderContext renderContext) throws MacroException {
  String picasaUser=(String)params.get(PICASAUSER_PARAM);
  int maxEntries=-1;
  try {
    maxEntries=Integer.parseInt((String)params.get(MAXENTRIES_PARAM));
  }
 catch (  NumberFormatException e) {
  }
  int thumbnailCount=5;
  try {
    thumbnailCount=Integer.parseInt((String)params.get(THUMBNAILS_PARAM));
  }
 catch (  NumberFormatException e) {
  }
  int imageSize=640;
  try {
    imageSize=Integer.parseInt((String)params.get(IMAGESIZE_PARAM));
  }
 catch (  NumberFormatException e) {
  }
  if (picasaUser == null) {
    throw new MacroException("String_Node_Str");
  }
  HttpServletRequest request=ServletActionContext.getRequest();
  String albumId=null;
  String photoId=null;
  int page=0;
  int pageId=0;
  boolean flushCache=false;
  if (request != null) {
    albumId=request.getParameter("String_Node_Str");
    photoId=request.getParameter("String_Node_Str");
    try {
      page=Integer.parseInt(request.getParameter("String_Node_Str")) - 1;
    }
 catch (    NumberFormatException e) {
    }
    try {
      pageId=Integer.parseInt(request.getParameter("String_Node_Str"));
    }
 catch (    NumberFormatException e) {
    }
    try {
      flushCache=Boolean.parseBoolean(request.getParameter("String_Node_Str"));
    }
 catch (    NumberFormatException e) {
    }
  }
  CacheFactory cacheFactory=(CacheFactory)ContainerManager.getComponent("String_Node_Str");
  Cache cache=cacheFactory.getCache("String_Node_Str");
  if (flushCache) {
    cache.removeAll();
  }
  UserFeed userFeed;
  try {
    userFeed=PicasaHelper.getUserFeed(picasaUser,cache);
  }
 catch (  IOException e) {
    throw new MacroException("String_Node_Str");
  }
  AlbumFeed albumFeed=null;
  AlbumEntry albumEntry=null;
  if (albumId != null && (userFeed.albums != null)) {
    for (    AlbumEntry entry : userFeed.albums) {
      if (entry.id.equals(albumId)) {
        albumEntry=entry;
        break;
      }
    }
    if (albumEntry != null) {
      try {
        albumFeed=PicasaHelper.getAlbumFeed(picasaUser,albumEntry.id,cache);
      }
 catch (      IOException e) {
        throw new MacroException("String_Node_Str");
      }
    }
  }
  PhotoEntry photoEntry=null;
  List<PhotoEntry> thumbnails=null;
  int photoIndex=0;
  if (photoId != null && albumFeed != null && albumFeed.photos != null) {
    for (int i=0, n=albumFeed.photos.size(); i != n; ++i) {
      PhotoEntry photo=albumFeed.photos.get(i);
      if (photoId.equals(photo.id)) {
        int begin=(int)Math.max(0,i - Math.floor(thumbnailCount / 2.0f));
        int end=(int)Math.min(albumFeed.photos.size(),i + Math.ceil(thumbnailCount / 2.0f));
        photoEntry=photo;
        photoIndex=i;
        thumbnails=albumFeed.photos.subList(begin,end);
        break;
      }
    }
  }
  StringBuilder builder=new StringBuilder();
  Map context=MacroUtils.defaultVelocityContext();
  if (pageId > 0) {
    context.put("String_Node_Str","String_Node_Str" + pageId + "String_Node_Str");
  }
 else {
    context.put("String_Node_Str","String_Node_Str");
  }
  if (photoEntry != null) {
    context.put("String_Node_Str",photoIndex + 1);
    context.put("String_Node_Str",albumFeed.photos.size());
    if (photoIndex > 0) {
      context.put("String_Node_Str",albumFeed.photos.get(photoIndex - 1).id);
    }
    if (photoIndex < albumFeed.photos.size() - 1) {
      context.put("String_Node_Str",albumFeed.photos.get(photoIndex + 1).id);
    }
    context.put("String_Node_Str",GalleryHelper.buildPhotoEntry(photoEntry,imageSize));
    context.put("String_Node_Str",GalleryHelper.buildAlbumEntry(albumEntry));
    context.put("String_Node_Str",pageId);
    if (thumbnails != null) {
      context.put("String_Node_Str",GalleryHelper.buildPhotoList(thumbnails,0));
    }
    builder.append(VelocityUtils.getRenderedTemplate("String_Node_Str",context));
  }
 else   if (albumFeed != null && albumFeed.photos != null) {
    int begin=0;
    int end=albumFeed.photos.size();
    if (maxEntries > 0) {
      context.put("String_Node_Str",page + 1);
      context.put("String_Node_Str",(end + maxEntries - 1) / maxEntries);
      begin=Math.min(end,page * maxEntries);
      end=Math.min(end,begin + maxEntries);
    }
    context.put("String_Node_Str",GalleryHelper.buildPhotoList(albumFeed.photos.subList(begin,end),1));
    context.put("String_Node_Str",GalleryHelper.buildAlbumEntry(albumEntry));
    context.put("String_Node_Str",pageId);
    builder.append(VelocityUtils.getRenderedTemplate("String_Node_Str",context));
  }
 else   if (userFeed.albums != null) {
    int begin=0;
    int end=userFeed.albums.size();
    if (maxEntries > 0) {
      context.put("String_Node_Str",Integer.toString(page + 1));
      context.put("String_Node_Str",(end + maxEntries - 1) / maxEntries);
      begin=Math.min(end,page * maxEntries);
      end=Math.min(end,begin + maxEntries);
    }
    context.put("String_Node_Str",GalleryHelper.buildAlbumList(userFeed.albums.subList(begin,end)));
    context.put("String_Node_Str",pageId);
    builder.append(VelocityUtils.getRenderedTemplate("String_Node_Str",context));
  }
  return builder.toString();
}

Fixed version (ground truth):
public String execute(Map params,String body,RenderContext renderContext) throws MacroException {
  String picasaUser=(String)params.get(PICASAUSER_PARAM);
  int maxEntries=-1;
  try {
    maxEntries=Integer.parseInt((String)params.get(MAXENTRIES_PARAM));
  }
 catch (  NumberFormatException e) {
  }
  int thumbnailCount=5;
  try {
    thumbnailCount=Integer.parseInt((String)params.get(THUMBNAILS_PARAM));
  }
 catch (  NumberFormatException e) {
  }
  int imageSize=640;
  try {
    imageSize=Integer.parseInt((String)params.get(IMAGESIZE_PARAM));
  }
 catch (  NumberFormatException e) {
  }
  if (picasaUser == null) {
    throw new MacroException("String_Node_Str");
  }
  HttpServletRequest request=ServletActionContext.getRequest();
  String albumId=null;
  String photoId=null;
  int pageIndex=0;
  int pageId=0;
  boolean flushCache=false;
  if (request != null) {
    albumId=request.getParameter("String_Node_Str");
    photoId=request.getParameter("String_Node_Str");
    try {
      pageIndex=Integer.parseInt(request.getParameter("String_Node_Str")) - 1;
    }
 catch (    NumberFormatException e) {
    }
    try {
      pageId=Integer.parseInt(request.getParameter("String_Node_Str"));
    }
 catch (    NumberFormatException e) {
    }
    try {
      flushCache=Boolean.parseBoolean(request.getParameter("String_Node_Str"));
    }
 catch (    NumberFormatException e) {
    }
  }
  CacheFactory cacheFactory=(CacheFactory)ContainerManager.getComponent("String_Node_Str");
  Cache cache=cacheFactory.getCache("String_Node_Str");
  if (flushCache) {
    cache.removeAll();
  }
  UserFeed userFeed;
  try {
    userFeed=PicasaHelper.getUserFeed(picasaUser,cache);
  }
 catch (  IOException e) {
    throw new MacroException("String_Node_Str");
  }
  AlbumFeed albumFeed=null;
  AlbumEntry albumEntry=null;
  if (albumId != null && (userFeed.albums != null)) {
    for (    AlbumEntry entry : userFeed.albums) {
      if (entry.id.equals(albumId)) {
        albumEntry=entry;
        break;
      }
    }
    if (albumEntry != null) {
      try {
        albumFeed=PicasaHelper.getAlbumFeed(picasaUser,albumEntry.id,cache);
      }
 catch (      IOException e) {
        throw new MacroException("String_Node_Str");
      }
    }
  }
  PhotoEntry photoEntry=null;
  List<PhotoEntry> thumbnails=null;
  int photoIndex=0;
  if (photoId != null && albumFeed != null && albumFeed.photos != null) {
    for (int i=0, n=albumFeed.photos.size(); i != n; ++i) {
      PhotoEntry photo=albumFeed.photos.get(i);
      if (photoId.equals(photo.id)) {
        int begin=(int)Math.max(0,i - Math.floor(thumbnailCount / 2.0f));
        int end=(int)Math.min(albumFeed.photos.size(),i + Math.ceil(thumbnailCount / 2.0f));
        photoEntry=photo;
        photoIndex=i;
        thumbnails=albumFeed.photos.subList(begin,end);
        break;
      }
    }
  }
  StringBuilder builder=new StringBuilder();
  Map context=MacroUtils.defaultVelocityContext();
  if (pageId > 0) {
    context.put("String_Node_Str","String_Node_Str" + pageId + "String_Node_Str");
  }
 else {
    context.put("String_Node_Str","String_Node_Str");
  }
  PageContext pageContext=(PageContext)renderContext;
  Page page=(pageContext.getEntity() != null && pageContext.getEntity() instanceof Page) ? (Page)pageContext.getEntity() : null;
  if (page != null) {
    context.put("String_Node_Str",page.getTitle());
  }
  if (photoEntry != null) {
    context.put("String_Node_Str",photoIndex + 1);
    context.put("String_Node_Str",albumFeed.photos.size());
    if (photoIndex > 0) {
      context.put("String_Node_Str",albumFeed.photos.get(photoIndex - 1).id);
    }
    if (photoIndex < albumFeed.photos.size() - 1) {
      context.put("String_Node_Str",albumFeed.photos.get(photoIndex + 1).id);
    }
    context.put("String_Node_Str",GalleryHelper.buildPhotoEntry(photoEntry,imageSize));
    context.put("String_Node_Str",GalleryHelper.buildAlbumEntry(albumEntry));
    context.put("String_Node_Str",pageId);
    if (thumbnails != null) {
      context.put("String_Node_Str",GalleryHelper.buildPhotoList(thumbnails,0));
    }
    builder.append(VelocityUtils.getRenderedTemplate("String_Node_Str",context));
  }
 else   if (albumFeed != null && albumFeed.photos != null) {
    int begin=0;
    int end=albumFeed.photos.size();
    if (maxEntries > 0) {
      context.put("String_Node_Str",pageIndex + 1);
      context.put("String_Node_Str",(end + maxEntries - 1) / maxEntries);
      begin=Math.min(end,pageIndex * maxEntries);
      end=Math.min(end,begin + maxEntries);
    }
    context.put("String_Node_Str",GalleryHelper.buildPhotoList(albumFeed.photos.subList(begin,end),1));
    context.put("String_Node_Str",GalleryHelper.buildAlbumEntry(albumEntry));
    context.put("String_Node_Str",pageId);
    builder.append(VelocityUtils.getRenderedTemplate("String_Node_Str",context));
  }
 else   if (userFeed.albums != null) {
    int begin=0;
    int end=userFeed.albums.size();
    if (maxEntries > 0) {
      context.put("String_Node_Str",Integer.toString(pageIndex + 1));
      context.put("String_Node_Str",(end + maxEntries - 1) / maxEntries);
      begin=Math.min(end,pageIndex * maxEntries);
      end=Math.min(end,begin + maxEntries);
    }
    context.put("String_Node_Str",GalleryHelper.buildAlbumList(userFeed.albums.subList(begin,end)));
    context.put("String_Node_Str",pageId);
    builder.append(VelocityUtils.getRenderedTemplate("String_Node_Str",context));
  }
  return builder.toString();
}