Program: 37430
Project: 37430
Buggy source:
Responses.ResponseBody variables(Requests.VariablesArguments arguments) throws AbsentInformationException {
  Map<String,Object> options=variableFormatter.getDefaultOptions();
  boolean showStaticVariables=true;
  boolean showFullyQualifiedNames=true;
  if (arguments.format != null && arguments.format.hex) {
    options.put(NumericFormatter.NUMERIC_FORMAT_OPTION,NumericFormatEnum.HEX);
  }
  if (showFullyQualifiedNames) {
    options.put(SimpleTypeFormatter.QUALIFIED_CLASS_NAME_OPTION,showFullyQualifiedNames);
  }
  List<Types.Variable> list=new ArrayList<>();
  List<Variable> variables;
  Object obj=this.objectPool.getObjectById(arguments.variablesReference);
  ThreadReference thread;
  if (obj instanceof StackFrameScope) {
    StackFrame frame=((StackFrameScope)obj).getStackFrame();
    thread=frame.thread();
    variables=VariableUtils.listLocalVariables(frame);
    Variable thisVariable=VariableUtils.getThisVariable(frame);
    if (thisVariable != null) {
      variables.add(thisVariable);
    }
    if (showStaticVariables && frame.location().method().isStatic()) {
      variables.addAll(VariableUtils.listStaticVariables(frame));
    }
  }
 else   if (obj instanceof ThreadObjectReference) {
    ObjectReference currentObj=((ThreadObjectReference)obj).getObject();
    thread=((ThreadObjectReference)obj).getThread();
    if (arguments.count > 0) {
      variables=VariableUtils.listFieldVariables(currentObj,arguments.start,arguments.count);
    }
 else {
      variables=VariableUtils.listFieldVariables(currentObj,showStaticVariables);
    }
  }
 else {
    throw new IllegalArgumentException(String.format("String_Node_Str",arguments.variablesReference));
  }
  Set<String> duplicateNames=getDuplicateNames(variables.stream().map(var -> var.name).collect(Collectors.toList()));
  Map<Variable,String> variableNameMap=new HashMap<>();
  if (!duplicateNames.isEmpty()) {
    Map<String,List<Variable>> duplicateVars=variables.stream().filter(var -> duplicateNames.contains(var.name)).collect(Collectors.groupingBy(var -> var.name,Collectors.toList()));
    duplicateVars.forEach((k,duplicateVariables) -> {
      Set<String> declarationTypeNames=new HashSet<>();
      boolean declarationTypeNameConflict=false;
      for (      Variable javaVariable : duplicateVariables) {
        Type declarationType=javaVariable.getDeclaringType();
        if (declarationType != null) {
          String declarationTypeName=this.variableFormatter.typeToString(declarationType,options);
          String compositeName=String.format("String_Node_Str",javaVariable.name,declarationTypeName);
          if (!declarationTypeNames.add(compositeName)) {
            declarationTypeNameConflict=true;
            break;
          }
          variableNameMap.put(javaVariable,compositeName);
        }
      }
      if (declarationTypeNameConflict) {
        for (        Variable javaVariable : duplicateVariables) {
          Type declarationType=javaVariable.getDeclaringType();
          if (declarationType != null) {
            variableNameMap.put(javaVariable,String.format("String_Node_Str",javaVariable.name,declarationType.name()));
          }
        }
      }
    }
);
  }
  for (  Variable javaVariable : variables) {
    Value value=javaVariable.value;
    String name=javaVariable.name;
    if (variableNameMap.containsKey(javaVariable)) {
      name=variableNameMap.get(javaVariable);
    }
    int referenceId=0;
    if (value instanceof ObjectReference && VariableUtils.hasChildren(value,showStaticVariables)) {
      ThreadObjectReference threadObjectReference=new ThreadObjectReference(thread,(ObjectReference)value);
      referenceId=this.objectPool.addObject(thread.uniqueID(),threadObjectReference);
    }
    Types.Variable typedVariables=new Types.Variable(name,variableFormatter.valueToString(value,options),variableFormatter.typeToString(value == null ? null : value.type(),options),referenceId,null);
    if (javaVariable.value instanceof ArrayReference) {
      typedVariables.indexedVariables=((ArrayReference)javaVariable.value).length();
    }
    list.add(typedVariables);
  }
  return new Responses.VariablesResponseBody(list);
}

