Program: 25505
Project: 25505
Buggy source:
@Path("String_Node_Str") @GET @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value="String_Node_Str",notes="String_Node_Str" + "String_Node_Str") @ApiResponses(value={@ApiResponse(code=400,message="String_Node_Str"),@ApiResponse(code=404,message="String_Node_Str")}) public LeafTransformSpec buildAffineWarpFieldTransform(@PathParam("String_Node_Str") final String owner,@PathParam("String_Node_Str") final String project,@PathParam("String_Node_Str") final Double z,@QueryParam("String_Node_Str") final Integer consensusRows,@QueryParam("String_Node_Str") final Integer consensusColumns){
  LOG.info("String_Node_Str",owner,project,z);
  LeafTransformSpec transformSpec=null;
  final int consensusRowCount=consensusRows == null ? 10 : consensusRows;
  final int consensusColumnCount=consensusRows == null ? 10 : consensusColumns;
  try {
    final List<StackMetaData> projectStacks=renderDao.getStackMetaDataList(owner,project);
    final Map<String,StackMetaData> projectStackNamesToMetadataMap=new HashMap<>(projectStacks.size() * 2);
    for (    final StackMetaData stackMetaData : projectStacks) {
      projectStackNamesToMetadataMap.put(stackMetaData.getStackId().getStack(),stackMetaData);
    }
    final List<HierarchicalStack> alignedTierStacks=new ArrayList<>(projectStacks.size());
    HierarchicalStack hierarchicalStack;
    for (    final StackMetaData stackMetaData : projectStacks) {
      hierarchicalStack=stackMetaData.getHierarchicalData();
      if ((hierarchicalStack != null) && (projectStackNamesToMetadataMap.containsKey(hierarchicalStack.getAlignedStackId().getStack()))) {
        alignedTierStacks.add(hierarchicalStack);
      }
    }
    StackId alignedStackId;
    StackStats alignedStackStats;
    Bounds alignedStackBounds;
    AffineModel2D relativeAlignedModel;
    final double[] affineMatrixElements=new double[6];
    TileSpec tileSpecForZ;
    if (alignedTierStacks.size() > 0) {
      LOG.info("String_Node_Str",z,alignedTierStacks.size());
      AffineWarpField warpField=null;
      final Map<HierarchicalStack,AffineWarpField> tierStackToConsensusFieldMap=new HashMap<>();
      double[] locationOffsets=AffineWarpFieldTransform.EMPTY_OFFSETS;
      for (      final HierarchicalStack tierStack : alignedTierStacks) {
        if (warpField == null) {
          warpField=new AffineWarpField(tierStack.getTotalTierFullScaleWidth(),tierStack.getTotalTierFullScaleHeight(),tierStack.getTotalTierRowCount(),tierStack.getTotalTierColumnCount(),AffineWarpField.getDefaultInterpolatorFactory());
          final StackMetaData parentStackMetadata=getStackMetaData(tierStack.getParentTierStackId());
          final StackStats parentStats=parentStackMetadata.getStats();
          if (parentStats != null) {
            final Bounds parentBounds=parentStats.getStackBounds();
            locationOffsets=new double[]{parentBounds.getMinX(),parentBounds.getMinY()};
          }
        }
        alignedStackId=tierStack.getAlignedStackId();
        alignedStackBounds=null;
        alignedStackStats=projectStackNamesToMetadataMap.get(alignedStackId.getStack()).getStats();
        if (alignedStackStats != null) {
          alignedStackBounds=alignedStackStats.getStackBounds();
        }
        if (alignedStackBounds == null) {
          throw new IllegalArgumentException("String_Node_Str" + z + "String_Node_Str"+ alignedStackId+ "String_Node_Str");
        }
        final Set<String> multiConsensusGroupIds=matchDao.getMultiConsensusGroupIds(tierStack.getMatchCollectionId());
        if ((multiConsensusGroupIds.size() > 0) && (multiConsensusGroupIds.contains(z.toString()))) {
          final Bounds tierStackBounds=tierStack.getFullScaleBounds();
          final ConsensusWarpFieldBuilder builder=new ConsensusWarpFieldBuilder(tierStackBounds.getDeltaX(),tierStackBounds.getDeltaY(),consensusRowCount,consensusColumnCount);
          final String groupId=z.toString();
          final List<CanvasMatches> canvasMatchesList=matchDao.getMatchesOutsideGroup(tierStack.getMatchCollectionId(),z.toString());
          final Map<String,List<RealPoint>> tileIdToPoints=new HashMap<>();
          for (          final CanvasMatches pair : canvasMatchesList) {
            final String tileId;
            final List<RealPoint> points;
            if (groupId.equals(pair.getpGroupId())) {
              tileId=pair.getpId();
              points=pair.getMatches().getPList();
            }
 else {
              tileId=pair.getqId();
              points=pair.getMatches().getQList();
            }
            final List<RealPoint> savedPoints=tileIdToPoints.get(tileId);
            if (savedPoints == null) {
              tileIdToPoints.put(tileId,points);
            }
 else {
              savedPoints.addAll(points);
            }
          }
          for (          final String tileId : tileIdToPoints.keySet()) {
            tileSpecForZ=renderDao.getTileSpec(alignedStackId,tileId,false);
            relativeAlignedModel=getRelativeAlignedModel(tierStack,tileSpecForZ,alignedStackId,alignedStackBounds.getMinX(),alignedStackBounds.getMinY());
            builder.addConsensusSetData(relativeAlignedModel,tileIdToPoints.get(tileId));
          }
          tierStackToConsensusFieldMap.put(tierStack,builder.build());
        }
 else {
          tileSpecForZ=renderDao.getTileSpec(alignedStackId,tierStack.getTileIdForZ(z),false);
          relativeAlignedModel=getRelativeAlignedModel(tierStack,tileSpecForZ,alignedStackId,alignedStackBounds.getMinX(),alignedStackBounds.getMinY());
          relativeAlignedModel.toArray(affineMatrixElements);
          warpField.set(tierStack.getTierRow(),tierStack.getTierColumn(),affineMatrixElements);
        }
      }
      if ((warpField != null) && (tierStackToConsensusFieldMap.size() > 0)) {
        LOG.info("String_Node_Str",tierStackToConsensusFieldMap.size());
        final AffineWarpField hiResField=warpField.getHighResolutionCopy(consensusRowCount,consensusColumnCount);
        for (        final HierarchicalStack tierStack : tierStackToConsensusFieldMap.keySet()) {
          final AffineWarpField consensusField=tierStackToConsensusFieldMap.get(tierStack);
          final int startHiResRow=tierStack.getTierRow() * consensusRowCount;
          final int startHiResColumn=tierStack.getTierColumn() * consensusColumnCount;
          for (int row=0; row < consensusRowCount; row++) {
            for (int column=0; column < consensusColumnCount; column++) {
              hiResField.set((startHiResRow + row),(startHiResColumn + column),consensusField.get(row,column));
            }
          }
        }
        warpField=hiResField;
      }
      final String warpFieldTransformId=z + "String_Node_Str";
      final AffineWarpFieldTransform warpFieldTransform=new AffineWarpFieldTransform(locationOffsets,warpField);
      transformSpec=new LeafTransformSpec(warpFieldTransformId,null,AffineWarpFieldTransform.class.getName(),warpFieldTransform.toDataString());
    }
 else {
      throw new ObjectNotFoundException("String_Node_Str" + owner + "String_Node_Str"+ project+ "String_Node_Str");
    }
  }
 catch (  final Throwable t) {
    RenderServiceUtil.throwServiceException(t);
  }
  return transformSpec;
}

