nus-yam/ex-repair huggingface dataset:
Program: 55543
Project: 55543
Buggy source:
@Override public void onLocationAcquired(android.location.Location location){
  Location myLocation=new Location();
  myLocation.setLatitude(location.getLatitude());
  myLocation.setLongitude(location.getLongitude());
  lastLocation=myLocation;
}

Fixed version (ground truth):
@Override public void onLocationAcquired(android.location.Location location){
  Location myLocation=new Location();
  myLocation.setLatitude(location.getLatitude());
  myLocation.setLongitude(location.getLongitude());
  lastLocation=myLocation;
  lastAddress=LocationGeocoder.getAddress(getActivity().getApplicationContext(),location);
}
Program: 55544
Project: 55544
Buggy source:
public static RouteDetailFragment newInstance(Location origin,Recommendation recommendation){
  RouteDetailFragment fragment=new RouteDetailFragment();
  Bundle args=new Bundle();
  args.putSerializable(ORIGIN_LOCATION_ARG,origin);
  args.putSerializable(RECOMMENDATION_ARG,recommendation);
  fragment.setArguments(args);
  return fragment;
}

Fixed version (ground truth):
public static RouteDetailFragment newInstance(Location originLocation,String originAddress,Recommendation recommendation){
  RouteDetailFragment fragment=new RouteDetailFragment();
  Bundle args=new Bundle();
  args.putSerializable(ORIGIN_LOCATION_ARG,originLocation);
  args.putString(ORIGIN_ADDRESS_ARG,originAddress);
  args.putSerializable(RECOMMENDATION_ARG,recommendation);
  fragment.setArguments(args);
  return fragment;
}
Program: 55545
Project: 55545
Buggy source:
@Override public void onViewCreated(View view,Bundle savedInstanceState){
  super.onViewCreated(view,savedInstanceState);
  recommendationReasonView.setText(getRecommendation().getReason());
  poiListView.setHasFixedSize(true);
  poiListView.setLayoutManager(new LinearLayoutManager(getActivity()));
  poiListView.setAdapter(new RecommendationAdapter(getOriginLocation(),getRecommendation()));
}

Fixed version (ground truth):
@Override public void onViewCreated(View view,Bundle savedInstanceState){
  super.onViewCreated(view,savedInstanceState);
  recommendationReasonView.setVisibility(View.GONE);
  poiListView.setHasFixedSize(true);
  poiListView.setLayoutManager(new LinearLayoutManager(getActivity()));
  poiListView.setAdapter(new RecommendationAdapter(getOriginAddress(),getRecommendation()));
}
Program: 55546
Project: 55546
Buggy source:
public RecommendationAdapter(Location origin,Recommendation recommendation){
  this.origin=origin;
  this.recommendation=recommendation;
}

Fixed version (ground truth):
public RecommendationAdapter(String originAddress,Recommendation recommendation){
  this.originAddress=originAddress;
  this.recommendation=recommendation;
}
Program: 55547
Project: 55547
Buggy source:
@Override public void onBindViewHolder(ViewHolder holder,int position){
  if (position == 0) {
    holder.categoryImageView.setImageResource(R.drawable.ic_generic_category);
    holder.categoryNameView.setText(LocationGeocoder.getAddress(holder.poiNameView.getContext(),origin));
    holder.poiNameView.setText(R.string.your_location);
  }
 else {
    Picasso.with(holder.categoryImageView.getContext()).load(recommendation.getPoiSequence()[position - 1].getCategories()[0].getIconUrl()).placeholder(R.drawable.ic_generic_category).into(holder.categoryImageView);
    holder.categoryNameView.setText(recommendation.getPoiSequence()[position - 1].getCategories()[0].getName());
    holder.poiNameView.setText(recommendation.getPoiSequence()[position - 1].getName());
  }
}

Fixed version (ground truth):
@Override public void onBindViewHolder(ViewHolder holder,int position){
  if (position == 0) {
    holder.categoryImageView.setImageResource(R.drawable.ic_generic_category);
    holder.categoryNameView.setText(originAddress);
    holder.poiNameView.setText(R.string.current_location);
  }
 else {
    Picasso.with(holder.categoryImageView.getContext()).load(recommendation.getPoiSequence()[position - 1].getCategories()[0].getIconUrl()).placeholder(R.drawable.ic_generic_category).into(holder.categoryImageView);
    holder.categoryNameView.setText(recommendation.getPoiSequence()[position - 1].getCategories()[0].getName());
    holder.poiNameView.setText(recommendation.getPoiSequence()[position - 1].getName());
  }
}
Program: 55549
Project: 55549
Buggy source:
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2) @Override public void onConfigurationChanged(Configuration newConfig){
  super.onConfigurationChanged(newConfig);
  if (windowManager == null)   windowManager=(WindowManager)getSystemService(WINDOW_SERVICE);
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
    windowManager.getDefaultDisplay().getSize(szWindow);
  }
 else {
    int w=windowManager.getDefaultDisplay().getWidth();
    int h=windowManager.getDefaultDisplay().getHeight();
    szWindow.set(w,h);
  }
  WindowManager.LayoutParams layoutParams=(WindowManager.LayoutParams)chatheadView.getLayoutParams();
  if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
    Log.d(Utils.LogTag,"String_Node_Str");
    if (txtView != null) {
      txtView.setVisibility(View.GONE);
    }
    if (layoutParams.y + (chatheadView.getHeight() + getStatusBarHeight()) > szWindow.y) {
      layoutParams.y=szWindow.y - (chatheadView.getHeight() + getStatusBarHeight());
      windowManager.updateViewLayout(chatheadView,layoutParams);
    }
    if (layoutParams.x != 0 && layoutParams.x < szWindow.x) {
      resetPosition(szWindow.x);
    }
  }
 else   if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
    Log.d(Utils.LogTag,"String_Node_Str");
    if (txtView != null) {
      txtView.setVisibility(View.GONE);
    }
    if (layoutParams.x > szWindow.x) {
      resetPosition(szWindow.x);
    }
  }
}