Fixed version (ground truth):
Responses.ResponseBody variables(Requests.VariablesArguments arguments) throws AbsentInformationException {
  Map<String,Object> options=variableFormatter.getDefaultOptions();
  boolean showStaticVariables=true;
  boolean showFullyQualifiedNames=true;
  if (arguments.format != null && arguments.format.hex) {
    options.put(NumericFormatter.NUMERIC_FORMAT_OPTION,NumericFormatEnum.HEX);
  }
  if (showFullyQualifiedNames) {
    options.put(SimpleTypeFormatter.QUALIFIED_CLASS_NAME_OPTION,showFullyQualifiedNames);
  }
  List<Types.Variable> list=new ArrayList<>();
  List<Variable> variables;
  Object obj=this.objectPool.getObjectById(arguments.variablesReference);
  if (obj == null) {
    return new Responses.VariablesResponseBody(list);
  }
  ThreadReference thread;
  if (obj instanceof StackFrameScope) {
    StackFrame frame=((StackFrameScope)obj).getStackFrame();
    thread=frame.thread();
    variables=VariableUtils.listLocalVariables(frame);
    Variable thisVariable=VariableUtils.getThisVariable(frame);
    if (thisVariable != null) {
      variables.add(thisVariable);
    }
    if (showStaticVariables && frame.location().method().isStatic()) {
      variables.addAll(VariableUtils.listStaticVariables(frame));
    }
  }
 else   if (obj instanceof ThreadObjectReference) {
    ObjectReference currentObj=((ThreadObjectReference)obj).getObject();
    thread=((ThreadObjectReference)obj).getThread();
    if (arguments.count > 0) {
      variables=VariableUtils.listFieldVariables(currentObj,arguments.start,arguments.count);
    }
 else {
      variables=VariableUtils.listFieldVariables(currentObj,showStaticVariables);
    }
  }
 else {
    throw new IllegalArgumentException(String.format("String_Node_Str",arguments.variablesReference));
  }
  Set<String> duplicateNames=getDuplicateNames(variables.stream().map(var -> var.name).collect(Collectors.toList()));
  Map<Variable,String> variableNameMap=new HashMap<>();
  if (!duplicateNames.isEmpty()) {
    Map<String,List<Variable>> duplicateVars=variables.stream().filter(var -> duplicateNames.contains(var.name)).collect(Collectors.groupingBy(var -> var.name,Collectors.toList()));
    duplicateVars.forEach((k,duplicateVariables) -> {
      Set<String> declarationTypeNames=new HashSet<>();
      boolean declarationTypeNameConflict=false;
      for (      Variable javaVariable : duplicateVariables) {
        Type declarationType=javaVariable.getDeclaringType();
        if (declarationType != null) {
          String declarationTypeName=this.variableFormatter.typeToString(declarationType,options);
          String compositeName=String.format("String_Node_Str",javaVariable.name,declarationTypeName);
          if (!declarationTypeNames.add(compositeName)) {
            declarationTypeNameConflict=true;
            break;
          }
          variableNameMap.put(javaVariable,compositeName);
        }
      }
      if (declarationTypeNameConflict) {
        for (        Variable javaVariable : duplicateVariables) {
          Type declarationType=javaVariable.getDeclaringType();
          if (declarationType != null) {
            variableNameMap.put(javaVariable,String.format("String_Node_Str",javaVariable.name,declarationType.name()));
          }
        }
      }
    }
);
  }
  for (  Variable javaVariable : variables) {
    Value value=javaVariable.value;
    String name=javaVariable.name;
    if (variableNameMap.containsKey(javaVariable)) {
      name=variableNameMap.get(javaVariable);
    }
    int referenceId=0;
    if (value instanceof ObjectReference && VariableUtils.hasChildren(value,showStaticVariables)) {
      ThreadObjectReference threadObjectReference=new ThreadObjectReference(thread,(ObjectReference)value);
      referenceId=this.objectPool.addObject(thread.uniqueID(),threadObjectReference);
    }
    Types.Variable typedVariables=new Types.Variable(name,variableFormatter.valueToString(value,options),variableFormatter.typeToString(value == null ? null : value.type(),options),referenceId,null);
    if (javaVariable.value instanceof ArrayReference) {
      typedVariables.indexedVariables=((ArrayReference)javaVariable.value).length();
    }
    list.add(typedVariables);
  }
  return new Responses.VariablesResponseBody(list);
}