Program: 47035
Project: 47035
Buggy source:
/** 
 * Generate and append image and thumbnail   {@code res} and{@code upnp:albumArtURI} entries for the image.
 * @param sb The {@link StringBuilder} to append the elements to.
 * @param renderer the {@link Renderer} used for filtering or {@code null}for no filtering.
 */
@SuppressFBWarnings("String_Node_Str") private void appendImage(StringBuilder sb,Renderer renderer){
  ImageInfo imageInfo=media.getImageInfo();
  ImageInfo thumbnailImageInfo=this.thumbnailImageInfo != null ? this.thumbnailImageInfo : getMedia() != null && getMedia().getThumb() != null ? getMedia().getThumb().getImageInfo() : null;
  boolean includeGIF=imageInfo != null && imageInfo.getFormat() == ImageFormat.GIF && DLNAImageResElement.isImageProfileSupported(DLNAImageProfile.GIF_LRG,renderer);
  List<DLNAImageResElement> resElements=new ArrayList<>();
  resElements.add(new DLNAImageResElement(DLNAImageProfile.JPEG_TN,thumbnailImageInfo != null ? thumbnailImageInfo : imageInfo,true));
  if (DLNAImageResElement.isImageProfileSupported(DLNAImageProfile.PNG_TN,renderer)) {
    resElements.add(new DLNAImageResElement(DLNAImageProfile.PNG_TN,thumbnailImageInfo != null ? thumbnailImageInfo : imageInfo,true));
  }
  if (imageInfo != null) {
    if (DLNAImageResElement.isImageProfileSupported(DLNAImageProfile.JPEG_RES_H_V,renderer) && imageInfo.getWidth() > 0 && imageInfo.getHeight() > 0) {
      DLNAImageProfile exactResolution=DLNAImageProfile.createJPEG_RES_H_V(imageInfo.getWidth(),imageInfo.getHeight());
      resElements.add(new DLNAImageResElement(exactResolution,imageInfo,exactResolution.useThumbnailSource(imageInfo,thumbnailImageInfo)));
    }
    resElements.add(new DLNAImageResElement(DLNAImageProfile.JPEG_SM,imageInfo,DLNAImageProfile.JPEG_SM.useThumbnailSource(imageInfo,thumbnailImageInfo)));
    if (!DLNAImageProfile.PNG_TN.isResolutionCorrect(imageInfo)) {
      if (DLNAImageResElement.isImageProfileSupported(DLNAImageProfile.PNG_LRG,renderer)) {
        resElements.add(new DLNAImageResElement(DLNAImageProfile.PNG_LRG,imageInfo,DLNAImageProfile.PNG_LRG.useThumbnailSource(imageInfo,thumbnailImageInfo)));
      }
      if (includeGIF) {
        resElements.add(new DLNAImageResElement(DLNAImageProfile.GIF_LRG,imageInfo,DLNAImageProfile.GIF_LRG.useThumbnailSource(imageInfo,thumbnailImageInfo)));
      }
      if (!DLNAImageProfile.JPEG_SM.isResolutionCorrect(imageInfo)) {
        if (DLNAImageResElement.isImageProfileSupported(DLNAImageProfile.JPEG_MED,renderer)) {
          resElements.add(new DLNAImageResElement(DLNAImageProfile.JPEG_MED,imageInfo,DLNAImageProfile.JPEG_MED.useThumbnailSource(imageInfo,thumbnailImageInfo)));
        }
        if (!DLNAImageProfile.JPEG_MED.isResolutionCorrect(imageInfo)) {
          if (DLNAImageResElement.isImageProfileSupported(DLNAImageProfile.PNG_LRG,renderer)) {
            resElements.add(new DLNAImageResElement(DLNAImageProfile.JPEG_LRG,imageInfo,DLNAImageProfile.JPEG_LRG.useThumbnailSource(imageInfo,thumbnailImageInfo)));
          }
        }
      }
    }
  }
 else {
    resElements.add(new DLNAImageResElement(DLNAImageProfile.JPEG_SM,null,false));
    if (DLNAImageResElement.isImageProfileSupported(DLNAImageProfile.JPEG_LRG,renderer)) {
      resElements.add(new DLNAImageResElement(DLNAImageProfile.JPEG_LRG,null,false));
    }
    if (DLNAImageResElement.isImageProfileSupported(DLNAImageProfile.PNG_LRG,renderer)) {
      resElements.add(new DLNAImageResElement(DLNAImageProfile.PNG_LRG,null,false));
    }
    LOGGER.debug("String_Node_Str",this.getName());
  }
  Collections.sort(resElements,DLNAImageResElement.getComparator(imageInfo != null ? imageInfo.getFormat() : ImageFormat.JPEG));
  for (  DLNAImageResElement resElement : resElements) {
    addImageResource(sb,resElement);
  }
  for (  DLNAImageResElement resElement : resElements) {
switch (resElement.getProfile().toInt()) {
case DLNAImageProfile.GIF_LRG_INT:
case DLNAImageProfile.JPEG_SM_INT:
case DLNAImageProfile.JPEG_TN_INT:
case DLNAImageProfile.PNG_LRG_INT:
case DLNAImageProfile.PNG_TN_INT:
      addAlbumArt(sb,resElement.getProfile());
  }
}
}