Fixed version (ground truth):
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2) @Override public void onConfigurationChanged(Configuration newConfig){
  super.onConfigurationChanged(newConfig);
  if (windowManager == null)   return;
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
    windowManager.getDefaultDisplay().getSize(szWindow);
  }
 else {
    int w=windowManager.getDefaultDisplay().getWidth();
    int h=windowManager.getDefaultDisplay().getHeight();
    szWindow.set(w,h);
  }
  WindowManager.LayoutParams layoutParams=(WindowManager.LayoutParams)chatheadView.getLayoutParams();
  if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
    Log.d(Utils.LogTag,"String_Node_Str");
    if (txtView != null) {
      txtView.setVisibility(View.GONE);
    }
    if (layoutParams.y + (chatheadView.getHeight() + getStatusBarHeight()) > szWindow.y) {
      layoutParams.y=szWindow.y - (chatheadView.getHeight() + getStatusBarHeight());
      windowManager.updateViewLayout(chatheadView,layoutParams);
    }
    if (layoutParams.x != 0 && layoutParams.x < szWindow.x) {
      resetPosition(szWindow.x);
    }
  }
 else   if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
    Log.d(Utils.LogTag,"String_Node_Str");
    if (txtView != null) {
      txtView.setVisibility(View.GONE);
    }
    if (layoutParams.x > szWindow.x) {
      resetPosition(szWindow.x);
    }
  }
}
Program: 55552
Project: 55552
Buggy source:
@Override public Object doEvaluate(Map<String,Object> argMap,Map<String,Object> kwargMap,List<Object> varArgs){
  JinjavaInterpreter interpreter=JinjavaInterpreter.getCurrent();
  try (InterpreterScopeClosable c=interpreter.enterScope()){
    for (    Map.Entry<String,Object> scopeEntry : localContextScope.getScope().entrySet()) {
      if (scopeEntry.getValue() instanceof MacroFunction) {
        interpreter.getContext().addGlobalMacro((MacroFunction)scopeEntry.getValue());
      }
 else {
        interpreter.getContext().put(scopeEntry.getKey(),scopeEntry.getValue());
      }
    }
    for (    Map.Entry<String,Object> argEntry : argMap.entrySet()) {
      interpreter.getContext().put(argEntry.getKey(),argEntry.getValue());
    }
    interpreter.getContext().put("String_Node_Str",argMap);
    interpreter.getContext().put("String_Node_Str",varArgs);
    LengthLimitingStringBuilder result=new LengthLimitingStringBuilder(interpreter.getConfig().getMaxOutputSize());
    for (    Node node : content) {
      result.append(node.render(interpreter));
    }
    return result.toString();
  }
 }

Fixed version (ground truth):
@Override public Object doEvaluate(Map<String,Object> argMap,Map<String,Object> kwargMap,List<Object> varArgs){
  JinjavaInterpreter interpreter=JinjavaInterpreter.getCurrent();
  try (InterpreterScopeClosable c=interpreter.enterScope()){
    for (    Map.Entry<String,Object> scopeEntry : localContextScope.getScope().entrySet()) {
      if (scopeEntry.getValue() instanceof MacroFunction) {
        interpreter.getContext().addGlobalMacro((MacroFunction)scopeEntry.getValue());
      }
 else {
        interpreter.getContext().put(scopeEntry.getKey(),scopeEntry.getValue());
      }
    }
    for (    Map.Entry<String,Object> argEntry : argMap.entrySet()) {
      interpreter.getContext().put(argEntry.getKey(),argEntry.getValue());
    }
    interpreter.getContext().put("String_Node_Str",kwargMap);
    interpreter.getContext().put("String_Node_Str",varArgs);
    LengthLimitingStringBuilder result=new LengthLimitingStringBuilder(interpreter.getConfig().getMaxOutputSize());
    for (    Node node : content) {
      result.append(node.render(interpreter));
    }
    return result.toString();
  }
 }
Program: 55553
Project: 55553
Buggy source:
@Test public void itRetainsFieldNameCaseForUnknownToken(){
  interpreter.render("String_Node_Str");
  assertThat(interpreter.getErrors().get(0).getFieldName()).isEqualTo("String_Node_Str");
}

Fixed version (ground truth):
@Test public void itRetainsFieldNameCaseForUnknownToken(){
  JinjavaInterpreter interpreter=new Jinjava().newInterpreter();
  interpreter.render("String_Node_Str");
  assertThat(interpreter.getErrors().get(0).getFieldName()).isEqualTo("String_Node_Str");
}
Program: 55554
Project: 55554
Buggy source:
@Test public void itSetsFieldNameCaseForSyntaxErrorInFor(){
  RenderResult renderResult=jinjava.renderForResult("String_Node_Str",ImmutableMap.of());
  assertThat(renderResult.getErrors().get(0).getFieldName()).isEqualTo("String_Node_Str");
}

Fixed version (ground truth):
@Test public void itSetsFieldNameCaseForSyntaxErrorInFor(){
  RenderResult renderResult=new Jinjava().renderForResult("String_Node_Str",ImmutableMap.of());
  assertThat(renderResult.getErrors().get(0).getFieldName()).isEqualTo("String_Node_Str");
}
Program: 55555
Project: 55555
Buggy source:
private Token newToken(int kind){
  Token t=Token.newToken(kind,String.valueOf(is,lastStart,tokenLength),currLine);
  if (t instanceof TagToken) {
    if (config.isTrimBlocks() && is[currPost] == '\n') {
      ++currPost;
      ++tokenStart;
    }
    TagToken tt=(TagToken)t;
    if ("String_Node_Str".equals(tt.getTagName())) {
      inRaw=1;
      return tt;
    }
 else     if ("String_Node_Str".equals(tt.getTagName())) {
      inRaw=0;
      return tt;
    }
  }
  if (inRaw > 0 && t.getType() != TOKEN_FIXED) {
    return Token.newToken(TOKEN_FIXED,t.image,currLine);
  }
  return t;
}

Fixed version (ground truth):
private Token newToken(int kind){
  Token t=Token.newToken(kind,String.valueOf(is,lastStart,tokenLength),currLine);
  if (t instanceof TagToken) {
    if (config.isTrimBlocks() && currPost < length && is[currPost] == '\n') {
      ++currPost;
      ++tokenStart;
    }
    TagToken tt=(TagToken)t;
    if ("String_Node_Str".equals(tt.getTagName())) {
      inRaw=1;
      return tt;
    }
 else     if ("String_Node_Str".equals(tt.getTagName())) {
      inRaw=0;
      return tt;
    }
  }
  if (inRaw > 0 && t.getType() != TOKEN_FIXED) {
    return Token.newToken(TOKEN_FIXED,t.image,currLine);
  }
  return t;
}
Program: 55556
Project: 55556
Buggy source:
private List<Token> tokens(String fixture){
  TokenScanner t=fixture(fixture);
  List<Token> tokens=Lists.newArrayList();
  while (t.hasNext()) {
    tokens.add(t.next());
  }
  return tokens;
}

