Program: 165465
Project: 165465
Buggy source:
@Override public Thumb[] scrapePosters(){
  ArrayList<Thumb> posters=new ArrayList<Thumb>();
  ArrayList<Thumb> trailerImages=new ArrayList<Thumb>();
  Elements trailerImgElements=document.select("String_Node_Str");
  Elements videoStills=document.select("String_Node_Str");
  if (trailerImgElements != null && trailerImgElements.size() > 0 && (videoStills == null || videoStills.size() == 0)) {
    try {
      for (      Element currentTrailerElement : trailerImgElements) {
        trailerImages.add(new Thumb(currentTrailerElement.attr("String_Node_Str")));
      }
    }
 catch (    MalformedURLException e) {
      e.printStackTrace();
    }
    if (videoStills != null && videoStills.size() > 0) {
      try {
        for (        Element currentVideoStill : videoStills)         posters.add(new Thumb(currentVideoStill.attr("String_Node_Str")));
      }
 catch (      MalformedURLException e) {
        e.printStackTrace();
      }
    }
  }
  ArrayList<String> contentLinks=new ArrayList<String>();
  String docLocation=document.location();
  String contentIDFromViewerFoundOnPage="String_Node_Str";
  Element viewerElementOnPage=document.select("String_Node_Str").first();
  if (viewerElementOnPage != null) {
    String hrefContent=viewerElementOnPage.attr("String_Node_Str");
    int startingIndex=hrefContent.indexOf("String_Node_Str") + "String_Node_Str".length() + 1;
    int endingIndex=hrefContent.lastIndexOf("String_Node_Str");
    if (startingIndex != -1 && endingIndex != -1) {
      contentIDFromViewerFoundOnPage=hrefContent.substring(startingIndex,endingIndex);
    }
  }
  String contentIDToUse=docLocation.substring(docLocation.lastIndexOf("String_Node_Str") + 1,docLocation.length());
  if (contentIDFromViewerFoundOnPage != null && contentIDFromViewerFoundOnPage.length() > 0) {
    contentIDToUse=contentIDFromViewerFoundOnPage;
  }
  contentLinks.add(contentIDToUse);
  for (  String contentID : contentLinks) {
    for (int viewerPageNumber=1; viewerPageNumber <= 15; viewerPageNumber++) {
      String currentViewerPageURL="String_Node_Str" + contentID + "String_Node_Str"+ String.format("String_Node_Str",viewerPageNumber);
      try {
        Document viewerDocument=Jsoup.connect(currentViewerPageURL).timeout(SiteParsingProfile.CONNECTION_TIMEOUT_VALUE).userAgent("String_Node_Str").get();
        if (viewerDocument != null) {
          Element imgElement=viewerDocument.select("String_Node_Str").first();
          if (imgElement != null) {
            String mainImageUrl=imgElement.attr("String_Node_Str");
            if (fileExistsAtURL(mainImageUrl)) {
              Thumb thumbToAdd=new Thumb(mainImageUrl);
              String previewURL=mainImageUrl.substring(0,mainImageUrl.length() - 6) + "String_Node_Str" + mainImageUrl.substring(mainImageUrl.length() - 6,mainImageUrl.length());
              if (!fileExistsAtURL(previewURL))               previewURL=mainImageUrl.substring(0,mainImageUrl.length() - 6) + "String_Node_Str" + mainImageUrl.substring(mainImageUrl.length() - 6,mainImageUrl.length());
              if (fileExistsAtURL(previewURL))               thumbToAdd.setPreviewURL(new URL(previewURL));
              posters.add(thumbToAdd);
            }
          }
        }
      }
 catch (      IOException e) {
        e.printStackTrace();
      }
    }
  }
  Element officialPosterElement=document.select("String_Node_Str").first();
  if (officialPosterElement != null) {
    try {
      Thumb officialPosterThumb=new Thumb(officialPosterElement.attr("String_Node_Str"));
      posters.add(officialPosterThumb);
      posters.addAll(trailerImages);
    }
 catch (    MalformedURLException e) {
      e.printStackTrace();
    }
  }
  scrapedPosters=posters.toArray(new Thumb[posters.size()]);
  if (scrapedPosters != null && scrapedPosters.length > 0)   return scrapedPosters;
 else {
    scrapedPosters=trailerImages.toArray(new Thumb[trailerImages.size()]);
    return scrapedPosters;
  }
}

