nus-yam/ex-repair huggingface dataset:
Program: 25500
Project: 25500
Buggy source:
private static TilePairClient.Parameters getTestParameters(final int zNeighborDistance,final String toJson) throws IllegalArgumentException {
  final TilePairClient.Parameters p=new TilePairClient.Parameters();
  final String argString="String_Node_Str" + "String_Node_Str" + "String_Node_Str" + zNeighborDistance + "String_Node_Str"+ toJson;
  p.parse(argString.split("String_Node_Str"));
  return p;
}

Fixed version (ground truth):
private static TilePairClient.Parameters getTestParameters(final int zNeighborDistance,final int maxPairsPerFile,final String toJson) throws IllegalArgumentException {
  final TilePairClient.Parameters p=new TilePairClient.Parameters();
  final String argString="String_Node_Str" + "String_Node_Str" + maxPairsPerFile + "String_Node_Str"+ "String_Node_Str"+ zNeighborDistance+ "String_Node_Str"+ toJson;
  p.parse(argString.split("String_Node_Str"));
  return p;
}
Program: 25501
Project: 25501
Buggy source:
private void testDeriveAndSaveSortedNeighborPairs(final int zNeighborDistance,final int expectedNumberOfFiles) throws Exception {
  final String toJson=baseFileName + "String_Node_Str";
  final MockTilePairClient client=new MockTilePairClient(getTestParameters(zNeighborDistance,toJson));
  client.deriveAndSaveSortedNeighborPairs();
  final List<Path> pairFilePaths=new ArrayList<>();
  Files.list(Paths.get("String_Node_Str")).forEach(path -> {
    if (path.getFileName().toString().startsWith(baseFileName)) {
      pairFilePaths.add(path);
    }
  }
);
  Assert.assertEquals("String_Node_Str",expectedNumberOfFiles,pairFilePaths.size());
}

Fixed version (ground truth):
private void testDeriveAndSaveSortedNeighborPairs(final int zNeighborDistance,final int expectedNumberOfFiles) throws Exception {
  final String toJson=baseFileName + "String_Node_Str";
  final MockTilePairClient client=new MockTilePairClient(getTestParameters(zNeighborDistance,3,toJson),1.0,2.0,3.0,4.0,5.0);
  client.deriveAndSaveSortedNeighborPairs();
  final List<Path> pairFilePaths=new ArrayList<>();
  Files.list(Paths.get("String_Node_Str")).forEach(path -> {
    if (path.getFileName().toString().startsWith(baseFileName)) {
      pairFilePaths.add(path);
    }
  }
);
  Assert.assertEquals("String_Node_Str",expectedNumberOfFiles,pairFilePaths.size());
}
Program: 25502
Project: 25502
Buggy source:
@Override public List<Double> getZValues() throws IOException {
  return Arrays.asList(1.0,2.0,3.0,4.0,5.0);
}

Fixed version (ground truth):
@Override public List<Double> getZValues() throws IOException {
  return zValues;
}
Program: 25503
Project: 25503
Buggy source:
public MockTilePairClient(final TilePairClient.Parameters p) throws IllegalArgumentException {
  super(p);
}

Fixed version (ground truth):
public MockTilePairClient(final TilePairClient.Parameters p,final Double... zValues) throws IllegalArgumentException {
  super(p);
  this.zValues=Arrays.asList(zValues);
}
Program: 25504
Project: 25504
Buggy source:
@Override public Iterator<Integer> call(final Integer partitionIndex,final Iterator<CanvasMatches> matchesIterator) throws Exception {
  LogUtilities.setupExecutorLog4j("String_Node_Str" + partitionIndex);
  String previousCollection=null;
  String currentCollection;
  final List<CanvasMatches> matchesList=new ArrayList<>();
  int savedMatchCount=0;
  CanvasMatches canvasMatches;
  while (matchesIterator.hasNext()) {
    canvasMatches=matchesIterator.next();
    if (canvasMatches.size() > 0) {
      currentCollection=pIdToCollectionMap.get(canvasMatches.getpId());
      if (currentCollection == null) {
        throw new IllegalStateException("String_Node_Str" + canvasMatches.getpId());
      }
 else       if (!currentCollection.equals(previousCollection)) {
        savedMatchCount+=saveMatchesAndClearList(previousCollection,matchesList);
        previousCollection=currentCollection;
      }
      matchesList.add(canvasMatches);
    }
  }
  savedMatchCount+=saveMatchesAndClearList(previousCollection,matchesList);
  return Collections.singletonList(savedMatchCount).iterator();
}

Fixed version (ground truth):
@Override public Iterator<Integer> call(final Integer partitionIndex,final Iterator<CanvasMatches> matchesIterator) throws Exception {
  LogUtilities.setupExecutorLog4j("String_Node_Str" + partitionIndex);
  String previousCollection=null;
  String currentCollection;
  final List<CanvasMatches> matchesList=new ArrayList<>();
  int savedMatchCount=0;
  CanvasMatches canvasMatches;
  while (matchesIterator.hasNext()) {
    canvasMatches=matchesIterator.next();
    if (canvasMatches.size() > 0) {
      currentCollection=pIdToCollectionMap.get(canvasMatches.getOriginalPId());
      if (currentCollection == null) {
        throw new IllegalStateException("String_Node_Str" + canvasMatches.getpId());
      }
 else       if (!currentCollection.equals(previousCollection)) {
        savedMatchCount+=saveMatchesAndClearList(previousCollection,matchesList);
        previousCollection=currentCollection;
      }
      matchesList.add(canvasMatches);
    }
  }
  savedMatchCount+=saveMatchesAndClearList(previousCollection,matchesList);
  return Collections.singletonList(savedMatchCount).iterator();
}
Program: 25506
Project: 25506
Buggy source:
@JsonIgnore public List<OrderedCanvasIdPair> getNeighborPairs(final List<Double> zValues,final int zNeighborDistance){
  final int n=zValues.size();
  final List<OrderedCanvasIdPair> neighborPairs=new ArrayList<>(n * zNeighborDistance);
  Double pz;
  Double qz;
  CanvasId p;
  CanvasId q;
  for (int i=0; i < n; i++) {
    pz=zValues.get(i);
    p=new CanvasId(pz.toString(),getTileIdForZ(pz));
    for (int k=i + 1; k < n && k < i + zNeighborDistance; k++) {
      qz=zValues.get(k);
      q=new CanvasId(qz.toString(),getTileIdForZ(qz));
      neighborPairs.add(new OrderedCanvasIdPair(p,q));
    }
  }
  return neighborPairs;
}