Fixed version (ground truth):
private List<Token> tokens(String fixture){
  TokenScanner t=fixture(fixture);
  return Lists.newArrayList(t);
}
Program: 55557
Project: 55557
Buggy source:
@Override public String interpret(TagNode tagNode,JinjavaInterpreter interpreter){
  HelperStringTokenizer helper=new HelperStringTokenizer(tagNode.getHelpers());
  if (!helper.hasNext()) {
    throw new InterpretException("String_Node_Str",tagNode.getLineNumber());
  }
  String path=StringUtils.trimToEmpty(helper.next());
  if (isPathInRenderStack(interpreter.getContext(),path)) {
    ENGINE_LOG.debug("String_Node_Str",path);
    return "String_Node_Str";
  }
  interpreter.getContext().put(INCLUDE_PATH_PROPERTY,path);
  String templateFile=interpreter.resolveString(path,tagNode.getLineNumber());
  try {
    String template=interpreter.getResource(templateFile);
    Node node=interpreter.parse(template);
    JinjavaInterpreter child=new JinjavaInterpreter(interpreter);
    interpreter.getContext().put(JinjavaInterpreter.INSERT_FLAG,true);
    return child.render(node);
  }
 catch (  IOException e) {
    throw new InterpretException(e.getMessage(),e,tagNode.getLineNumber());
  }
}