Fixed version (ground truth):
@Path("String_Node_Str") @GET @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value="String_Node_Str",notes="String_Node_Str" + "String_Node_Str") @ApiResponses(value={@ApiResponse(code=400,message="String_Node_Str"),@ApiResponse(code=404,message="String_Node_Str")}) public LeafTransformSpec buildAffineWarpFieldTransform(@PathParam("String_Node_Str") final String owner,@PathParam("String_Node_Str") final String project,@PathParam("String_Node_Str") final Double z,@QueryParam("String_Node_Str") final Integer consensusRows,@QueryParam("String_Node_Str") final Integer consensusColumns){
  LOG.info("String_Node_Str",owner,project,z);
  LeafTransformSpec transformSpec=null;
  final int consensusRowCount=consensusRows == null ? 10 : consensusRows;
  final int consensusColumnCount=consensusRows == null ? 10 : consensusColumns;
  try {
    final List<StackMetaData> projectStacks=renderDao.getStackMetaDataList(owner,project);
    final Map<String,StackMetaData> projectStackNamesToMetadataMap=new HashMap<>(projectStacks.size() * 2);
    for (    final StackMetaData stackMetaData : projectStacks) {
      projectStackNamesToMetadataMap.put(stackMetaData.getStackId().getStack(),stackMetaData);
    }
    final List<HierarchicalStack> alignedTierStacks=new ArrayList<>(projectStacks.size());
    HierarchicalStack hierarchicalStack;
    for (    final StackMetaData stackMetaData : projectStacks) {
      hierarchicalStack=stackMetaData.getHierarchicalData();
      if ((hierarchicalStack != null) && (projectStackNamesToMetadataMap.containsKey(hierarchicalStack.getAlignedStackId().getStack()))) {
        alignedTierStacks.add(hierarchicalStack);
      }
    }
    StackId alignedStackId;
    StackStats alignedStackStats;
    Bounds alignedStackBounds;
    AffineModel2D relativeAlignedModel;
    final double[] affineMatrixElements=new double[6];
    TileSpec tileSpecForZ;
    if (alignedTierStacks.size() > 0) {
      LOG.info("String_Node_Str",z,alignedTierStacks.size());
      AffineWarpField warpField=null;
      final Map<HierarchicalStack,AffineWarpField> tierStackToConsensusFieldMap=new HashMap<>();
      double[] locationOffsets=AffineWarpFieldTransform.EMPTY_OFFSETS;
      for (      final HierarchicalStack tierStack : alignedTierStacks) {
        if (warpField == null) {
          warpField=new AffineWarpField(tierStack.getTotalTierFullScaleWidth(),tierStack.getTotalTierFullScaleHeight(),tierStack.getTotalTierRowCount(),tierStack.getTotalTierColumnCount(),AffineWarpField.getDefaultInterpolatorFactory());
          final StackMetaData parentStackMetadata=getStackMetaData(tierStack.getParentTierStackId());
          final StackStats parentStats=parentStackMetadata.getStats();
          if (parentStats != null) {
            final Bounds parentBounds=parentStats.getStackBounds();
            locationOffsets=new double[]{parentBounds.getMinX(),parentBounds.getMinY()};
          }
        }
        alignedStackId=tierStack.getAlignedStackId();
        alignedStackBounds=null;
        alignedStackStats=projectStackNamesToMetadataMap.get(alignedStackId.getStack()).getStats();
        if (alignedStackStats != null) {
          alignedStackBounds=alignedStackStats.getStackBounds();
        }
        if (alignedStackBounds == null) {
          throw new IllegalArgumentException("String_Node_Str" + z + "String_Node_Str"+ alignedStackId+ "String_Node_Str");
        }
        final String groupId=z.toString();
        if (tierStack.hasSplitGroupId(groupId)) {
          final Bounds tierStackBounds=tierStack.getFullScaleBounds();
          final ConsensusWarpFieldBuilder builder=new ConsensusWarpFieldBuilder(tierStackBounds.getDeltaX(),tierStackBounds.getDeltaY(),consensusRowCount,consensusColumnCount);
          final List<CanvasMatches> canvasMatchesList=matchDao.getMatchesOutsideGroup(tierStack.getMatchCollectionId(),groupId);
          final CanvasNameToPointsMap nameToPointsForGroup=new CanvasNameToPointsMap(1 / tierStack.getScale());
          nameToPointsForGroup.addPointsForGroup(groupId,canvasMatchesList);
          for (          final String tileId : nameToPointsForGroup.getNames()) {
            tileSpecForZ=renderDao.getTileSpec(alignedStackId,tileId,false);
            relativeAlignedModel=getRelativeAlignedModel(tierStack,tileSpecForZ,alignedStackId,alignedStackBounds.getMinX(),alignedStackBounds.getMinY());
            builder.addConsensusSetData(relativeAlignedModel,nameToPointsForGroup.getPoints(tileId));
          }
          tierStackToConsensusFieldMap.put(tierStack,builder.build());
        }
 else {
          tileSpecForZ=renderDao.getTileSpec(alignedStackId,tierStack.getTileIdForZ(z),false);
          relativeAlignedModel=getRelativeAlignedModel(tierStack,tileSpecForZ,alignedStackId,alignedStackBounds.getMinX(),alignedStackBounds.getMinY());
          relativeAlignedModel.toArray(affineMatrixElements);
          warpField.set(tierStack.getTierRow(),tierStack.getTierColumn(),affineMatrixElements);
        }
      }
      if ((warpField != null) && (tierStackToConsensusFieldMap.size() > 0)) {
        LOG.info("String_Node_Str",tierStackToConsensusFieldMap.size());
        final AffineWarpField hiResField=warpField.getHighResolutionCopy(consensusRowCount,consensusColumnCount);
        for (        final HierarchicalStack tierStack : tierStackToConsensusFieldMap.keySet()) {
          final AffineWarpField consensusField=tierStackToConsensusFieldMap.get(tierStack);
          final int startHiResRow=tierStack.getTierRow() * consensusRowCount;
          final int startHiResColumn=tierStack.getTierColumn() * consensusColumnCount;
          for (int row=0; row < consensusRowCount; row++) {
            for (int column=0; column < consensusColumnCount; column++) {
              hiResField.set((startHiResRow + row),(startHiResColumn + column),consensusField.get(row,column));
            }
          }
        }
        warpField=hiResField;
      }
      final String warpFieldTransformId=z + "String_Node_Str";
      final AffineWarpFieldTransform warpFieldTransform=new AffineWarpFieldTransform(locationOffsets,warpField);
      transformSpec=new LeafTransformSpec(warpFieldTransformId,null,AffineWarpFieldTransform.class.getName(),warpFieldTransform.toDataString());
    }
 else {
      throw new ObjectNotFoundException("String_Node_Str" + owner + "String_Node_Str"+ project+ "String_Node_Str");
    }
  }
 catch (  final Throwable t) {
    RenderServiceUtil.throwServiceException(t);
  }
  return transformSpec;
}