Fixed version (ground truth):
/** 
 * Pairs each specified layer (z value) with the specified number of adjacent layers.
 * @param zValues            ordered list of z values for this stack.
 * @param zNeighborDistance  number of adjacent layers to pair with each layer.
 * @return list of layer pair identifiers.
 */
@JsonIgnore public List<OrderedCanvasIdPair> getNeighborPairs(final List<Double> zValues,final int zNeighborDistance){
  final int n=zValues.size();
  final List<OrderedCanvasIdPair> neighborPairs=new ArrayList<>(n * zNeighborDistance);
  Double pz;
  Double qz;
  CanvasId p;
  CanvasId q;
  for (int i=0; i < n; i++) {
    pz=zValues.get(i);
    p=new CanvasId(pz.toString(),getTileIdForZ(pz));
    for (int k=i + 1; k < n && k <= i + zNeighborDistance; k++) {
      qz=zValues.get(k);
      q=new CanvasId(qz.toString(),getTileIdForZ(qz));
      neighborPairs.add(new OrderedCanvasIdPair(p,q));
    }
  }
  return neighborPairs;
}
Program: 25508
Project: 25508
Buggy source:
private void generateTierMatchesByStack(final MatchRenderParameters matchRenderParameters,final MatchClipParameters emptyClipParameters) throws IOException, URISyntaxException {
  for (  final HierarchicalStack tierStack : tierStacks) {
    if (tierStack.requiresMatchDerivation()) {
      final MatchCollectionId matchCollectionId=tierStack.getMatchCollectionId();
      LOG.info("String_Node_Str",matchCollectionId.getName());
      final MatchStorageFunction matchStorageFunction=new MatchStorageFunction(parameters.renderWeb.baseDataUrl,matchCollectionId.getOwner(),matchCollectionId.getName());
      final long savedMatchPairCount=SIFTPointMatchClient.generateMatchesForPairs(sparkContext,getRenderablePairsForStack(tierStack),parameters.renderWeb.baseDataUrl,matchRenderParameters,parameters.match,emptyClipParameters,matchStorageFunction);
      tierStack.setSavedMatchPairCount(savedMatchPairCount);
      driverTierRender.setHierarchicalData(tierStack.getSplitStackId().getStack(),tierStack);
    }
  }
}

Fixed version (ground truth):
private void generateTierMatchesByStack(final MatchRenderParameters matchRenderParameters,final MatchClipParameters emptyClipParameters) throws IOException, URISyntaxException {
  LOG.info("String_Node_Str");
  for (  final HierarchicalStack tierStack : tierStacks) {
    if (tierStack.requiresMatchDerivation()) {
      final MatchCollectionId matchCollectionId=tierStack.getMatchCollectionId();
      LOG.info("String_Node_Str",matchCollectionId.getName());
      final MatchStorageFunction matchStorageFunction=new MatchStorageFunction(parameters.renderWeb.baseDataUrl,matchCollectionId.getOwner(),matchCollectionId.getName());
      final long savedMatchPairCount=SIFTPointMatchClient.generateMatchesForPairs(sparkContext,getRenderablePairsForStack(tierStack),parameters.renderWeb.baseDataUrl,matchRenderParameters,parameters.match,emptyClipParameters,matchStorageFunction);
      tierStack.setSavedMatchPairCount(savedMatchPairCount);
      persistHierarchicalData(tierStack);
    }
  }
  LOG.info("String_Node_Str");
}
Program: 25512
Project: 25512
Buggy source:
private void updateSavedMatchPairCounts(final Map<String,Long> existingMatchCollectionPairCounts,final boolean persistResults) throws IOException {
  for (  final HierarchicalStack tierStack : tierStacks) {
    final String matchCollectionName=tierStack.getMatchCollectionId().getName();
    if (existingMatchCollectionPairCounts.containsKey(matchCollectionName)) {
      tierStack.setSavedMatchPairCount(existingMatchCollectionPairCounts.get(matchCollectionName));
      if (persistResults) {
        driverTierRender.setHierarchicalData(tierStack.getSplitStackId().getStack(),tierStack);
      }
    }
  }
}

