Program: 183899
Project: 183899
Buggy source:
public String execute(Map params,String body,RenderContext renderContext) throws MacroException {
  String user=(String)params.get(USER_PARAM);
  if (user == null) {
    throw new MacroException("String_Node_Str");
  }
  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) {
  }
  boolean reverse=false;
  try {
    reverse=Boolean.parseBoolean((String)params.get(REVERSE_PARAM));
  }
 catch (  NumberFormatException e) {
  }
  HttpServletRequest request=ServletActionContext.getRequest();
  String playlistId=null;
  String videoId=null;
  int page=0;
  int pageId=0;
  boolean flushCache=false;
  if (request != null) {
    playlistId=request.getParameter("String_Node_Str");
    videoId=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();
  }
  PlaylistsFeed playlistsFeed;
  try {
    playlistsFeed=YoutubeHelper.getPlaylistsFeed(user,cache);
  }
 catch (  IOException e) {
    throw new MacroException("String_Node_Str");
  }
  VideoFeed videoFeed=null;
  PlaylistEntry playlistEntry=null;
  if ((playlistId != null) && (playlistsFeed.playlists != null)) {
    for (    PlaylistEntry entry : playlistsFeed.playlists) {
      if (entry.id.equals(playlistId)) {
        playlistEntry=entry;
        break;
      }
    }
    if (playlistEntry != null) {
      try {
        videoFeed=YoutubeHelper.getPlaylistFeed(playlistEntry.id,cache);
        PlaylistSummary summary=new PlaylistSummary(playlistEntry.summary);
        summary.patchVideos(videoFeed.videos);
      }
 catch (      IOException e) {
        throw new MacroException("String_Node_Str");
      }
    }
  }
  VideoEntry videoEntry=null;
  List<VideoEntry> thumbnails=null;
  int videoIndex=0;
  if (videoId != null && (videoFeed != null) && (videoFeed.videos != null)) {
    for (int i=0, n=videoFeed.videos.size(); i != n; ++i) {
      VideoEntry video=videoFeed.videos.get(i);
      if (videoId.equals(video.group.id)) {
        int begin=(int)Math.max(0,i - Math.floor(thumbnailCount / 2.0f));
        int end=(int)Math.min(videoFeed.videos.size(),i + Math.ceil(thumbnailCount / 2.0f));
        videoEntry=video;
        videoIndex=i;
        thumbnails=videoFeed.videos.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 (videoEntry != null) {
    context.put("String_Node_Str",videoIndex + 1);
    context.put("String_Node_Str",videoFeed.videos.size());
    if (videoIndex > 0) {
      context.put("String_Node_Str",videoFeed.videos.get(videoIndex - 1).group.id);
    }
    if (videoIndex < videoFeed.videos.size() - 1) {
      context.put("String_Node_Str",videoFeed.videos.get(videoIndex + 1).group.id);
    }
    context.put("String_Node_Str",PlaylistHelper.buildVideoEntry(videoEntry));
    context.put("String_Node_Str",PlaylistHelper.buildPlaylist(playlistEntry));
    if (thumbnails != null) {
      context.put("String_Node_Str",PlaylistHelper.buildVideoList(thumbnails));
    }
    builder.append(VelocityUtils.getRenderedTemplate("String_Node_Str",context));
  }
 else   if ((videoFeed != null) && (videoFeed.videos != null)) {
    int begin=0;
    int end=videoFeed.videos.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",PlaylistHelper.buildVideoList(videoFeed.videos.subList(begin,end)));
    context.put("String_Node_Str",PlaylistHelper.buildPlaylist(playlistEntry));
    builder.append(VelocityUtils.getRenderedTemplate("String_Node_Str",context));
  }
 else   if (playlistsFeed.playlists != null) {
    ArrayList<PlaylistEntry> playlists=new ArrayList<PlaylistEntry>(playlistsFeed.playlists);
    int begin=0;
    int end=playlists.size();
    if (!reverse) {
      Collections.reverse(playlists);
    }
    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",PlaylistHelper.buildPlaylists(playlists.subList(begin,end)));
    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 user=(String)params.get(USER_PARAM);
  if (user == null) {
    throw new MacroException("String_Node_Str");
  }
  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) {
  }
  boolean reverse=false;
  try {
    reverse=Boolean.parseBoolean((String)params.get(REVERSE_PARAM));
  }
 catch (  NumberFormatException e) {
  }
  HttpServletRequest request=ServletActionContext.getRequest();
  String playlistId=null;
  String videoId=null;
  int pageIndex=0;
  int pageId=0;
  boolean flushCache=false;
  if (request != null) {
    playlistId=request.getParameter("String_Node_Str");
    videoId=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();
  }
  PlaylistsFeed playlistsFeed;
  try {
    playlistsFeed=YoutubeHelper.getPlaylistsFeed(user,cache);
  }
 catch (  IOException e) {
    throw new MacroException("String_Node_Str");
  }
  VideoFeed videoFeed=null;
  PlaylistEntry playlistEntry=null;
  if ((playlistId != null) && (playlistsFeed.playlists != null)) {
    for (    PlaylistEntry entry : playlistsFeed.playlists) {
      if (entry.id.equals(playlistId)) {
        playlistEntry=entry;
        break;
      }
    }
    if (playlistEntry != null) {
      try {
        videoFeed=YoutubeHelper.getPlaylistFeed(playlistEntry.id,cache);
        PlaylistSummary summary=new PlaylistSummary(playlistEntry.summary);
        summary.patchVideos(videoFeed.videos);
      }
 catch (      IOException e) {
        throw new MacroException("String_Node_Str");
      }
    }
  }
  VideoEntry videoEntry=null;
  List<VideoEntry> thumbnails=null;
  int videoIndex=0;
  if (videoId != null && (videoFeed != null) && (videoFeed.videos != null)) {
    for (int i=0, n=videoFeed.videos.size(); i != n; ++i) {
      VideoEntry video=videoFeed.videos.get(i);
      if (videoId.equals(video.group.id)) {
        int begin=(int)Math.max(0,i - Math.floor(thumbnailCount / 2.0f));
        int end=(int)Math.min(videoFeed.videos.size(),i + Math.ceil(thumbnailCount / 2.0f));
        videoEntry=video;
        videoIndex=i;
        thumbnails=videoFeed.videos.subList(begin,end);
        break;
      }
    }
  }
  StringBuilder builder=new StringBuilder();
  Map context=MacroUtils.defaultVelocityContext();
  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 (pageId > 0) {
    context.put("String_Node_Str","String_Node_Str" + pageId + "String_Node_Str");
  }
 else {
    context.put("String_Node_Str","String_Node_Str");
  }
  if (videoEntry != null) {
    context.put("String_Node_Str",videoIndex + 1);
    context.put("String_Node_Str",videoFeed.videos.size());
    if (videoIndex > 0) {
      context.put("String_Node_Str",videoFeed.videos.get(videoIndex - 1).group.id);
    }
    if (videoIndex < videoFeed.videos.size() - 1) {
      context.put("String_Node_Str",videoFeed.videos.get(videoIndex + 1).group.id);
    }
    context.put("String_Node_Str",PlaylistHelper.buildVideoEntry(videoEntry));
    context.put("String_Node_Str",PlaylistHelper.buildPlaylist(playlistEntry));
    if (thumbnails != null) {
      context.put("String_Node_Str",PlaylistHelper.buildVideoList(thumbnails));
    }
    builder.append(VelocityUtils.getRenderedTemplate("String_Node_Str",context));
  }
 else   if ((videoFeed != null) && (videoFeed.videos != null)) {
    int begin=0;
    int end=videoFeed.videos.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",PlaylistHelper.buildVideoList(videoFeed.videos.subList(begin,end)));
    context.put("String_Node_Str",PlaylistHelper.buildPlaylist(playlistEntry));
    builder.append(VelocityUtils.getRenderedTemplate("String_Node_Str",context));
  }
 else   if (playlistsFeed.playlists != null) {
    ArrayList<PlaylistEntry> playlists=new ArrayList<PlaylistEntry>(playlistsFeed.playlists);
    int begin=0;
    int end=playlists.size();
    if (!reverse) {
      Collections.reverse(playlists);
    }
    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",PlaylistHelper.buildPlaylists(playlists.subList(begin,end)));
    builder.append(VelocityUtils.getRenderedTemplate("String_Node_Str",context));
  }
  return builder.toString();
}