Fixed version (ground truth):
/** 
 * Generate and append image and thumbnail   {@code res} and{@code upnp:albumArtURI} entries for the image.
 * @param sb The {@link StringBuilder} to append the elements to.
 * @param renderer the {@link Renderer} used for filtering or {@code null}for no filtering.
 */
@SuppressFBWarnings("String_Node_Str") private void appendImage(StringBuilder sb,Renderer renderer){
  ImageInfo imageInfo=media.getImageInfo();
  ImageInfo thumbnailImageInfo=this.thumbnailImageInfo != null ? this.thumbnailImageInfo : getMedia() != null && getMedia().getThumb() != null ? getMedia().getThumb().getImageInfo() : null;
  boolean includeGIF=imageInfo != null && imageInfo.getFormat() == ImageFormat.GIF && DLNAImageResElement.isImageProfileSupported(DLNAImageProfile.GIF_LRG,renderer);
  List<DLNAImageResElement> resElements=new ArrayList<>();
  resElements.add(new DLNAImageResElement(DLNAImageProfile.JPEG_TN,thumbnailImageInfo != null ? thumbnailImageInfo : imageInfo,true));
  if (DLNAImageResElement.isImageProfileSupported(DLNAImageProfile.PNG_TN,renderer)) {
    resElements.add(new DLNAImageResElement(DLNAImageProfile.PNG_TN,thumbnailImageInfo != null ? thumbnailImageInfo : imageInfo,true));
  }
  if (imageInfo != null) {
    if (DLNAImageResElement.isImageProfileSupported(DLNAImageProfile.JPEG_RES_H_V,renderer) && imageInfo.getWidth() > 0 && imageInfo.getHeight() > 0) {
      DLNAImageProfile exactResolution=DLNAImageProfile.createJPEG_RES_H_V(imageInfo.getWidth(),imageInfo.getHeight());
      resElements.add(new DLNAImageResElement(exactResolution,imageInfo,exactResolution.useThumbnailSource(imageInfo,thumbnailImageInfo)));
    }
    resElements.add(new DLNAImageResElement(DLNAImageProfile.JPEG_SM,imageInfo,DLNAImageProfile.JPEG_SM.useThumbnailSource(imageInfo,thumbnailImageInfo)));
    if (!DLNAImageProfile.PNG_TN.isResolutionCorrect(imageInfo)) {
      if (DLNAImageResElement.isImageProfileSupported(DLNAImageProfile.PNG_LRG,renderer)) {
        resElements.add(new DLNAImageResElement(DLNAImageProfile.PNG_LRG,imageInfo,DLNAImageProfile.PNG_LRG.useThumbnailSource(imageInfo,thumbnailImageInfo)));
      }
      if (includeGIF) {
        resElements.add(new DLNAImageResElement(DLNAImageProfile.GIF_LRG,imageInfo,DLNAImageProfile.GIF_LRG.useThumbnailSource(imageInfo,thumbnailImageInfo)));
      }
      if (!DLNAImageProfile.JPEG_SM.isResolutionCorrect(imageInfo)) {
        if (DLNAImageResElement.isImageProfileSupported(DLNAImageProfile.JPEG_MED,renderer)) {
          resElements.add(new DLNAImageResElement(DLNAImageProfile.JPEG_MED,imageInfo,DLNAImageProfile.JPEG_MED.useThumbnailSource(imageInfo,thumbnailImageInfo)));
        }
        if (!DLNAImageProfile.JPEG_MED.isResolutionCorrect(imageInfo)) {
          if (DLNAImageResElement.isImageProfileSupported(DLNAImageProfile.JPEG_LRG,renderer)) {
            resElements.add(new DLNAImageResElement(DLNAImageProfile.JPEG_LRG,imageInfo,DLNAImageProfile.JPEG_LRG.useThumbnailSource(imageInfo,thumbnailImageInfo)));
          }
        }
      }
    }
  }
 else {
    resElements.add(new DLNAImageResElement(DLNAImageProfile.JPEG_SM,null,false));
    if (DLNAImageResElement.isImageProfileSupported(DLNAImageProfile.JPEG_LRG,renderer)) {
      resElements.add(new DLNAImageResElement(DLNAImageProfile.JPEG_LRG,null,false));
    }
    if (DLNAImageResElement.isImageProfileSupported(DLNAImageProfile.PNG_LRG,renderer)) {
      resElements.add(new DLNAImageResElement(DLNAImageProfile.PNG_LRG,null,false));
    }
    LOGGER.debug("String_Node_Str",this.getName());
  }
  Collections.sort(resElements,DLNAImageResElement.getComparator(imageInfo != null ? imageInfo.getFormat() : ImageFormat.JPEG));
  for (  DLNAImageResElement resElement : resElements) {
    addImageResource(sb,resElement);
  }
  for (  DLNAImageResElement resElement : resElements) {
switch (resElement.getProfile().toInt()) {
case DLNAImageProfile.GIF_LRG_INT:
case DLNAImageProfile.JPEG_SM_INT:
case DLNAImageProfile.JPEG_TN_INT:
case DLNAImageProfile.PNG_LRG_INT:
case DLNAImageProfile.PNG_TN_INT:
      addAlbumArt(sb,resElement.getProfile());
  }
}
}