Fixed version (ground truth):
private void updateSavedMatchPairCounts(final Map<String,Long> existingMatchCollectionPairCounts) throws IOException {
  for (  final HierarchicalStack tierStack : tierStacks) {
    final String matchCollectionName=tierStack.getMatchCollectionId().getName();
    tierStack.setSavedMatchPairCount(existingMatchCollectionPairCounts.get(matchCollectionName));
  }
}
Program: 25513
Project: 25513
Buggy source:
@Test public void testWarp() throws Exception {
  final int numberOfConcurrentTasks=1;
  final String[] args={"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  final ProcessTimer processTimer=new ProcessTimer();
  final HierarchicalAlignmentClient.Parameters parameters=new HierarchicalAlignmentClient.Parameters();
  parameters.parse(args);
  LOG.info("String_Node_Str",parameters);
  final String master="String_Node_Str" + numberOfConcurrentTasks + "String_Node_Str";
  final SparkConf sparkConf=new SparkConf().setMaster(master).setAppName(this.getClass().getSimpleName());
  final HierarchicalAlignmentClient client=new HierarchicalAlignmentClient(parameters,sparkConf);
  client.run();
  LOG.info("String_Node_Str",processTimer);
}

Fixed version (ground truth):
/** 
 * This test assumes access to a running render web service instance, so it is commented out. To run the test, uncomment the Test annotation and update the client arguments as needed.
 */
@SuppressWarnings("String_Node_Str") public void testWarp() throws Exception {
  final int numberOfConcurrentTasks=1;
  final String[] args={"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  final ProcessTimer processTimer=new ProcessTimer();
  final HierarchicalAlignmentClient.Parameters parameters=new HierarchicalAlignmentClient.Parameters();
  parameters.parse(args);
  LOG.info("String_Node_Str",parameters);
  final String master="String_Node_Str" + numberOfConcurrentTasks + "String_Node_Str";
  final SparkConf sparkConf=new SparkConf().setMaster(master).setAppName(this.getClass().getSimpleName());
  final HierarchicalAlignmentClient client=new HierarchicalAlignmentClient(parameters,sparkConf);
  client.run();
  LOG.info("String_Node_Str",processTimer);
}
Program: 25514
Project: 25514
Buggy source:
/** 
 * Adjusts these parameters to clip for montage pair point match rendering.
 * @param clipOffsets  full scale x[0] and y[1] offsets for clipped area.
 * @param clipWidth    number of full scale pixels to include in clipped members of left/right pairs.
 * @param clipHeight   number of full scale pixels to include in clipped members of top/bottom pairs.
 */
public void clipForMontagePair(final double[] clipOffsets,final Integer clipWidth,final Integer clipHeight){
  if (clipOffsets != null) {
    if (clipWidth != null) {
      x=x + clipOffsets[0];
      width=clipWidth;
    }
    if (clipHeight != null) {
      y=y + clipOffsets[1];
      height=clipHeight;
    }
  }
}

Fixed version (ground truth):
/** 
 * Adjusts these parameters to clip for montage pair point match rendering.
 * @param canvasId     canvas information.
 * @param clipWidth    number of full scale pixels to include in clipped members of left/right pairs.
 * @param clipHeight   number of full scale pixels to include in clipped members of top/bottom pairs.
 */
public void clipForMontagePair(final CanvasId canvasId,final Integer clipWidth,final Integer clipHeight){
  final MontageRelativePosition relativePosition=canvasId.getRelativePosition();
  if (relativePosition != null) {
    final double[] clipOffsets=canvasId.getClipOffsets();
switch (relativePosition) {
case TOP:
case BOTTOM:
      if (clipHeight != null) {
        y=y + clipOffsets[1];
        height=clipHeight;
      }
    break;
case LEFT:
case RIGHT:
  if (clipWidth != null) {
    x=x + clipOffsets[0];
    width=clipWidth;
  }
break;
}
}
}
Program: 25515
Project: 25515
Buggy source:
public void clipForMontagePair(final Bounds bounds,final Integer clipWidth,final Integer clipHeight){
  canvasId.setClipOffsets(bounds.getDeltaX().intValue(),bounds.getDeltaY().intValue(),clipWidth,clipHeight);
  renderParameters.clipForMontagePair(canvasId.getClipOffsets(),clipWidth,clipHeight);
}

Fixed version (ground truth):
public void clipForMontagePair(final Bounds bounds,final Integer clipWidth,final Integer clipHeight){
  canvasId.setClipOffsets(bounds.getDeltaX().intValue(),bounds.getDeltaY().intValue(),clipWidth,clipHeight);
  renderParameters.clipForMontagePair(canvasId,clipWidth,clipHeight);
}
Program: 25516
Project: 25516
Buggy source:
public RenderParameters getRenderParameters(final CanvasId canvasId) throws IllegalArgumentException {
  final RenderParameters renderParameters=RenderParameters.loadFromUrl(getRenderParametersUrl(canvasId));
  if ((clipWidth != null) || (clipHeight != null)) {
    canvasId.setClipOffsets(renderParameters.getWidth(),renderParameters.getHeight(),clipWidth,clipHeight);
    renderParameters.clipForMontagePair(canvasId.getClipOffsets(),clipWidth,clipHeight);
  }
  return renderParameters;
}

Fixed version (ground truth):
public RenderParameters getRenderParameters(final CanvasId canvasId) throws IllegalArgumentException {
  final RenderParameters renderParameters=RenderParameters.loadFromUrl(getRenderParametersUrl(canvasId));
  if ((clipWidth != null) || (clipHeight != null)) {
    canvasId.setClipOffsets(renderParameters.getWidth(),renderParameters.getHeight(),clipWidth,clipHeight);
    renderParameters.clipForMontagePair(canvasId,clipWidth,clipHeight);
  }
  return renderParameters;
}
Program: 25517
Project: 25517
Buggy source:
public int generateMipmapsForZ(final Double z) throws Exception {
  LOG.info("String_Node_Str",z);
  final ResolvedTileSpecCollection tiles=renderDataClient.getResolvedTiles(stack,z);
  final int tileCount=tiles.getTileCount();
  final int tilesPerGroup=(int)Math.ceil((double)tileCount / parameters.numberOfRenderGroups);
  final int startTile=(parameters.renderGroup - 1) * tilesPerGroup;
  final int stopTile=startTile + tilesPerGroup;
  int count=0;
  int rendered=0;
  for (  final TileSpec tileSpec : tiles.getTileSpecs()) {
    if ((count >= startTile) && (count < stopTile)) {
      generateMissingMipmapFiles(tileSpec);
      rendered++;
    }
    count++;
  }
  LOG.info("String_Node_Str",tileCount,tilesPerGroup,parameters.numberOfRenderGroups,startTile,stopTile);
  LOG.info("String_Node_Str",rendered,z);
  return count;
}

Fixed version (ground truth):
public int generateMipmapsForZ(final Double z) throws Exception {
  LOG.info("String_Node_Str",z);
  final ResolvedTileSpecCollection tiles=renderDataClient.getResolvedTiles(stack,z);
  final int tileCount=tiles.getTileCount();
  final int tilesPerGroup=(int)Math.ceil((double)tileCount / parameters.numberOfRenderGroups);
  final int startTile=(parameters.renderGroup - 1) * tilesPerGroup;
  final int stopTile=startTile + tilesPerGroup;
  final List<TileSpec> tileSpecsToRender=new ArrayList<>(tiles.getTileSpecs()).subList(startTile,stopTile);
  for (  final TileSpec tileSpec : tileSpecsToRender) {
    generateMissingMipmapFiles(tileSpec);
  }
  final int renderedTileCount=tileSpecsToRender.size();
  LOG.info("String_Node_Str",renderedTileCount,z,parameters.renderGroup,startTile,stopTile - 1,tileCount);
  return renderedTileCount;
}
Program: 25519
Project: 25519
Buggy source:
@JsonIgnore public boolean requiresAlignment(){
  return (alignmentQuality == null);
}

Fixed version (ground truth):
@JsonIgnore public boolean requiresAlignment(){
  return hasMatchPairs() && (alignmentQuality == null);
}
Program: 25521
Project: 25521
Buggy source:
@Override public ChannelMap getChannels(final int mipmapLevel) throws IllegalArgumentException {
  final ChannelMap targetChannels=new ChannelMap();
  final double levelScale=(1.0 / Math.pow(2.0,mipmapLevel)) * levelZeroScale;
  final int levelWidth=(int)((fullScaleWidth * levelScale) + 0.5);
  final int levelHeight=(int)((fullScaleHeight * levelScale) + 0.5);
  for (  final String channelName : channelNames) {
    targetChannels.put(channelName,new ImageProcessorWithMasks(new FloatProcessor(levelWidth,levelHeight),null,null));
  }
  long totalScaleDerivationTime=0;
  for (  final TransformableCanvas canvas : canvasList) {
    final long scaleDerivationStart=System.currentTimeMillis();
    final CoordinateTransformList<CoordinateTransform> renderTransformList=addRenderScaleAndOffset(canvas.getTransformList(),levelZeroScale,levelScale,x,y);
    final MipmapSource source=canvas.getSource();
    final double averageScale=Utils.sampleAverageScale(renderTransformList,source.getFullScaleWidth(),source.getFullScaleHeight(),meshCellSize);
    final int componentMipmapLevel=Utils.bestMipmapLevel(averageScale);
    totalScaleDerivationTime+=(System.currentTimeMillis() - scaleDerivationStart);
    mapPixels(source,componentMipmapLevel,renderTransformList,meshCellSize,binaryMask,numberOfMappingThreads,skipInterpolation,targetChannels);
  }
  LOG.debug("String_Node_Str",canvasList.size(),totalScaleDerivationTime);
  return targetChannels;
}

Fixed version (ground truth):
@Override public ChannelMap getChannels(final int mipmapLevel) throws IllegalArgumentException {
  final ChannelMap targetChannels=new ChannelMap();
  final double levelScale=(1.0 / Math.pow(2.0,mipmapLevel)) * levelZeroScale;
  final int levelWidth=(int)((fullScaleWidth * levelScale) + 0.5);
  final int levelHeight=(int)((fullScaleHeight * levelScale) + 0.5);
  for (  final String channelName : channelNames) {
    targetChannels.put(channelName,new ImageProcessorWithMasks(new FloatProcessor(levelWidth,levelHeight),null,null));
  }
  long totalScaleDerivationTime=0;
  for (  final TransformableCanvas canvas : canvasList) {
    final long scaleDerivationStart=System.currentTimeMillis();
    final CoordinateTransformList<CoordinateTransform> renderTransformList=addRenderScaleAndOffset(canvas.getTransformList(),levelZeroScale,levelScale,x,y);
    final MipmapSource source=canvas.getSource();
    final double averageScale=Utils.sampleAverageScale(renderTransformList,source.getFullScaleWidth(),source.getFullScaleHeight(),meshCellSize);
    final int componentMipmapLevel=Utils.bestMipmapLevel(averageScale);
    totalScaleDerivationTime+=(System.currentTimeMillis() - scaleDerivationStart);
    mapPixels(source,componentMipmapLevel,renderTransformList,meshCellSize,hasMasks,binaryMask,numberOfMappingThreads,skipInterpolation,targetChannels);
  }
  LOG.debug("String_Node_Str",canvasList.size(),totalScaleDerivationTime);
  return targetChannels;
}
Program: 25525
Project: 25525
Buggy source:
@Test public void testRender() throws Exception {
  final ImageAndMask imageWithoutMask=new ImageAndMask("String_Node_Str",null);
  final ImageProcessorCache imageProcessorCache=new ImageProcessorCache();
  final ImageProcessor rawIp=imageProcessorCache.get(imageWithoutMask.getImageUrl(),0,false,false);
  final BufferedImage rawImage=rawIp.getBufferedImage();
  final ChannelSpec channelSpec=new ChannelSpec();
  channelSpec.putMipmap(0,imageWithoutMask);
  final TileSpec tileSpec=new TileSpec();
  tileSpec.addChannel(channelSpec);
  final RenderParameters tileRenderParameters=new RenderParameters(null,0,0,rawIp.getWidth(),rawIp.getHeight(),1.0);
  tileRenderParameters.addTileSpec(tileSpec);
  tileRenderParameters.setSkipInterpolation(true);
  final BufferedImage renderedImage=tileRenderParameters.openTargetImage();
  ArgbRenderer.render(tileRenderParameters,renderedImage,imageProcessorCache);
  Assert.assertEquals("String_Node_Str",rawImage.getWidth(),renderedImage.getWidth());
  Assert.assertEquals("String_Node_Str",rawImage.getWidth(),renderedImage.getHeight());
  for (int x=0; x < rawImage.getWidth(); x++) {
    for (int y=0; y < rawImage.getHeight(); y++) {
      Assert.assertEquals("String_Node_Str" + x + "String_Node_Str"+ y+ "String_Node_Str",rawImage.getRGB(x,y),renderedImage.getRGB(x,y));
    }
  }
}

Fixed version (ground truth):
@Test public void testRender() throws Exception {
  final ImageAndMask imageWithoutMask=new ImageAndMask("String_Node_Str",null);
  final ImageProcessorCache imageProcessorCache=new ImageProcessorCache();
  final ImageProcessor rawIp=imageProcessorCache.get(imageWithoutMask.getImageUrl(),0,false,false);
  final BufferedImage rawImage=rawIp.getBufferedImage();
  final ChannelSpec channelSpec=new ChannelSpec();
  channelSpec.putMipmap(0,imageWithoutMask);
  final TileSpec tileSpec=new TileSpec();
  tileSpec.addChannel(channelSpec);
  final RenderParameters tileRenderParameters=new RenderParameters(null,0,0,rawIp.getWidth(),rawIp.getHeight(),1.0);
  tileRenderParameters.addTileSpec(tileSpec);
  tileRenderParameters.setSkipInterpolation(true);
  final BufferedImage renderedImage=tileRenderParameters.openTargetImage();
  ArgbRenderer.render(tileRenderParameters,renderedImage,imageProcessorCache);
  Assert.assertEquals("String_Node_Str",rawImage.getWidth(),renderedImage.getWidth());
  Assert.assertEquals("String_Node_Str",rawImage.getHeight(),renderedImage.getHeight());
  for (int x=0; x < rawImage.getWidth(); x++) {
    for (int y=0; y < rawImage.getHeight(); y++) {
      Assert.assertEquals("String_Node_Str" + x + "String_Node_Str"+ y+ "String_Node_Str",rawImage.getRGB(x,y),renderedImage.getRGB(x,y));
    }
  }
}
Program: 25527
Project: 25527
Buggy source:
public static TileSpec deriveBoundingBox(final TileSpec tileSpec,final double meshCellSize,final boolean force){
  if (!tileSpec.hasWidthAndHeightDefined()) {
    final Map.Entry<Integer,ImageAndMask> mipmapEntry=tileSpec.getFirstMipmapEntry();
    final ImageAndMask imageAndMask=mipmapEntry.getValue();
    final ImageProcessor imageProcessor=ImageProcessorCache.getNonCachedImage(imageAndMask.getImageUrl(),0,false);
    tileSpec.setWidth((double)imageProcessor.getWidth());
    tileSpec.setHeight((double)imageProcessor.getHeight());
  }
  tileSpec.deriveBoundingBox(meshCellSize,force);
  return tileSpec;
}

Fixed version (ground truth):
public static TileSpec deriveBoundingBox(final TileSpec tileSpec,final double meshCellSize,final boolean force){
  if (!tileSpec.hasWidthAndHeightDefined()) {
    final Map.Entry<Integer,ImageAndMask> mipmapEntry=tileSpec.getFirstMipmapEntry();
    final ImageAndMask imageAndMask=mipmapEntry.getValue();
    final ImageProcessor imageProcessor=ImageProcessorCache.getNonCachedImage(imageAndMask.getImageUrl(),0,false,false);
    tileSpec.setWidth((double)imageProcessor.getWidth());
    tileSpec.setHeight((double)imageProcessor.getHeight());
  }
  tileSpec.deriveBoundingBox(meshCellSize,force);
  return tileSpec;
}
Program: 25528
Project: 25528
Buggy source:
@Override public int weigh(@Nullable CacheKey key,@Nullable ImageProcessor value){
  final int weight;
  if (value == null) {
    weight=0;
  }
 else {
    weight=value.getPixelCount() * value.getBitDepth() / 8;
  }
  return weight;
}

Fixed version (ground truth):
@Override public int weigh(@Nullable final CacheKey key,@Nullable final ImageProcessor value){
  final int weight;
  if (value == null) {
    weight=0;
  }
 else {
    weight=value.getPixelCount() * value.getBitDepth() / 8;
  }
  return weight;
}
Program: 25530
Project: 25530
Buggy source:
protected ImageProcessor loadImageProcessor(final String url,final int downSampleLevels,final boolean isMask,final boolean convertTo16Bit) throws IllegalArgumentException {
  if (LOG.isDebugEnabled()) {
    LOG.debug("String_Node_Str",url,downSampleLevels,convertTo16Bit);
  }
  ImageProcessor imageProcessor=null;
  if (downSampleLevels > 0) {
    imageProcessor=cache.getIfPresent(new CacheKey(url,0,isMask,convertTo16Bit));
  }
  if (imageProcessor == null) {
    final Opener opener=new Opener();
    opener.setSilentMode(true);
    final ImagePlus imagePlus=opener.openURL(url);
    if (imagePlus == null) {
      throw new IllegalArgumentException("String_Node_Str" + url + "String_Node_Str");
    }
    imageProcessor=imagePlus.getProcessor();
    if (!isMask && imageProcessor.getBitDepth() == 8 && convertTo16Bit) {
      imageProcessor=imageProcessor.convertToShort(false);
      imageProcessor.multiply(256.0);
    }
    if (cacheOriginalsForDownSampledImages && (downSampleLevels > 0)) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("String_Node_Str",url);
      }
      cache.put(new CacheKey(url,0,isMask,convertTo16Bit),imageProcessor);
    }
  }
  if (downSampleLevels > 0) {
    imageProcessor=Downsampler.downsampleImageProcessor(imageProcessor,downSampleLevels);
  }
  return imageProcessor;
}

