Program: 58126
Project: 58126
Buggy source:
/** 
 * Completely merges a set of plots<br> <b>(There are no checks to make sure you supply the correct arguments)</b><br> - Misuse of this method can result in unusable plots<br> - the set of plots must belong to one owner and be rectangular<br> - the plot array must be sorted in ascending order<br> - Road will be removed where required<br> - changes will be saved to DB<br>
 * @param world
 * @param plotIds
 * @return boolean (success)
 */
public static boolean mergePlots(World world,ArrayList<PlotId> plotIds){
  if (plotIds.size() < 2) {
    return false;
  }
  PlotId pos1=plotIds.get(0);
  PlotId pos2=plotIds.get(plotIds.size() - 1);
  PlotManager manager=PlotMain.getPlotManager(world);
  PlotWorld plotworld=PlotMain.getWorldSettings(world);
  for (int x=pos1.x; x <= pos2.x; x++) {
    for (int y=pos1.y; y <= pos2.y; y++) {
      boolean lx=x < pos2.x;
      boolean ly=y < pos2.y;
      PlotId id=new PlotId(x,y);
      Plot plot=PlotMain.getPlots(world).get(id);
      if (lx) {
        if (ly) {
          if (!plot.settings.getMerged(1) || !plot.settings.getMerged(2)) {
            manager.createRoadSouthEast(plotworld,plot);
          }
        }
        if (!plot.settings.getMerged(1)) {
          Plot plot2=PlotMain.getPlots(world).get(new PlotId(x + 1,y));
          mergePlot(world,plot,plot2);
          plot.settings.setMerged(1,true);
          plot2.settings.setMerged(3,true);
        }
      }
      if (ly) {
        if (!plot.settings.getMerged(2)) {
          Plot plot2=PlotMain.getPlots(world).get(new PlotId(x,y + 1));
          mergePlot(world,plot,plot2);
          plot.settings.setMerged(2,true);
          plot2.settings.setMerged(0,true);
        }
      }
    }
  }
  manager.finishPlotMerge(world,plotworld,plotIds);
  return true;
}

Fixed version (ground truth):
/** 
 * Completely merges a set of plots<br> <b>(There are no checks to make sure you supply the correct arguments)</b><br> - Misuse of this method can result in unusable plots<br> - the set of plots must belong to one owner and be rectangular<br> - the plot array must be sorted in ascending order<br> - Road will be removed where required<br> - changes will be saved to DB<br>
 * @param world
 * @param plotIds
 * @return boolean (success)
 */
public static boolean mergePlots(World world,ArrayList<PlotId> plotIds){
  if (plotIds.size() < 2) {
    return false;
  }
  PlotId pos1=plotIds.get(0);
  PlotId pos2=plotIds.get(plotIds.size() - 1);
  PlotManager manager=PlotMain.getPlotManager(world);
  PlotWorld plotworld=PlotMain.getWorldSettings(world);
  for (int x=pos1.x; x <= pos2.x; x++) {
    for (int y=pos1.y; y <= pos2.y; y++) {
      boolean lx=x < pos2.x;
      boolean ly=y < pos2.y;
      PlotId id=new PlotId(x,y);
      Plot plot=PlotMain.getPlots(world).get(id);
      if (lx) {
        if (ly) {
          if (!plot.settings.getMerged(1) || !plot.settings.getMerged(2)) {
            manager.removeRoadSouthEast(plotworld,plot);
          }
        }
        if (!plot.settings.getMerged(1)) {
          Plot plot2=PlotMain.getPlots(world).get(new PlotId(x + 1,y));
          mergePlot(world,plot,plot2);
          plot.settings.setMerged(1,true);
          plot2.settings.setMerged(3,true);
        }
      }
      if (ly) {
        if (!plot.settings.getMerged(2)) {
          Plot plot2=PlotMain.getPlots(world).get(new PlotId(x,y + 1));
          mergePlot(world,plot,plot2);
          plot.settings.setMerged(2,true);
          plot2.settings.setMerged(0,true);
        }
      }
    }
  }
  manager.finishPlotMerge(world,plotworld,plotIds);
  return true;
}