Fixed version (ground truth):
@Override public String interpret(TagNode tagNode,JinjavaInterpreter interpreter){
  HelperStringTokenizer helper=new HelperStringTokenizer(tagNode.getHelpers());
  if (!helper.hasNext()) {
    throw new InterpretException("String_Node_Str",tagNode.getLineNumber());
  }
  String path=StringUtils.trimToEmpty(helper.next());
  if (isPathInRenderStack(interpreter.getContext(),path)) {
    ENGINE_LOG.debug("String_Node_Str",path);
    return "String_Node_Str";
  }
  String templateFile=interpreter.resolveString(path,tagNode.getLineNumber());
  try {
    String template=interpreter.getResource(templateFile);
    Node node=interpreter.parse(template);
    JinjavaInterpreter child=new JinjavaInterpreter(interpreter);
    child.getContext().put(INCLUDE_PATH_PROPERTY,path);
    interpreter.getContext().put(JinjavaInterpreter.INSERT_FLAG,true);
    return child.render(node);
  }
 catch (  IOException e) {
    throw new InterpretException(e.getMessage(),e,tagNode.getLineNumber());
  }
}
Program: 55558
Project: 55558
Buggy source:
@Test public void itAvoidsNestedIncludeCycles() throws IOException {
  String result=jinjava.render(Resources.toString(Resources.getResource("String_Node_Str"),StandardCharsets.UTF_8),new HashMap<String,Object>());
  System.out.println(result);
  assertThat(result).containsSequence("String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
@Test public void itAvoidsNestedIncludeCycles() throws IOException {
  String result=jinjava.render(Resources.toString(Resources.getResource("String_Node_Str"),StandardCharsets.UTF_8),new HashMap<String,Object>());
  assertThat(result).containsSequence("String_Node_Str","String_Node_Str");
}
Program: 55559
Project: 55559
Buggy source:
@Override public Object filter(Object var,JinjavaInterpreter interpreter,String... args){
  if (var == null) {
    return var;
  }
  boolean reverse=false;
  if (args.length > 0) {
    reverse=BooleanUtils.toBoolean(args[0]);
  }
  boolean caseSensitive=false;
  if (args.length > 1) {
    caseSensitive=BooleanUtils.toBoolean(args[1]);
  }
  String attr=null;
  if (args.length > 2) {
    attr=args[2];
  }
  List<?> result=Lists.newArrayList(ObjectIterator.getLoop(var));
  Collections.sort(result,new ObjectComparator(reverse,caseSensitive,attr));
  return result;
}

Fixed version (ground truth):
@Override public Object filter(Object var,JinjavaInterpreter interpreter,String... args){
  if (var == null) {
    return var;
  }
  boolean reverse=false;
  if (args.length > 0) {
    reverse=BooleanUtils.toBoolean(args[0]);
  }
  boolean caseSensitive=false;
  if (args.length > 1) {
    caseSensitive=BooleanUtils.toBoolean(args[1]);
  }
  String attr=null;
  if (args.length > 2) {
    attr=args[2];
  }
  List<?> result=Lists.newArrayList(ObjectIterator.getLoop(var));
  Collections.sort(result,new ObjectComparator(interpreter,reverse,caseSensitive,attr));
  return result;
}
Program: 55560
Project: 55560
Buggy source:
@SuppressWarnings("String_Node_Str") @Override public int compare(Object o1,Object o2){
  int result=0;
  if (attr != null) {
    o1=new VariableChain(Lists.newArrayList(attr),o1).resolve();
    o2=new VariableChain(Lists.newArrayList(attr),o2).resolve();
  }
  if (o1 instanceof String && !caseSensitive) {
    result=((String)o1).compareToIgnoreCase((String)o2);
  }
 else   if (Comparable.class.isAssignableFrom(o1.getClass()) && Comparable.class.isAssignableFrom(o2.getClass())) {
    result=((Comparable<Object>)o1).compareTo(o2);
  }
  if (reverse) {
    result=-1 * result;
  }
  return result;
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") @Override public int compare(Object o1,Object o2){
  int result=0;
  if (variable != null) {
    o1=variable.resolve(o1);
    o2=variable.resolve(o2);
  }
  if (o1 instanceof String && !caseSensitive) {
    result=((String)o1).compareToIgnoreCase((String)o2);
  }
 else   if (Comparable.class.isAssignableFrom(o1.getClass()) && Comparable.class.isAssignableFrom(o2.getClass())) {
    result=((Comparable<Object>)o1).compareTo(o2);
  }
  if (reverse) {
    result=-1 * result;
  }
  return result;
}
Program: 55561
Project: 55561
Buggy source:
public ObjectComparator(boolean reverse,boolean caseSensitive,String attr){
  this.reverse=reverse;
  this.caseSensitive=caseSensitive;
  this.attr=attr;
}

Fixed version (ground truth):
public ObjectComparator(JinjavaInterpreter interpreter,boolean reverse,boolean caseSensitive,String attr){
  this.reverse=reverse;
  this.caseSensitive=caseSensitive;
  if (attr != null) {
    this.variable=new Variable(interpreter,"String_Node_Str" + attr);
  }
 else {
    this.variable=null;
  }
}
Program: 55562
Project: 55562
Buggy source:
@Override public String toString(){
  return "String_Node_Str" + date.getTime();
}

Fixed version (ground truth):
@Override public String toString(){
  return foo.toString();
}
Program: 55563
Project: 55563
Buggy source:
/** 
 * Parses a string in python strftime format, returning the equivalent string in java date time format.
 * @param strftime
 * @return date formatted as string
 */
private static String toJavaDateTimeFormat(String strftime){
  if (!StringUtils.contains(strftime,'%')) {
    return replaceL(strftime);
  }
  StringBuilder result=new StringBuilder();
  for (int i=0; i < strftime.length(); i++) {
    char c=strftime.charAt(i);
    if (c == '%') {
      c=strftime.charAt(++i);
      boolean stripLeadingZero=false;
      if (c == '-') {
        stripLeadingZero=true;
        c=strftime.charAt(++i);
      }
      if (stripLeadingZero) {
        result.append(CONVERSIONS.get(c).substring(1));
      }
 else {
        result.append(CONVERSIONS.get(c));
      }
    }
 else     if (Character.isLetter(c)) {
      result.append("String_Node_Str");
      while (Character.isLetter(c)) {
        result.append(c);
        c=strftime.charAt(++i);
      }
      result.append("String_Node_Str");
      --i;
    }
 else {
      result.append(c);
    }
  }
  return replaceL(result.toString());
}

Fixed version (ground truth):
/** 
 * Parses a string in python strftime format, returning the equivalent string in java date time format.
 * @param strftime
 * @return date formatted as string
 */
private static String toJavaDateTimeFormat(String strftime){
  if (!StringUtils.contains(strftime,'%')) {
    return replaceL(strftime);
  }
  StringBuilder result=new StringBuilder();
  for (int i=0; i < strftime.length(); i++) {
    char c=strftime.charAt(i);
    if (c == '%') {
      c=strftime.charAt(++i);
      boolean stripLeadingZero=false;
      if (c == '-') {
        stripLeadingZero=true;
        c=strftime.charAt(++i);
      }
      if (stripLeadingZero) {
        result.append(CONVERSIONS.get(c).substring(1));
      }
 else {
        result.append(CONVERSIONS.get(c));
      }
    }
 else     if (Character.isLetter(c)) {
      result.append("String_Node_Str");
      while (Character.isLetter(c)) {
        result.append(c);
        if (++i < strftime.length()) {
          c=strftime.charAt(i);
        }
 else {
          c=0;
        }
      }
      result.append("String_Node_Str");
      --i;
    }
 else {
      result.append(c);
    }
  }
  return replaceL(result.toString());
}
Program: 55564
Project: 55564
Buggy source:
public void setWaypoint(EWaypointType waypointType,ShortPoint2D position){
  if (waypointType != EWaypointType.DESTINATION && !isTargetSet()) {
    waypointType=EWaypointType.DESTINATION;
  }
  if (isSelected()) {
    drawWaypointLine(false);
  }
  if (waypointType == EWaypointType.DESTINATION) {
    Arrays.fill(waypoints,null);
  }
  ShortPoint2D closeReachableLocation=findClosestReachablePosition(waypointType,position);
  if (closeReachableLocation != null && !isWaypointFulfillingPreconditions(waypointType,closeReachableLocation)) {
    return;
  }
  waypoints[waypointType.ordinal()]=closeReachableLocation;
  if (isSelected()) {
    drawWaypointLine(true);
  }
}

Fixed version (ground truth):
public void setWaypoint(EWaypointType waypointType,ShortPoint2D position){
  if (waypointType != EWaypointType.DESTINATION && !isTargetSet()) {
    waypointType=EWaypointType.DESTINATION;
  }
  if (isSelected()) {
    drawWaypointLine(false);
  }
  if (waypointType == EWaypointType.DESTINATION) {
    Arrays.fill(waypoints,null);
  }
  ShortPoint2D closestReachableLocation=findClosestReachablePosition(waypointType,position);
  if (closestReachableLocation == null || !isWaypointFulfillingPreconditions(waypointType,closestReachableLocation)) {
    return;
  }
  waypoints[waypointType.ordinal()]=closestReachableLocation;
  if (isSelected()) {
    drawWaypointLine(true);
  }
}
Program: 55565
Project: 55565
Buggy source:
@Override public boolean isCoastReachable(ShortPoint2D position){
  return !HexGridArea.stream(position.x,position.y,0,2).filterBounds(width,height).filter((x,y) -> !landscapeGrid.getLandscapeTypeAt(x,y).isWater).isEmpty();
}

Fixed version (ground truth):
@Override public boolean isCoastReachable(ShortPoint2D position){
  return !HexGridArea.stream(position.x,position.y,0,3).filterBounds(width,height).filter((x,y) -> !landscapeGrid.getLandscapeTypeAt(x,y).isWater).isEmpty();
}
Program: 55566
Project: 55566
Buggy source:
private Set<Integer> occupyMilitaryBuildings(){
  Set<Integer> soldiersWithOrders=new HashSet<>();
  for (  ShortPoint2D militaryBuildingPosition : aiStatistics.getBuildingPositionsOfTypesForPlayer(EBuildingType.MILITARY_BUILDINGS,playerId)) {
    OccupyingBuilding militaryBuilding=(OccupyingBuilding)aiStatistics.getBuildingAt(militaryBuildingPosition);
    if (!militaryBuilding.isOccupied()) {
      ShortPoint2D door=militaryBuilding.getDoor();
      IMovable soldier=aiStatistics.getNearestSwordsmanOf(door,playerId);
      if (soldier != null && militaryBuilding.getPosition().getOnGridDistTo(soldier.getPosition()) > TOWER_SEARCH_RADIUS) {
        soldiersWithOrders.add(soldier.getID());
        sendMovableTo(soldier,door);
      }
    }
  }
  return soldiersWithOrders;
}

Fixed version (ground truth):
private Set<Integer> occupyMilitaryBuildings(){
  Set<Integer> soldiersWithOrders=new HashSet<>();
  for (  ShortPoint2D militaryBuildingPosition : aiStatistics.getBuildingPositionsOfTypesForPlayer(EBuildingType.MILITARY_BUILDINGS,playerId)) {
    OccupyingBuilding militaryBuilding=(OccupyingBuilding)aiStatistics.getBuildingAt(militaryBuildingPosition);
    if (!militaryBuilding.isOccupied()) {
      ShortPoint2D door=militaryBuilding.getDoor();
      IMovable soldier=aiStatistics.getNearestSwordsmanOf(door,playerId);
      if (soldier != null && militaryBuilding.getPosition().getOnGridDistTo(soldier.getPosition()) > TOWER_SEARCH_SOLDIERS_RADIUS) {
        soldiersWithOrders.add(soldier.getID());
        sendMovableTo(soldier,door);
      }
    }
  }
  return soldiersWithOrders;
}
Program: 55567
Project: 55567
Buggy source:
private void changeTowerSoldiers(ChangeTowerSoldiersGuiTask soldierTask){
  ShortPoint2D buildingPosition=soldierTask.getBuildingPos();
  OccupyingBuilding occupyingBuilding=(OccupyingBuilding)grid.getBuildingAt(buildingPosition.x,buildingPosition.y);
switch (soldierTask.getTaskType()) {
case FULL:
    occupyingBuilding.requestFullSoldiers();
  break;
case MORE:
occupyingBuilding.requestSoldier(soldierTask.getSoldierType());
break;
case ONE:
occupyingBuilding.releaseSoldiers();
break;
case LESS:
occupyingBuilding.releaseSoldier(soldierTask.getSoldierType());
break;
}
}

Fixed version (ground truth):
private void changeTowerSoldiers(ChangeTowerSoldiersGuiTask soldierTask){
  ShortPoint2D buildingPosition=soldierTask.getBuildingPos();
  OccupyingBuilding occupyingBuilding=(OccupyingBuilding)grid.getBuildingAt(buildingPosition.x,buildingPosition.y);
  if (occupyingBuilding == null) {
    return;
  }
switch (soldierTask.getTaskType()) {
case FULL:
    occupyingBuilding.requestFullSoldiers();
  break;
case MORE:
occupyingBuilding.requestSoldier(soldierTask.getSoldierType());
break;
case ONE:
occupyingBuilding.releaseSoldiers();
break;
case LESS:
occupyingBuilding.releaseSoldier(soldierTask.getSoldierType());
break;
}
}
Program: 55568
Project: 55568
Buggy source:
private void searchSoldiersIfNeeded(){
  if (!searchedSoldiers.isEmpty()) {
    if (dijkstraRequest == null) {
      dijkstraRequest=new DijkstraContinuableRequest(this,super.pos.x,super.pos.y,(short)1,Constants.TOWER_SEARCH_RADIUS);
    }
    dijkstraRequest.setSearchTypes(searchedSoldiers.getRequestedSearchTypes());
    Path path=super.grid.getDijkstra().find(dijkstraRequest);
    if (path != null) {
      ILogicMovable soldier=super.grid.getMovable(path.getTargetPosition());
      if (soldier != null) {
        IBuildingOccupyableMovable occupier=soldier.setOccupyableBuilding(this);
        if (occupier != null) {
          SoldierRequest soldierRequest=searchedSoldiers.removeOne(occupier.getMovableType().getSoldierType());
          comingSoldiers.put(occupier,soldierRequest);
          dijkstraRequest.reset();
        }
      }
    }
  }
}

Fixed version (ground truth):
private void searchSoldiersIfNeeded(){
  if (!searchedSoldiers.isEmpty()) {
    if (dijkstraRequest == null) {
      dijkstraRequest=new DijkstraContinuableRequest(this,super.pos.x,super.pos.y,(short)1,Constants.TOWER_SEARCH_SOLDIERS_RADIUS);
    }
    dijkstraRequest.setSearchTypes(searchedSoldiers.getRequestedSearchTypes());
    Path path=super.grid.getDijkstra().find(dijkstraRequest);
    if (path != null) {
      ILogicMovable soldier=super.grid.getMovable(path.getTargetPosition());
      if (soldier != null) {
        IBuildingOccupyableMovable occupier=soldier.setOccupyableBuilding(this);
        if (occupier != null) {
          SoldierRequest soldierRequest=searchedSoldiers.removeOne(occupier.getMovableType().getSoldierType());
          comingSoldiers.put(occupier,soldierRequest);
          dijkstraRequest.reset();
        }
      }
    }
  }
}
Program: 55569
Project: 55569
Buggy source:
/** 
 * Informs towers of the attackable in their search radius..
 * @param position The new position of the movable.
 * @param attackable The attackable that moved to the given position.
 * @param informFullArea if true, the full area is informed<br> if false, only the border of the area is informed.
 * @param informAttackable
 */
public void informObjectsAboutAttackable(ShortPoint2D position,IAttackable attackable,boolean informFullArea,boolean informAttackable){
  CoordinateStream area;
  if (informFullArea) {
    area=HexGridArea.stream(position.x,position.y,1,Constants.TOWER_SEARCH_RADIUS);
  }
 else {
    area=HexGridArea.streamBorder(position.x,position.y,Constants.TOWER_SEARCH_RADIUS - 1);
  }
  byte movableTeam=attackable.getPlayer().getTeamId();
  area.filterBounds(width,height).forEach((x,y) -> {
    IAttackable currTower=(IAttackable)getMapObjectAt(x,y,EMapObjectType.ATTACKABLE_TOWER);
    if (currTower != null && currTower.getPlayer().getTeamId() != movableTeam) {
      currTower.informAboutAttackable(attackable);
      if (informAttackable) {
        attackable.informAboutAttackable(currTower);
      }
    }
    IInformable currInformable=(IInformable)getMapObjectAt(x,y,EMapObjectType.INFORMABLE_MAP_OBJECT);
    if (currInformable != null) {
      currInformable.informAboutAttackable(attackable);
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Informs towers of the attackable in their search radius..
 * @param position The new position of the movable.
 * @param attackable The attackable that moved to the given position.
 * @param informFullArea if true, the full area is informed<br> if false, only the border of the area is informed.
 * @param informAttackable
 */
public void informObjectsAboutAttackable(ShortPoint2D position,IAttackable attackable,boolean informFullArea,boolean informAttackable){
  CoordinateStream area;
  if (informFullArea) {
    area=HexGridArea.stream(position.x,position.y,1,Constants.TOWER_ATTACKABLE_SEARCH_RADIUS);
  }
 else {
    area=HexGridArea.streamBorder(position.x,position.y,Constants.TOWER_ATTACKABLE_SEARCH_RADIUS - 1);
  }
  byte movableTeam=attackable.getPlayer().getTeamId();
  area.filterBounds(width,height).forEach((x,y) -> {
    IAttackable currTower=(IAttackable)getMapObjectAt(x,y,EMapObjectType.ATTACKABLE_TOWER);
    if (currTower != null && currTower.getPlayer().getTeamId() != movableTeam) {
      currTower.informAboutAttackable(attackable);
      if (informAttackable) {
        attackable.informAboutAttackable(currTower);
      }
    }
    IInformable currInformable=(IInformable)getMapObjectAt(x,y,EMapObjectType.INFORMABLE_MAP_OBJECT);
    if (currInformable != null) {
      currInformable.informAboutAttackable(attackable);
    }
  }
);
}
Program: 55570
Project: 55570
Buggy source:
@Override protected short getMaxSearchDistance(boolean isInTower){
  return isInTower ? Constants.TOWER_SEARCH_RADIUS : Constants.SOLDIER_SEARCH_RADIUS;
}

Fixed version (ground truth):
@Override protected short getMaxSearchDistance(boolean isInTower){
  return isInTower ? Constants.TOWER_ATTACKABLE_SEARCH_RADIUS : Constants.SOLDIER_SEARCH_RADIUS;
}
Program: 55571
Project: 55571
Buggy source:
private JSettlersGame.GameRunner createStartingGame(PlayerSetting[] playerSettings) throws MapLoadException {
  byte playerId=0;
  for (byte i=0; i < playerSettings.length; i++) {
    if (playerSettings[i].isAvailable()) {
      playerId=i;
      break;
    }
  }
  MapLoader mapCreator=MapUtils.getSpezialSumpf();
  JSettlersGame game=new JSettlersGame(mapCreator,2L,new OfflineNetworkConnector(),playerId,playerSettings);
  return (JSettlersGame.GameRunner)game.start();
}

Fixed version (ground truth):
private JSettlersGame.GameRunner createStartingGame(PlayerSetting[] playerSettings) throws MapLoadException {
  byte playerId=0;
  for (byte i=0; i < playerSettings.length; i++) {
    if (playerSettings[i].isAvailable()) {
      playerId=i;
      break;
    }
  }
  MapLoader mapCreator=MapUtils.getSpezialSumpf();
  JSettlersGame game=new JSettlersGame(mapCreator,1L,new OfflineNetworkConnector(),playerId,playerSettings);
  return (JSettlersGame.GameRunner)game.start();
}
Program: 55572
Project: 55572
Buggy source:
void onDirectorySelected();

Fixed version (ground truth):
void onDirectorySelected(File resourceDirectory);
Program: 55573
Project: 55573
Buggy source:
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState){
  LayoutInflater layoutInflater=LayoutInflater.from(getActivity());
  View view=layoutInflater.inflate(R.layout.dialog_directory_picker,null);
  ProgressBar progressBar=view.findViewById(R.id.progressBar);
  ListView listView=view.findViewById(R.id.listView);
  listView.setAdapter(directoryAdapter);
  listView.setOnItemClickListener((arg0,arg1,position,arg3) -> {
    directoryAdapter.positionSelected(position);
    setButtonState();
  }
);
  AlertDialog alertDialog=new AlertDialog.Builder(getActivity()).setTitle(R.string.resource_selection_dialog_title).setView(view).setPositiveButton(R.string.ok,null).create();
  alertDialog.setOnShowListener(dialog -> {
    Button button=alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
    button.setOnClickListener(v -> {
      button.setEnabled(false);
      progressBar.setVisibility(View.VISIBLE);
      setDirectoryTask=new SetResourcesTask(getActivity().getApplication()).execute(directoryAdapter.getCurrentDirectory());
    }
);
  }
);
  return alertDialog;
}

Fixed version (ground truth):
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState){
  LayoutInflater layoutInflater=LayoutInflater.from(getActivity());
  View view=layoutInflater.inflate(R.layout.dialog_directory_picker,null);
  ProgressBar progressBar=view.findViewById(R.id.progressBar);
  ListView listView=view.findViewById(R.id.listView);
  listView.setAdapter(directoryAdapter);
  listView.setOnItemClickListener((arg0,arg1,position,arg3) -> {
    directoryAdapter.positionSelected(position);
    setButtonState();
  }
);
  AlertDialog alertDialog=new AlertDialog.Builder(getActivity()).setTitle(R.string.resource_selection_dialog_title).setView(view).setPositiveButton(R.string.ok,null).create();
  alertDialog.setOnShowListener(dialog -> {
    Button button=alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
    button.setOnClickListener(v -> {
      setCancelable(false);
      listView.setEnabled(false);
      button.setEnabled(false);
      progressBar.setVisibility(View.VISIBLE);
      ((Listener)getParentFragment()).onDirectorySelected(directoryAdapter.getCurrentDirectory());
    }
);
  }
);
  return alertDialog;
}
Program: 55574
Project: 55574
Buggy source:
/** 
 * DirectoryPickerDialog.Listener implementation
 */
@Override public void onDirectorySelected(){
  viewModel.resourceDirectoryChosen();
}

Fixed version (ground truth):
/** 
 * DirectoryPickerDialog.Listener implementation
 */
@Override public void onDirectorySelected(File resourceDirectory){
  viewModel.resourceDirectoryChosen(resourceDirectory);
}
Program: 55575
Project: 55575
Buggy source:
@Override public void onActivityCreated(@Nullable Bundle savedInstanceState){
  super.onActivityCreated(savedInstanceState);
  viewModel.getResumeState().observe(this,this::updateResumeView);
  viewModel.getAreResourcesLoaded().observe(this,this::updateResourceView);
  viewModel.getAreResourcesLoaded().observe(this,newSinglePlayerButton::setEnabled);
  viewModel.getAreResourcesLoaded().observe(this,loadSinglePlayerButton::setEnabled);
  viewModel.getAreResourcesLoaded().observe(this,newMultiPlayerButton::setEnabled);
  viewModel.getAreResourcesLoaded().observe(this,joinMultiPlayerButton::setEnabled);
  viewModel.getShowSinglePlayer().observe(this,z -> mainMenuNavigator.showNewSinglePlayerPicker());
  viewModel.getShowLoadSinglePlayer().observe(this,z -> mainMenuNavigator.showLoadSinglePlayerPicker());
  viewModel.getShowMultiplayerPlayer().observe(this,z -> mainMenuNavigator.showNewMultiPlayerPicker());
  viewModel.getShowJoinMultiplayerPlayer().observe(this,z -> mainMenuNavigator.showJoinMultiPlayerPicker());
}

Fixed version (ground truth):
@Override public void onActivityCreated(@Nullable Bundle savedInstanceState){
  super.onActivityCreated(savedInstanceState);
  viewModel.getResumeState().observe(this,this::updateResumeView);
  viewModel.getAreResourcesLoaded().observe(this,this::updateResourceView);
  viewModel.getAreResourcesLoaded().observe(this,newSinglePlayerButton::setEnabled);
  viewModel.getAreResourcesLoaded().observe(this,loadSinglePlayerButton::setEnabled);
  viewModel.getAreResourcesLoaded().observe(this,newMultiPlayerButton::setEnabled);
  viewModel.getAreResourcesLoaded().observe(this,joinMultiPlayerButton::setEnabled);
  viewModel.getAreResourcesLoaded().observe(this,this::dismissResourceDialog);
  viewModel.getShowSinglePlayer().observe(this,z -> mainMenuNavigator.showNewSinglePlayerPicker());
  viewModel.getShowLoadSinglePlayer().observe(this,z -> mainMenuNavigator.showLoadSinglePlayerPicker());
  viewModel.getShowMultiplayerPlayer().observe(this,z -> mainMenuNavigator.showNewMultiPlayerPicker());
  viewModel.getShowJoinMultiplayerPlayer().observe(this,z -> mainMenuNavigator.showJoinMultiPlayerPicker());
}
Program: 55576
Project: 55576
Buggy source:
@Click(R.id.button_resources) void showDirectoryPicker(){
  if (ContextCompat.checkSelfPermission(getActivity(),Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
    requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},REQUEST_CODE_PERMISSION_STORAGE);
  }
 else {
    DirectoryPickerDialog.newInstance().show(getChildFragmentManager(),null);
  }
}

Fixed version (ground truth):
@Click(R.id.button_resources) void showDirectoryPicker(){
  if (ContextCompat.checkSelfPermission(getActivity(),Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
    requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},REQUEST_CODE_PERMISSION_STORAGE);
  }
 else {
    DirectoryPickerDialog.newInstance().show(getChildFragmentManager(),TAG_RESOURCE_DIALOG);
  }
}
Program: 55577
Project: 55577
Buggy source:
public void resourceDirectoryChosen(){
  boolean resourcesLoaded=androidResourcesLoader.setup();
  if (resourcesLoaded) {
    areResourcesLoaded.setValue(true);
  }
 else {
    throw new RuntimeException("String_Node_Str");
  }
}

Fixed version (ground truth):
public void resourceDirectoryChosen(File resourceDirectory){
  androidResourcesLoader.setResourcesDirectory(resourceDirectory.getAbsolutePath());
  Disposable resourceSetupSubscription=androidResourcesLoader.setupSingle().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(() -> {
    areResourcesLoaded.postValue(true);
  }
);
}
Program: 55578
Project: 55578
Buggy source:
NewFoWThread(){
  super("String_Node_Str");
  super.setDaemon(true);
  this.buffer=new byte[width][height];
  drawer=new CircleDrawer();
}

Fixed version (ground truth):
NewFoWThread(){
  super("String_Node_Str");
  super.setDaemon(true);
}
Program: 55579
Project: 55579
Buggy source:
@Override public final void run(){
  mySleep(500);
  while (!canceled) {
    if (enabled) {
      rebuildSight();
    }
    mySleep(800);
  }
}

Fixed version (ground truth):
@Override public final void run(){
  mySleep(500L);
  while (!canceled) {
    if (enabled) {
      rebuildSight();
    }
    mySleep(800L);
  }
}
Program: 55580
Project: 55580
Buggy source:
private void mySleep(int ms){
  try {
    Thread.sleep(ms);
  }
 catch (  InterruptedException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
private void mySleep(long ms){
  try {
    Thread.sleep(ms);
  }
 catch (  InterruptedException e) {
    e.printStackTrace();
  }
}
Program: 55581
Project: 55581
Buggy source:
private void rebuildSight(){
  drawer.setBuffer(buffer);
  for (int x=0; x < width; x++) {
    for (int y=0; y < height; y++) {
      byte currSight=sight[x][y];
      if (currSight >= CommonConstants.FOG_OF_WAR_EXPLORED) {
        byte newSight=(byte)(currSight - DIM_DOWN_SPEED);
        if (newSight < CommonConstants.FOG_OF_WAR_EXPLORED) {
          buffer[x][y]=CommonConstants.FOG_OF_WAR_EXPLORED;
        }
 else {
          buffer[x][y]=newSight;
        }
      }
 else {
        buffer[x][y]=sight[x][y];
      }
    }
  }
  ConcurrentLinkedQueue<? extends IViewDistancable> buildings=grid.getBuildingViewDistancables();
  applyViewDistances(buildings);
  ConcurrentLinkedQueue<? extends IViewDistancable> movables=grid.getMovableViewDistancables();
  applyViewDistances(movables);
  byte[][] temp=sight;
  sight=buffer;
  buffer=temp;
}

Fixed version (ground truth):
private void rebuildSight(){
  drawer.setBuffer(buffer);
  for (short x=0; x < width; x++) {
    for (short y=0; y < height; y++) {
      byte currSight=sight[x][y];
      if (currSight >= CommonConstants.FOG_OF_WAR_EXPLORED) {
        byte newSight=(byte)(currSight - DIM_DOWN_SPEED);
        if (newSight < CommonConstants.FOG_OF_WAR_EXPLORED) {
          buffer[x][y]=CommonConstants.FOG_OF_WAR_EXPLORED;
        }
 else {
          buffer[x][y]=newSight;
        }
      }
 else {
        buffer[x][y]=sight[x][y];
      }
    }
  }
  ConcurrentLinkedQueue<? extends IViewDistancable> buildings=grid.getBuildingViewDistancables();
  applyViewDistances(buildings);
  ConcurrentLinkedQueue<? extends IViewDistancable> movables=grid.getMovableViewDistancables();
  applyViewDistances(movables);
  byte[][] temp=sight;
  sight=buffer;
  buffer=temp;
}
Program: 55582
Project: 55582
Buggy source:
public static synchronized void stopAndClear(){
  if (uniIns != null) {
    if (MatchConstants.clock() != null) {
      MatchConstants.clock().remove(uniIns);
    }
    uniIns=null;
    try {
      Thread.sleep(100);
    }
 catch (    InterruptedException e) {
    }
  }
}

Fixed version (ground truth):
public static synchronized void stopAndClear(){
  if (uniIns != null) {
    if (MatchConstants.clock() != null) {
      MatchConstants.clock().remove(uniIns);
    }
    uniIns=null;
    try {
      Thread.sleep(100L);
    }
 catch (    InterruptedException e) {
    }
  }
}
Program: 55583
Project: 55583
Buggy source:
private void waitForAllPlayersStartFinished(INetworkConnector networkConnector){
  while (!networkConnector.haveAllPlayersStartFinished()) {
    try {
      Thread.sleep(5);
    }
 catch (    InterruptedException e) {
    }
  }
}

Fixed version (ground truth):
private void waitForAllPlayersStartFinished(INetworkConnector networkConnector){
  while (!networkConnector.haveAllPlayersStartFinished()) {
    try {
      Thread.sleep(5L);
    }
 catch (    InterruptedException e) {
    }
  }
}
Program: 55584
Project: 55584
Buggy source:
/** 
 * Waits until the   {@link #startingGameListener} has been set.
 */
private void waitForStartingGameListener(){
  while (startingGameListener == null) {
    try {
      Thread.sleep(5);
    }
 catch (    InterruptedException e) {
    }
  }
}

Fixed version (ground truth):
/** 
 * Waits until the   {@link #startingGameListener} has been set.
 */
private void waitForStartingGameListener(){
  while (startingGameListener == null) {
    try {
      Thread.sleep(5L);
    }
 catch (    InterruptedException e) {
    }
  }
}
Program: 55585
Project: 55585
Buggy source:
@Test public void testSpeed() throws MapLoadException, InterruptedException {
  MatchConstants.init(new NetworkTimer(true),0);
  MainGrid grid=MapUtils.getBigMap().loadMainGrid(null).getMainGrid();
  MainGridDataAccessor gridAccessor=new MainGridDataAccessor(grid);
  short width=gridAccessor.getWidth();
  short height=gridAccessor.getHeight();
  BitSet notBlockingSet=new BitSet(width * height);
  LandscapeGrid landscapeGrid=gridAccessor.getLandscapeGrid();
  for (short y=0; y < height; y++) {
    for (short x=0; x < width; x++) {
      notBlockingSet.set(x + y * width,!landscapeGrid.getLandscapeTypeAt(x,y).isBlocking);
    }
  }
  Thread.sleep(500);
  MilliStopWatch watch=new MilliStopWatch();
  PartitionCalculatorAlgorithm partitioner=new PartitionCalculatorAlgorithm(0,0,width,height,notBlockingSet,IBlockingProvider.DEFAULT_IMPLEMENTATION);
  partitioner.calculatePartitions();
  System.out.println("String_Node_Str" + partitioner.getNumberOfPartitions());
  watch.stop("String_Node_Str");
}

Fixed version (ground truth):
@Test public void testSpeed() throws MapLoadException, InterruptedException {
  MatchConstants.init(new NetworkTimer(true),0);
  MainGrid grid=MapUtils.getBigMap().loadMainGrid(null).getMainGrid();
  MainGridDataAccessor gridAccessor=new MainGridDataAccessor(grid);
  short width=gridAccessor.getWidth();
  short height=gridAccessor.getHeight();
  BitSet notBlockingSet=new BitSet(width * height);
  LandscapeGrid landscapeGrid=gridAccessor.getLandscapeGrid();
  for (short y=0; y < height; y++) {
    for (short x=0; x < width; x++) {
      notBlockingSet.set(x + y * width,!landscapeGrid.getLandscapeTypeAt(x,y).isBlocking);
    }
  }
  Thread.sleep(500L);
  MilliStopWatch watch=new MilliStopWatch();
  PartitionCalculatorAlgorithm partitioner=new PartitionCalculatorAlgorithm(0,0,width,height,notBlockingSet,IBlockingProvider.DEFAULT_IMPLEMENTATION);
  partitioner.calculatePartitions();
  System.out.println("String_Node_Str" + partitioner.getNumberOfPartitions());
  watch.stop("String_Node_Str");
}
Program: 55586
Project: 55586
Buggy source:
@Test public void testIfSavegameOfSavegameEqualsSavegame() throws IOException, MapLoadException, ClassNotFoundException, InterruptedException {
  final byte playerId=0;
  final int targetTimeMinutes=30;
  MapLoader map=MapUtils.getMountainlake();
  ReplayUtils.PlayMapResult directSavegameReplay=ReplayUtils.playMapToTargetTimes(map,playerId,targetTimeMinutes);
  assertDirectSavegameReplay(1,directSavegameReplay);
  MapLoader savegame=directSavegameReplay.getSavegames()[0];
  Thread.sleep(2000);
  System.out.println("String_Node_Str");
  MatchConstants.init(new NetworkTimer(true),0L);
  MainGridWithUiSettings loadedMap=savegame.loadMainGrid(PlayerSetting.createDefaultSettings(playerId,(byte)savegame.getMaxPlayers()));
  MainGrid mainGrid=loadedMap.getMainGrid();
  PlayerState playerState=loadedMap.getPlayerState(playerId);
  mainGrid.initForPlayer(playerId,playerState.getFogOfWar());
  MapLoader savegameOfSavegame;
  try {
    System.out.println("String_Node_Str");
    savegameOfSavegame=MapUtils.saveMainGrid(mainGrid,playerId,playerState.getUiState());
    assertNotNull(savegameOfSavegame);
  }
  finally {
    mainGrid.stopThreads();
    JSettlersGame.clearState();
  }
  MapUtils.compareMapFiles(savegame,savegameOfSavegame);
}

Fixed version (ground truth):
@Test public void testIfSavegameOfSavegameEqualsSavegame() throws IOException, MapLoadException, ClassNotFoundException, InterruptedException {
  final byte playerId=0;
  final int targetTimeMinutes=30;
  MapLoader map=MapUtils.getMountainlake();
  ReplayUtils.PlayMapResult directSavegameReplay=ReplayUtils.playMapToTargetTimes(map,playerId,targetTimeMinutes);
  assertDirectSavegameReplay(1,directSavegameReplay);
  MapLoader savegame=directSavegameReplay.getSavegames()[0];
  Thread.sleep(2000L);
  System.out.println("String_Node_Str");
  MatchConstants.init(new NetworkTimer(true),0L);
  MainGridWithUiSettings loadedMap=savegame.loadMainGrid(PlayerSetting.createDefaultSettings(playerId,(byte)savegame.getMaxPlayers()));
  MainGrid mainGrid=loadedMap.getMainGrid();
  PlayerState playerState=loadedMap.getPlayerState(playerId);
  mainGrid.initForPlayer(playerId,playerState.getFogOfWar());
  MapLoader savegameOfSavegame;
  try {
    System.out.println("String_Node_Str");
    savegameOfSavegame=MapUtils.saveMainGrid(mainGrid,playerId,playerState.getUiState());
    assertNotNull(savegameOfSavegame);
  }
  finally {
    mainGrid.stopThreads();
    JSettlersGame.clearState();
  }
  MapUtils.compareMapFiles(savegame,savegameOfSavegame);
}
Program: 55587
Project: 55587
Buggy source:
public static void main(String[] args) throws IOException, InterruptedException, MapLoadException, SwingResourceLoader.ResourceSetupException {
  CommonConstants.ENABLE_CONSOLE_LOGGING=true;
  OptionableProperties options=MainUtils.loadOptions(args);
  SwingManagedJSettlers.loadOptionalSettings(options);
  SwingResourceLoader.setup(options);
  int targetGameTimeMinutes=Integer.valueOf(options.getProperty("String_Node_Str"));
  String replayFileString=options.getProperty("String_Node_Str");
  if (replayFileString == null)   throw new IllegalArgumentException("String_Node_Str");
  File replayFile=new File(replayFileString);
  if (!replayFile.exists())   throw new FileNotFoundException("String_Node_Str" + replayFile);
  ReplayUtils.replayAndCreateSavegame(new ReplayUtils.ReplayFile(replayFile),targetGameTimeMinutes,"String_Node_Str");
  Thread.sleep(2000);
  System.exit(0);
}

Fixed version (ground truth):
public static void main(String[] args) throws IOException, InterruptedException, MapLoadException, SwingResourceLoader.ResourceSetupException {
  CommonConstants.ENABLE_CONSOLE_LOGGING=true;
  OptionableProperties options=MainUtils.loadOptions(args);
  SwingManagedJSettlers.loadOptionalSettings(options);
  SwingResourceLoader.setup(options);
  int targetGameTimeMinutes=Integer.valueOf(options.getProperty("String_Node_Str"));
  String replayFileString=options.getProperty("String_Node_Str");
  if (replayFileString == null)   throw new IllegalArgumentException("String_Node_Str");
  File replayFile=new File(replayFileString);
  if (!replayFile.exists())   throw new FileNotFoundException("String_Node_Str" + replayFile);
  ReplayUtils.replayAndCreateSavegame(new ReplayUtils.ReplayFile(replayFile),targetGameTimeMinutes,"String_Node_Str");
  Thread.sleep(2000L);
  System.exit(0);
}