Fixed version (ground truth):
/** 
 * The core method used to load image processor instances that is called when cache misses occur.
 * @param url               url for the image.
 * @param downSampleLevels  number of levels to further down sample the image.
 * @param isMask            indicates whether this image is a mask.
 * @return a newly loaded image processor to be cached.
 * @throws IllegalArgumentException if the image cannot be loaded.
 */
protected ImageProcessor loadImageProcessor(final String url,final int downSampleLevels,final boolean isMask,final boolean convertTo16Bit) throws IllegalArgumentException {
  if (LOG.isDebugEnabled()) {
    LOG.debug("String_Node_Str",url,downSampleLevels,convertTo16Bit);
  }
  ImageProcessor imageProcessor=null;
  if (downSampleLevels > 0) {
    imageProcessor=cache.getIfPresent(new CacheKey(url,0,isMask,convertTo16Bit));
  }
  if (imageProcessor == null) {
    final Opener opener=new Opener();
    opener.setSilentMode(true);
    final ImagePlus imagePlus=opener.openURL(url);
    if (imagePlus == null) {
      throw new IllegalArgumentException("String_Node_Str" + url + "String_Node_Str");
    }
    imageProcessor=imagePlus.getProcessor();
    if (!isMask && imageProcessor.getBitDepth() == 8 && convertTo16Bit) {
      imageProcessor=imageProcessor.convertToShort(false);
      imageProcessor.multiply(256.0);
    }
    if (cacheOriginalsForDownSampledImages && (downSampleLevels > 0)) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("String_Node_Str",url);
      }
      cache.put(new CacheKey(url,0,isMask,convertTo16Bit),imageProcessor);
    }
  }
  if (downSampleLevels > 0) {
    imageProcessor=Downsampler.downsampleImageProcessor(imageProcessor,downSampleLevels);
  }
  return imageProcessor;
}
Program: 25531
Project: 25531
Buggy source:
@Override public ImageProcessor load(@Nullable CacheKey key) throws Exception {
  ImageProcessor imageProcessor=null;
  if (key != null) {
    imageProcessor=loadImageProcessor(key.getUri(),key.getDownSampleLevels(),key.isMask(),key.isConvertTo16Bit());
  }
  return imageProcessor;
}