Fixed version (ground truth):
@Override public Thumb[] scrapePosters(){
  ArrayList<Thumb> posters=new ArrayList<Thumb>();
  ArrayList<Thumb> trailerImages=new ArrayList<Thumb>();
  Elements trailerImgElements=document.select("String_Node_Str");
  Elements videoStills=document.select("String_Node_Str");
  if (trailerImgElements != null && trailerImgElements.size() > 0 && (videoStills == null || videoStills.size() == 0)) {
    try {
      for (      Element currentTrailerElement : trailerImgElements) {
        trailerImages.add(new Thumb(fixIPAddressOfData18(currentTrailerElement.attr("String_Node_Str"))));
      }
    }
 catch (    MalformedURLException e) {
      e.printStackTrace();
    }
    if (videoStills != null && videoStills.size() > 0) {
      try {
        for (        Element currentVideoStill : videoStills)         posters.add(new Thumb(fixIPAddressOfData18(currentVideoStill.attr("String_Node_Str"))));
      }
 catch (      MalformedURLException e) {
        e.printStackTrace();
      }
    }
  }
  ArrayList<String> contentLinks=new ArrayList<String>();
  String docLocation=document.location();
  String contentIDFromViewerFoundOnPage="String_Node_Str";
  Element viewerElementOnPage=document.select("String_Node_Str").first();
  if (viewerElementOnPage != null) {
    String hrefContent=viewerElementOnPage.attr("String_Node_Str");
    int startingIndex=hrefContent.indexOf("String_Node_Str") + "String_Node_Str".length() + 1;
    int endingIndex=hrefContent.lastIndexOf("String_Node_Str");
    if (startingIndex != -1 && endingIndex != -1) {
      contentIDFromViewerFoundOnPage=hrefContent.substring(startingIndex,endingIndex);
    }
  }
  String contentIDToUse=docLocation.substring(docLocation.lastIndexOf("String_Node_Str") + 1,docLocation.length());
  if (contentIDFromViewerFoundOnPage != null && contentIDFromViewerFoundOnPage.length() > 0) {
    contentIDToUse=contentIDFromViewerFoundOnPage;
  }
  contentLinks.add(contentIDToUse);
  for (  String contentID : contentLinks) {
    for (int viewerPageNumber=1; viewerPageNumber <= 15; viewerPageNumber++) {
      String currentViewerPageURL="String_Node_Str" + contentID + "String_Node_Str"+ String.format("String_Node_Str",viewerPageNumber);
      try {
        Document viewerDocument=Jsoup.connect(currentViewerPageURL).timeout(SiteParsingProfile.CONNECTION_TIMEOUT_VALUE).userAgent("String_Node_Str").get();
        if (viewerDocument != null) {
          Element imgElement=viewerDocument.select("String_Node_Str").first();
          if (imgElement != null) {
            String mainImageUrl=imgElement.attr("String_Node_Str");
            mainImageUrl=fixIPAddressOfData18(mainImageUrl);
            if (fileExistsAtURL(mainImageUrl)) {
              Thumb thumbToAdd=new Thumb(mainImageUrl);
              String previewURL=mainImageUrl.substring(0,mainImageUrl.length() - 6) + "String_Node_Str" + mainImageUrl.substring(mainImageUrl.length() - 6,mainImageUrl.length());
              previewURL=fixIPAddressOfData18(previewURL);
              if (!fileExistsAtURL(previewURL))               previewURL=mainImageUrl.substring(0,mainImageUrl.length() - 6) + "String_Node_Str" + mainImageUrl.substring(mainImageUrl.length() - 6,mainImageUrl.length());
              if (fileExistsAtURL(previewURL))               thumbToAdd.setPreviewURL(new URL(previewURL));
              posters.add(thumbToAdd);
            }
          }
        }
      }
 catch (      IOException e) {
        e.printStackTrace();
      }
    }
  }
  Element officialPosterElement=document.select("String_Node_Str").first();
  if (officialPosterElement != null) {
    try {
      Thumb officialPosterThumb=new Thumb(fixIPAddressOfData18(officialPosterElement.attr("String_Node_Str")));
      posters.add(officialPosterThumb);
      posters.addAll(trailerImages);
    }
 catch (    MalformedURLException e) {
      e.printStackTrace();
    }
  }
  scrapedPosters=posters.toArray(new Thumb[posters.size()]);
  if (scrapedPosters != null && scrapedPosters.length > 0)   return scrapedPosters;
 else {
    scrapedPosters=trailerImages.toArray(new Thumb[trailerImages.size()]);
    return scrapedPosters;
  }
}