Program: 170407
Project: 170407
Buggy source:
@Override protected RenderedImage createImage(int targetLevel){
  final int masterWidth=masterImage.getImage(targetLevel).getWidth();
  final int masterHeight=masterImage.getImage(targetLevel).getHeight();
  final MultiLevelModel sourceModel=sourceImage.getModel();
  final MultiLevelModel targetModel=getModel();
  final double targetScale=targetModel.getScale(targetLevel);
  final int sourceLevel=sourceModel.getLevel(targetScale);
  final double sourceScale=sourceModel.getScale(sourceLevel);
  final RenderedImage image=sourceImage.getImage(sourceLevel);
  final float scaleRatio=(float)(sourceScale / targetScale);
  if (scaleTranslations == null) {
    scaleTranslations=new float[]{0f,0f};
  }
  RenderedImage renderedImage=image;
  final float xScale=scalings[0] * scaleRatio;
  final float yScale=scalings[1] * scaleRatio;
  if (xScale != 1.0f && yScale != 1.0f) {
    renderedImage=ScaleDescriptor.create(image,xScale,yScale,scaleTranslations[0],scaleTranslations[1],interpolation,renderingHints);
  }
  final float scaledXOffset=(offsets != null) ? (float)(offsets[0] / targetScale) : 0f;
  final float scaledYOffset=(offsets != null) ? (float)(offsets[1] / targetScale) : 0f;
  if (!Double.isNaN(noDataValue)) {
    final int padX=Math.round(Math.abs(scaledXOffset));
    final int padY=Math.round(Math.abs(scaledYOffset));
    final BorderExtender borderExtender=new BorderExtenderConstant(new double[]{noDataValue});
    renderedImage=BorderDescriptor.create(renderedImage,padX,padX,padY,padY,borderExtender,renderingHints);
  }
  if (scaledXOffset != 0.0f || scaledYOffset != 0.0f) {
    renderedImage=TranslateDescriptor.create(renderedImage,scaledXOffset,scaledYOffset,null,renderingHints);
  }
  renderedImage=CropDescriptor.create(renderedImage,0.0f,0.0f,(float)masterWidth,(float)masterHeight,renderingHints);
  return renderedImage;
}

Fixed version (ground truth):
@Override protected RenderedImage createImage(int targetLevel){
  final int masterWidth=masterImage.getImage(targetLevel).getWidth();
  final int masterHeight=masterImage.getImage(targetLevel).getHeight();
  final MultiLevelModel sourceModel=sourceImage.getModel();
  final MultiLevelModel targetModel=getModel();
  final double targetScale=targetModel.getScale(targetLevel);
  final int sourceLevel=sourceModel.getLevel(targetScale);
  final double sourceScale=sourceModel.getScale(sourceLevel);
  final RenderedImage image=sourceImage.getImage(sourceLevel);
  final float scaleRatio=(float)(sourceScale / targetScale);
  if (scaleTranslations == null) {
    scaleTranslations=new float[]{0f,0f};
  }
  RenderedImage renderedImage=image;
  final float xScale=scalings[0] * scaleRatio;
  final float yScale=scalings[1] * scaleRatio;
  if (xScale != 1.0f && yScale != 1.0f) {
    renderedImage=ScaleDescriptor.create(image,xScale,yScale,scaleTranslations[0],scaleTranslations[1],interpolation,renderingHints);
  }
  final float scaledXOffset=(offsets != null) ? (float)(offsets[0] / targetScale) : 0f;
  final float scaledYOffset=(offsets != null) ? (float)(offsets[1] / targetScale) : 0f;
  if (masterWidth != renderedImage.getWidth() || masterHeight != renderedImage.getHeight() || scaledXOffset != 0.0f || scaledYOffset != 0.0f) {
    final int padX=Math.round(scaledXOffset);
    final int padY=Math.round(scaledYOffset);
    int borderCorrectorX=(scaledXOffset - padX < 0) ? 1 : 0;
    int borderCorrectorY=(scaledYOffset - padY < 0) ? 1 : 0;
    final BorderExtender borderExtender=new BorderExtenderConstant(new double[]{noDataValue});
    final int rightPadX=Math.max(0,masterWidth - padX - renderedImage.getWidth() + borderCorrectorX);
    final int lowerPadY=Math.max(0,masterHeight - padY - renderedImage.getHeight() + borderCorrectorY);
    renderedImage=BorderDescriptor.create(renderedImage,padX,rightPadX,padY,lowerPadY,borderExtender,renderingHints);
  }
  if (scaledXOffset != 0.0f || scaledYOffset != 0.0f) {
    renderedImage=TranslateDescriptor.create(renderedImage,scaledXOffset,scaledYOffset,null,renderingHints);
  }
  renderedImage=CropDescriptor.create(renderedImage,0.0f,0.0f,(float)masterWidth,(float)masterHeight,renderingHints);
  return renderedImage;
}