Fixed version (ground truth):
@Override public ImageProcessor load(@Nullable final CacheKey key) throws Exception {
  ImageProcessor imageProcessor=null;
  if (key != null) {
    imageProcessor=loadImageProcessor(key.getUri(),key.getDownSampleLevels(),key.isMask(),key.isConvertTo16Bit());
  }
  return imageProcessor;
}
Program: 25532
Project: 25532
Buggy source:
public ImageProcessor get(final String url,final int downSampleLevels,boolean isMask,boolean convertTo16Bit) throws IllegalArgumentException {
  final CacheKey key=new CacheKey(url,downSampleLevels,isMask,convertTo16Bit);
  final ImageProcessor imageProcessor;
  try {
    imageProcessor=cache.get(key);
  }
 catch (  Throwable t) {
    throw new IllegalArgumentException("String_Node_Str" + key + "String_Node_Str",t);
  }
  return imageProcessor.duplicate();
}

Fixed version (ground truth):
/** 
 * @param url               url for the image.
 * @param downSampleLevels  number of levels to further down sample the image.Negative values are considered the same as zero.
 * @param isMask            indicates whether this image is a mask.
 * @param convertTo16Bit    indicates whether this image should be converted to 16-bit.
 * @return a duplicate instance of the cached image processor for the specified url string.If the source processor is not already cached, it will be loaded into the cache. The duplicate instance is returned because the processors are mutable and the cached instance needs to remain unaltered for future use.
 * @throws IllegalArgumentException if the image cannot be loaded.
 */
public ImageProcessor get(final String url,final int downSampleLevels,final boolean isMask,final boolean convertTo16Bit) throws IllegalArgumentException {
  final CacheKey key=new CacheKey(url,downSampleLevels,isMask,convertTo16Bit);
  final ImageProcessor imageProcessor;
  try {
    imageProcessor=cache.get(key);
  }
 catch (  final Throwable t) {
    throw new IllegalArgumentException("String_Node_Str" + key + "String_Node_Str",t);
  }
  return imageProcessor.duplicate();
}
Program: 25533
Project: 25533
Buggy source:
@Override public boolean equals(Object o){
  boolean result=true;
  if (this != o) {
    if (o instanceof CacheKey) {
      final CacheKey that=(CacheKey)o;
      result=this.url.equals(that.url) && (this.downSampleLevels == that.downSampleLevels) && (this.convertTo16Bit == that.convertTo16Bit);
    }
 else {
      result=false;
    }
  }
  return result;
}

Fixed version (ground truth):
@Override public boolean equals(final Object o){
  boolean result=true;
  if (this != o) {
    if (o instanceof CacheKey) {
      final CacheKey that=(CacheKey)o;
      result=this.url.equals(that.url) && (this.downSampleLevels == that.downSampleLevels) && (this.convertTo16Bit == that.convertTo16Bit);
    }
 else {
      result=false;
    }
  }
  return result;
}
Program: 25534
Project: 25534
Buggy source:
/** 
 * @param url               url for the image.
 * @param downSampleLevels  number of levels to further down sample the image.
 * @param isMask            indicates whether this image is a mask.
 * @return a newly loaded (non-cached) image processor.
 * @throws IllegalArgumentException if the image cannot be loaded.
 */
public static ImageProcessor getNonCachedImage(final String url,final int downSampleLevels,final boolean isMask) throws IllegalArgumentException {
  return DISABLED_CACHE.loadImageProcessor(url,downSampleLevels,isMask);
}

Fixed version (ground truth):
/** 
 * @param url               url for the image.
 * @param downSampleLevels  number of levels to further down sample the image.
 * @param isMask            indicates whether this image is a mask.
 * @return a newly loaded (non-cached) image processor.
 * @throws IllegalArgumentException if the image cannot be loaded.
 */
public static ImageProcessor getNonCachedImage(final String url,final int downSampleLevels,final boolean isMask,final boolean convertTo16Bit) throws IllegalArgumentException {
  return DISABLED_CACHE.loadImageProcessor(url,downSampleLevels,isMask,convertTo16Bit);
}
Program: 25535
Project: 25535
Buggy source:
/** 
 * Loads a label image processor when cache misses occur for source images. Masks are loaded in the standard manner.
 * @param url               url for the image.
 * @param downSampleLevels  number of levels to further down sample the image.
 * @param isMask            indicates whether this image is a mask.
 * @return a newly loaded image processor to be cached.
 * @throws IllegalArgumentException if the image cannot be loaded.
 */
@Override protected ImageProcessor loadImageProcessor(final String url,final int downSampleLevels,final boolean isMask) throws IllegalArgumentException {
  ImageProcessor imageProcessor;
  if (isMask) {
    imageProcessor=super.loadImageProcessor(url,downSampleLevels,true);
  }
 else {
    final Color labelColor=getColorForUrl(url);
    if (LOG.isDebugEnabled()) {
      LOG.debug("String_Node_Str",url,downSampleLevels,labelColor);
    }
    final TileSpec tileSpec=urlToTileSpec.get(url);
    imageProcessor=loadLabelProcessor(tileSpec.getWidth(),tileSpec.getHeight(),labelColor);
    if (downSampleLevels > 0) {
      imageProcessor=Downsampler.downsampleImageProcessor(imageProcessor,downSampleLevels);
    }
  }
  return imageProcessor;
}

Fixed version (ground truth):
/** 
 * Loads a label image processor when cache misses occur for source images. Masks are loaded in the standard manner.
 * @param url               url for the image.
 * @param downSampleLevels  number of levels to further down sample the image.
 * @param isMask            indicates whether this image is a mask.
 * @return a newly loaded image processor to be cached.
 * @throws IllegalArgumentException if the image cannot be loaded.
 */
@Override protected ImageProcessor loadImageProcessor(final String url,final int downSampleLevels,final boolean isMask,final boolean convertTo16Bit) throws IllegalArgumentException {
  ImageProcessor imageProcessor;
  if (isMask) {
    imageProcessor=super.loadImageProcessor(url,downSampleLevels,true,convertTo16Bit);
  }
 else {
    final Color labelColor=getColorForUrl(url);
    if (LOG.isDebugEnabled()) {
      LOG.debug("String_Node_Str",url,downSampleLevels,labelColor);
    }
    final TileSpec tileSpec=urlToTileSpec.get(url);
    imageProcessor=loadLabelProcessor(tileSpec.getWidth(),tileSpec.getHeight(),labelColor);
    if (downSampleLevels > 0) {
      imageProcessor=Downsampler.downsampleImageProcessor(imageProcessor,downSampleLevels);
    }
  }
  return imageProcessor;
}
Program: 25536
Project: 25536
Buggy source:
@Test public void testRender() throws Exception {
  final ImageAndMask imageWithoutMask=new ImageAndMask("String_Node_Str",null);
  final ImageProcessorCache imageProcessorCache=new ImageProcessorCache();
  final ImageProcessor rawIp=imageProcessorCache.get(imageWithoutMask.getImageUrl(),0,false);
  final BufferedImage rawImage=rawIp.getBufferedImage();
  final TileSpec tileSpec=new TileSpec();
  tileSpec.putMipmap(0,imageWithoutMask);
  final RenderParameters tileRenderParameters=new RenderParameters(null,0,0,rawIp.getWidth(),rawIp.getHeight(),1.0);
  tileRenderParameters.addTileSpec(tileSpec);
  tileRenderParameters.setSkipInterpolation(true);
  final BufferedImage renderedImage=tileRenderParameters.openTargetImage();
  Render.render(tileRenderParameters,renderedImage,imageProcessorCache);
  Assert.assertEquals("String_Node_Str",rawImage.getWidth(),renderedImage.getWidth());
  Assert.assertEquals("String_Node_Str",rawImage.getWidth(),renderedImage.getHeight());
  for (int x=0; x < rawImage.getWidth(); x++) {
    for (int y=0; y < rawImage.getHeight(); y++) {
      Assert.assertEquals("String_Node_Str" + x + "String_Node_Str"+ y+ "String_Node_Str",rawImage.getRGB(x,y),renderedImage.getRGB(x,y));
    }
  }
}

Fixed version (ground truth):
@Test public void testRender() throws Exception {
  final ImageAndMask imageWithoutMask=new ImageAndMask("String_Node_Str",null);
  final ImageProcessorCache imageProcessorCache=new ImageProcessorCache();
  final ImageProcessor rawIp=imageProcessorCache.get(imageWithoutMask.getImageUrl(),0,false,false);
  final BufferedImage rawImage=rawIp.getBufferedImage();
  final TileSpec tileSpec=new TileSpec();
  tileSpec.putMipmap(0,imageWithoutMask);
  final RenderParameters tileRenderParameters=new RenderParameters(null,0,0,rawIp.getWidth(),rawIp.getHeight(),1.0);
  tileRenderParameters.addTileSpec(tileSpec);
  tileRenderParameters.setSkipInterpolation(true);
  final BufferedImage renderedImage=tileRenderParameters.openTargetImage();
  Render.render(tileRenderParameters,renderedImage,imageProcessorCache);
  Assert.assertEquals("String_Node_Str",rawImage.getWidth(),renderedImage.getWidth());
  Assert.assertEquals("String_Node_Str",rawImage.getWidth(),renderedImage.getHeight());
  for (int x=0; x < rawImage.getWidth(); x++) {
    for (int y=0; y < rawImage.getHeight(); y++) {
      Assert.assertEquals("String_Node_Str" + x + "String_Node_Str"+ y+ "String_Node_Str",rawImage.getRGB(x,y),renderedImage.getRGB(x,y));
    }
  }
}
Program: 25538
Project: 25538
Buggy source:
@Before public void setup() throws Exception {
  tileSpec=TileSpec.fromJson(TILE_SPEC_JSON);
  ctlMipmap=new CoordinateTransformList<>();
  for (  final CoordinateTransform t : tileSpec.getTransformList().getList(null)) {
    ctlMipmap.add(t);
  }
  final int downSampleLevels=0;
  final Map.Entry<Integer,ImageAndMask> mipmapEntry=tileSpec.getFirstMipmapEntry();
  final ImageAndMask imageAndMask=mipmapEntry.getValue();
  ipMipmap=ImageProcessorCache.getNonCachedImage(imageAndMask.getImageUrl(),downSampleLevels,false);
  tp=ipMipmap.createProcessor(ipMipmap.getWidth(),ipMipmap.getHeight());
  final String maskUrl=imageAndMask.getMaskUrl();
  maskSourceProcessor=ImageProcessorCache.getNonCachedImage(maskUrl,downSampleLevels,true);
  maskTargetProcessor=new ByteProcessor(tp.getWidth(),tp.getHeight());
}

Fixed version (ground truth):
@Before public void setup() throws Exception {
  tileSpec=TileSpec.fromJson(TILE_SPEC_JSON);
  ctlMipmap=new CoordinateTransformList<>();
  for (  final CoordinateTransform t : tileSpec.getTransformList().getList(null)) {
    ctlMipmap.add(t);
  }
  final int downSampleLevels=0;
  final Map.Entry<Integer,ImageAndMask> mipmapEntry=tileSpec.getFirstMipmapEntry();
  final ImageAndMask imageAndMask=mipmapEntry.getValue();
  ipMipmap=ImageProcessorCache.getNonCachedImage(imageAndMask.getImageUrl(),downSampleLevels,false,false);
  tp=ipMipmap.createProcessor(ipMipmap.getWidth(),ipMipmap.getHeight());
  final String maskUrl=imageAndMask.getMaskUrl();
  maskSourceProcessor=ImageProcessorCache.getNonCachedImage(maskUrl,downSampleLevels,true,false);
  maskTargetProcessor=new ByteProcessor(tp.getWidth(),tp.getHeight());
}
Program: 25540
Project: 25540
Buggy source:
public static BufferedImage targetToARGBImage(final ImageProcessorWithMasks target,final double sourceMinIntensity,final double sourceMaxIntensity,final boolean binaryMask,final Double renderMinIntensity,final Double renderMaxIntensity){
  final double minIntensity=(renderMinIntensity == null) ? sourceMinIntensity : renderMinIntensity;
  final double maxIntensity=(renderMaxIntensity == null) ? sourceMaxIntensity : renderMaxIntensity;
  target.ip.setMinAndMax(minIntensity,maxIntensity);
  final ColorProcessor cp=target.ip.convertToColorProcessor();
  final int[] cpPixels=(int[])cp.getPixels();
  final byte[] alphaPixels;
  if (target.mask != null) {
    alphaPixels=(byte[])target.mask.getPixels();
  }
 else {
    alphaPixels=(byte[])target.outside.getPixels();
  }
  if (binaryMask) {
    for (int i=0; i < cpPixels.length; ++i) {
      if (alphaPixels[i] == -1)       cpPixels[i]&=0xffffffff;
 else       cpPixels[i]&=0x00ffffff;
    }
  }
 else {
    for (int i=0; i < cpPixels.length; ++i) {
      cpPixels[i]&=0x00ffffff | (alphaPixels[i] << 24);
    }
  }
  final BufferedImage image=new BufferedImage(cp.getWidth(),cp.getHeight(),BufferedImage.TYPE_INT_ARGB);
  final WritableRaster raster=image.getRaster();
  raster.setDataElements(0,0,cp.getWidth(),cp.getHeight(),cpPixels);
  return image;
}

Fixed version (ground truth):
public static BufferedImage targetToARGBImage(final ImageProcessorWithMasks target,final double sourceMinIntensity,final double sourceMaxIntensity,final boolean binaryMask,final Double renderMinIntensity,final Double renderMaxIntensity){
  final double minIntensity=(renderMinIntensity == null) ? sourceMinIntensity : renderMinIntensity;
  final double maxIntensity=(renderMaxIntensity == null) ? sourceMaxIntensity : renderMaxIntensity;
  target.ip.setMinAndMax(minIntensity,maxIntensity);
  final ColorProcessor cp=target.ip.convertToColorProcessor();
  final int[] cpPixels=(int[])cp.getPixels();
  final byte[] alphaPixels;
  if (target.mask != null) {
    alphaPixels=(byte[])target.mask.getPixels();
  }
 else   if (target.outside != null) {
    alphaPixels=(byte[])target.outside.getPixels();
  }
 else {
    alphaPixels=null;
  }
  if (alphaPixels == null) {
    for (int i=0; i < cpPixels.length; ++i) {
      cpPixels[i]&=0xffffffff;
    }
  }
 else   if (binaryMask) {
    for (int i=0; i < cpPixels.length; ++i) {
      if (alphaPixels[i] == -1)       cpPixels[i]&=0xffffffff;
 else       cpPixels[i]&=0x00ffffff;
    }
  }
 else {
    for (int i=0; i < cpPixels.length; ++i) {
      cpPixels[i]&=0x00ffffff | (alphaPixels[i] << 24);
    }
  }
  final BufferedImage image=new BufferedImage(cp.getWidth(),cp.getHeight(),BufferedImage.TYPE_INT_ARGB);
  final WritableRaster raster=image.getRaster();
  raster.setDataElements(0,0,cp.getWidth(),cp.getHeight(),cpPixels);
  return image;
}
Program: 25541
Project: 25541
Buggy source:
@Override public ChannelMap getChannels(final int mipmapLevel) throws IllegalArgumentException {
  final ChannelMap targetChannels=new ChannelMap();
  final double levelScale=(1.0 / Math.pow(2.0,mipmapLevel)) * levelZeroScale;
  final int levelWidth=(int)((fullScaleWidth * levelScale) + 0.5);
  final int levelHeight=(int)((fullScaleHeight * levelScale) + 0.5);
  for (  final String channelName : channelNames) {
    targetChannels.put(channelName,new ImageProcessorWithMasks(new FloatProcessor(levelWidth,levelHeight),new ByteProcessor(levelWidth,levelHeight),null));
  }
  long totalScaleDerivationTime=0;
  for (  final TransformableCanvas canvas : canvasList) {
    final long scaleDerivationStart=System.currentTimeMillis();
    final CoordinateTransformList<CoordinateTransform> renderTransformList=addRenderScaleAndOffset(canvas.getTransformList(),levelZeroScale,levelScale,x,y);
    final MipmapSource source=canvas.getSource();
    final double averageScale=Utils.sampleAverageScale(renderTransformList,source.getFullScaleWidth(),source.getFullScaleHeight(),meshCellSize);
    final int componentMipmapLevel=Utils.bestMipmapLevel(averageScale);
    totalScaleDerivationTime+=(System.currentTimeMillis() - scaleDerivationStart);
    mapPixels(source,componentMipmapLevel,renderTransformList,meshCellSize,binaryMask,numberOfMappingThreads,skipInterpolation,targetChannels);
  }
  LOG.debug("String_Node_Str",canvasList.size(),totalScaleDerivationTime);
  return targetChannels;
}

Fixed version (ground truth):
@Override public ChannelMap getChannels(final int mipmapLevel) throws IllegalArgumentException {
  final ChannelMap targetChannels=new ChannelMap();
  final double levelScale=(1.0 / Math.pow(2.0,mipmapLevel)) * levelZeroScale;
  final int levelWidth=(int)((fullScaleWidth * levelScale) + 0.5);
  final int levelHeight=(int)((fullScaleHeight * levelScale) + 0.5);
  for (  final String channelName : channelNames) {
    targetChannels.put(channelName,new ImageProcessorWithMasks(new FloatProcessor(levelWidth,levelHeight),null,null));
  }
  long totalScaleDerivationTime=0;
  for (  final TransformableCanvas canvas : canvasList) {
    final long scaleDerivationStart=System.currentTimeMillis();
    final CoordinateTransformList<CoordinateTransform> renderTransformList=addRenderScaleAndOffset(canvas.getTransformList(),levelZeroScale,levelScale,x,y);
    final MipmapSource source=canvas.getSource();
    final double averageScale=Utils.sampleAverageScale(renderTransformList,source.getFullScaleWidth(),source.getFullScaleHeight(),meshCellSize);
    final int componentMipmapLevel=Utils.bestMipmapLevel(averageScale);
    totalScaleDerivationTime+=(System.currentTimeMillis() - scaleDerivationStart);
    mapPixels(source,componentMipmapLevel,renderTransformList,meshCellSize,binaryMask,numberOfMappingThreads,skipInterpolation,targetChannels);
  }
  LOG.debug("String_Node_Str",canvasList.size(),totalScaleDerivationTime);
  return targetChannels;
}
Program: 25544
Project: 25544
Buggy source:
private Map<String,TransformSpec> addResolvedTileSpecs(final StackId stackId,final Document tileQuery,final RenderParameters renderParameters){
  final MongoCollection<Document> tileCollection=getTileCollection(stackId);
  final Document orderBy=new Document("String_Node_Str",1);
  try (MongoCursor<Document> cursor=tileCollection.find(tileQuery).sort(orderBy).iterator()){
    Document document;
    TileSpec tileSpec;
    int count=0;
    while (cursor.hasNext()) {
      if (count > 50000) {
        throw new IllegalArgumentException("String_Node_Str" + count + "String_Node_Str"+ tileQuery);
      }
      document=cursor.next();
      tileSpec=TileSpec.fromJson(document.toJson());
      renderParameters.addTileSpec(tileSpec);
      count++;
    }
  }
   LOG.debug("String_Node_Str",renderParameters.numberOfTileSpecs(),MongoUtil.fullName(tileCollection),tileQuery.toJson(),orderBy.toJson());
  return resolveTransformReferencesForTiles(stackId,renderParameters.getTileSpecs());
}

Fixed version (ground truth):
private Map<String,TransformSpec> addResolvedTileSpecs(final StackId stackId,final Document tileQuery,final RenderParameters renderParameters){
  final MongoCollection<Document> tileCollection=getTileCollection(stackId);
  final Document orderBy=new Document("String_Node_Str",1);
  try (MongoCursor<Document> cursor=tileCollection.find(tileQuery).sort(orderBy).iterator()){
    Document document;
    TileSpec tileSpec;
    int count=0;
    while (cursor.hasNext()) {
      if (count > 50000) {
        throw new IllegalArgumentException("String_Node_Str" + count + "String_Node_Str"+ tileQuery);
      }
      document=cursor.next();
      tileSpec=TileSpec.fromJson(document.toJson());
      renderParameters.addTileSpec(tileSpec);
      count++;
    }
  }
   if (LOG.isDebugEnabled()) {
    String queryJson=tileQuery.toJson();
    if (queryJson.length() > 100) {
      queryJson=queryJson.substring(0,95) + "String_Node_Str";
    }
    LOG.debug("String_Node_Str",renderParameters.numberOfTileSpecs(),MongoUtil.fullName(tileCollection),queryJson,orderBy.toJson());
  }
  return resolveTransformReferencesForTiles(stackId,renderParameters.getTileSpecs());
}