nus-yam/ex-repair huggingface dataset:
Program: 170933
Project: 170933
Buggy source:
public PaletteButton(Context context,int shortCutId,int imageId,int descriptionId,String code){
  super(context);
  final int buttonSize=context.getResources().getDimensionPixelSize(R.dimen.activity_toolbar_height) - 2 * context.getResources().getDimensionPixelSize(R.dimen.activity_palette_vertical_padding);
  setLayoutParams(new ViewGroup.LayoutParams(buttonSize,buttonSize));
  TypedValue outValue=new TypedValue();
  context.getTheme().resolveAttribute(R.attr.selectableItemBackground,outValue,true);
  setBackgroundResource(outValue.resourceId);
  setImageResource(imageId);
  if (shortCutId != Palette.NO_BUTTON) {
    shortCut=context.getResources().getString(shortCutId);
  }
  if (descriptionId != Palette.NO_BUTTON) {
    String description=context.getResources().getString(descriptionId);
    if (shortCut != null) {
      description+="String_Node_Str";
      description+=shortCut;
      description+="String_Node_Str";
    }
    setContentDescription(description);
    setLongClickable(true);
  }
  this.code=code;
  enableAll();
  ViewUtils.setImageButtonColorAttr(getContext(),this,isEnabled() ? R.attr.colorMicroMathIcon : R.attr.colorPrimaryDark);
}

Fixed version (ground truth):
public PaletteButton(Context context,String group,String code,int imageId,int descriptionId,int shortCutId){
  super(context);
  final int buttonSize=context.getResources().getDimensionPixelSize(R.dimen.activity_toolbar_height) - 2 * context.getResources().getDimensionPixelSize(R.dimen.activity_palette_vertical_padding);
  setLayoutParams(new ViewGroup.LayoutParams(buttonSize,buttonSize));
  TypedValue outValue=new TypedValue();
  context.getTheme().resolveAttribute(R.attr.selectableItemBackground,outValue,true);
  setBackgroundResource(outValue.resourceId);
  this.group=group;
  this.code=code;
  this.imageId=imageId;
  if (hasImage()) {
    setImageResource(imageId);
  }
  String shortCut=null;
  if (shortCutId != Palette.NO_BUTTON) {
    shortCut=context.getResources().getString(shortCutId);
  }
  if (descriptionId != Palette.NO_BUTTON) {
    String description=context.getResources().getString(descriptionId);
    if (shortCut != null) {
      description+="String_Node_Str";
      description+=shortCut;
      description+="String_Node_Str";
    }
    setContentDescription(description);
    setLongClickable(true);
  }
  enableAll();
  ViewUtils.setImageButtonColorAttr(getContext(),this,isEnabled() ? R.attr.colorMicroMathIcon : R.attr.colorPrimaryDark);
}
Program: 170934
Project: 170934
Buggy source:
protected void onSaveFinished(){
}

Fixed version (ground truth):
protected void onSaveFinished(){
  setInOperation(false,null);
}
Program: 170935
Project: 170935
Buggy source:
@Override protected void onSaveFinished(){
  ((MainActivity)activity).selectWorksheet(INVALID_ACTION_ID);
}

Fixed version (ground truth):
@Override protected void onSaveFinished(){
  super.onSaveFinished();
  ((MainActivity)activity).selectWorksheet(INVALID_ACTION_ID);
}
Program: 170936
Project: 170936
Buggy source:
public ValueType sqrt(CalculatedValue g){
  if (g.isComplex() || (g.isReal() && g.real < 0)) {
    if (g.unit != null) {
      invalidate(ErrorType.INCOMPATIBLE_UNIT);
    }
    return setComplexValue(g.getComplex().sqrt());
  }
 else {
    if (g.unit != null) {
      unit=g.unit.root(2);
    }
    return setValue(FastMath.sqrt(g.real));
  }
}

Fixed version (ground truth):
public ValueType sqrt(CalculatedValue g){
  if (g.isComplex() || (g.isReal() && g.real < 0)) {
    if (g.unit != null) {
      invalidate(ErrorType.INCOMPATIBLE_UNIT);
    }
 else {
      unit=null;
    }
    return setComplexValue(g.getComplex().sqrt());
  }
 else {
    if (g.unit != null) {
      unit=g.unit.root(2);
    }
 else {
      unit=null;
    }
    return setValue(FastMath.sqrt(g.real));
  }
}
Program: 170937
Project: 170937
Buggy source:
public ValueType add(CalculatedValue f,CalculatedValue g){
  if (unitExists(f,g)) {
    if (f.unit == null || g.unit == null || !f.unit.isCompatible(g.unit)) {
      return invalidate(ErrorType.INCOMPATIBLE_UNIT);
    }
    unit=f.unit;
  }
  if (f.isComplex() || g.isComplex()) {
    return setComplexValue(f.real + g.real,f.imaginary + g.imaginary);
  }
 else {
    return setValue(f.real + g.real);
  }
}

Fixed version (ground truth):
public ValueType add(CalculatedValue f,CalculatedValue g){
  if (unitExists(f,g)) {
    if (f.unit == null || g.unit == null || !f.unit.isCompatible(g.unit)) {
      return invalidate(ErrorType.INCOMPATIBLE_UNIT);
    }
    unit=f.unit;
  }
 else {
    unit=null;
  }
  if (f.isComplex() || g.isComplex()) {
    return setComplexValue(f.real + g.real,f.imaginary + g.imaginary);
  }
 else {
    return setValue(f.real + g.real);
  }
}
Program: 170938
Project: 170938
Buggy source:
public ValueType nthRoot(CalculatedValue g,int n){
  try {
    if (g.unit != null) {
      unit=g.unit.root(n);
    }
    final List<Complex> roots=g.getComplex().nthRoot(n);
    for (    Complex root : roots) {
      if (FastMath.abs(root.getImaginary()) < 1E-15) {
        return setValue(root.getReal());
      }
    }
    if (!roots.isEmpty()) {
      return setComplexValue(roots.get(0));
    }
  }
 catch (  Exception ex) {
  }
  return invalidate(ErrorType.NOT_A_NUMBER);
}

Fixed version (ground truth):
public ValueType nthRoot(CalculatedValue g,int n){
  try {
    if (g.unit != null) {
      unit=g.unit.root(n);
    }
 else {
      unit=null;
    }
    final List<Complex> roots=g.getComplex().nthRoot(n);
    for (    Complex root : roots) {
      if (FastMath.abs(root.getImaginary()) < 1E-15) {
        return setValue(root.getReal());
      }
    }
    if (!roots.isEmpty()) {
      return setComplexValue(roots.get(0));
    }
  }
 catch (  Exception ex) {
  }
  return invalidate(ErrorType.NOT_A_NUMBER);
}
Program: 170939
Project: 170939
Buggy source:
public ValueType subtract(CalculatedValue f,CalculatedValue g){
  if (unitExists(f,g)) {
    if (f.unit == null || g.unit == null || !f.unit.isCompatible(g.unit)) {
      return invalidate(ErrorType.INCOMPATIBLE_UNIT);
    }
    unit=f.unit;
  }
  if (f.isComplex() || g.isComplex()) {
    return setComplexValue(f.real - g.real,f.imaginary - g.imaginary);
  }
 else {
    return setValue(f.real - g.real);
  }
}

Fixed version (ground truth):
public ValueType subtract(CalculatedValue f,CalculatedValue g){
  if (unitExists(f,g)) {
    if (f.unit == null || g.unit == null || !f.unit.isCompatible(g.unit)) {
      return invalidate(ErrorType.INCOMPATIBLE_UNIT);
    }
    unit=f.unit;
  }
 else {
    unit=null;
  }
  if (f.isComplex() || g.isComplex()) {
    return setComplexValue(f.real - g.real,f.imaginary - g.imaginary);
  }
 else {
    return setValue(f.real - g.real);
  }
}
Program: 170940
Project: 170940
Buggy source:
public ValueType pow(CalculatedValue f,CalculatedValue g){
  if (f.isComplex() || g.isComplex()) {
    if (f.unit != null) {
      invalidate(ErrorType.INCOMPATIBLE_UNIT);
    }
    return setComplexValue(f.getComplex().pow(g.getComplex()));
  }
 else {
    if (f.unit != null) {
      final int n=(int)g.real;
      if ((double)n != g.real) {
        invalidate(ErrorType.INCOMPATIBLE_UNIT);
      }
 else {
        unit=f.unit.pow(n);
      }
    }
    return setValue(FastMath.pow(f.real,g.real));
  }
}

Fixed version (ground truth):
public ValueType pow(CalculatedValue f,CalculatedValue g){
  if (g.unit != null) {
    invalidate(ErrorType.INCOMPATIBLE_UNIT);
  }
  if (f.isComplex() || g.isComplex()) {
    if (f.unit != null) {
      invalidate(ErrorType.INCOMPATIBLE_UNIT);
    }
 else {
      unit=null;
    }
    return setComplexValue(f.getComplex().pow(g.getComplex()));
  }
 else {
    if (f.unit != null) {
      final int n=g.getInteger();
      if ((double)n != g.real) {
        invalidate(ErrorType.INCOMPATIBLE_UNIT);
      }
 else {
        unit=f.unit.pow(n);
      }
    }
 else {
      unit=null;
    }
    return setValue(FastMath.pow(f.real,g.real));
  }
}
Program: 170941
Project: 170941
Buggy source:
public ValueType divide(CalculatedValue f,CalculatedValue g){
  if (unitExists(f,g)) {
    if (f.unit == null) {
      unit=g.unit.inverse();
    }
 else     if (g.unit == null) {
      unit=f.unit;
    }
 else     if (f.unit.equals(g.unit)) {
      unit=null;
    }
 else {
      unit=f.unit.divide(g.unit);
    }
  }
  if (f.isComplex() || g.isComplex()) {
    final double c=g.real;
    final double d=g.imaginary;
    if (FastMath.abs(c) < FastMath.abs(d)) {
      final double q=c / d;
      final double denominator=c * q + d;
      return setComplexValue((f.real * q + f.imaginary) / denominator,(f.imaginary * q - f.real) / denominator);
    }
 else {
      final double q=d / c;
      final double denominator=d * q + c;
      return setComplexValue((f.imaginary * q + f.real) / denominator,(f.imaginary - f.real * q) / denominator);
    }
  }
 else {
    return setValue(f.real / g.real);
  }
}

Fixed version (ground truth):
public ValueType divide(CalculatedValue f,CalculatedValue g){
  if (unitExists(f,g)) {
    if (f.unit == null) {
      unit=g.unit.inverse();
    }
 else     if (g.unit == null) {
      unit=f.unit;
    }
 else     if (f.unit.equals(g.unit)) {
      unit=null;
    }
 else {
      unit=f.unit.divide(g.unit);
    }
  }
 else {
    unit=null;
  }
  if (f.isComplex() || g.isComplex()) {
    final double c=g.real;
    final double d=g.imaginary;
    if (FastMath.abs(c) < FastMath.abs(d)) {
      final double q=c / d;
      final double denominator=c * q + d;
      return setComplexValue((f.real * q + f.imaginary) / denominator,(f.imaginary * q - f.real) / denominator);
    }
 else {
      final double q=d / c;
      final double denominator=d * q + c;
      return setComplexValue((f.imaginary * q + f.real) / denominator,(f.imaginary - f.real * q) / denominator);
    }
  }
 else {
    return setValue(f.real / g.real);
  }
}
Program: 170942
Project: 170942
Buggy source:
/** 
 * Conversion methods
 */
public String toString(){
  return valueType.toString() + "String_Node_Str" + real+ "String_Node_Str"+ imaginary+ "String_Node_Str";
}

Fixed version (ground truth):
/** 
 * Conversion methods
 */
public String toString(){
  return valueType.toString() + "String_Node_Str" + real+ "String_Node_Str"+ imaginary+ "String_Node_Str"+ (unit == null ? "String_Node_Str" : unit.toString());
}
Program: 170943
Project: 170943
Buggy source:
public void prepare(AppCompatActivity activity,FormulaChangeIf termChangeIf){
  super.prepare(SymbolType.EMPTY,activity,termChangeIf);
  plotParameters.initialize(getContext());
  if (colorMapView != null) {
    colorMapView.prepare(activity,termChangeIf);
  }
}

Fixed version (ground truth):
public void prepare(AppCompatActivity activity,FormulaChangeIf termChangeIf){
  super.prepare(SymbolType.EMPTY,activity,termChangeIf);
  getPaint().setColor(CompatUtils.getThemeColorAttr(activity,R.attr.colorFormulaNormal));
  plotParameters.initialize(getContext());
  if (colorMapView != null) {
    colorMapView.prepare(activity,termChangeIf);
  }
}
Program: 170944
Project: 170944
Buggy source:
FileListView(Commander c){
  commander=c;
  listView=(ListView)commander.findViewById(R.id.fman_list_view);
  listView.setItemsCanFocus(false);
  listView.setFocusableInTouchMode(true);
  listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
  listView.setOnItemClickListener(this);
  if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
    TypedValue outValue=new TypedValue();
    commander.getContext().getTheme().resolveAttribute(R.attr.selectableItemBackground,outValue,true);
    listView.setSelector(outValue.resourceId);
  }
  commander.registerForContextMenu(listView);
  statusPanel=(LinearLayout)commander.findViewById(R.id.fman_status_panel);
  statusBar=(TextView)commander.findViewById(R.id.fman_status_bar);
}

Fixed version (ground truth):
FileListView(Commander c){
  commander=c;
  listView=(ListView)commander.findViewById(R.id.fman_list_view);
  listView.setItemsCanFocus(false);
  listView.setFocusableInTouchMode(true);
  listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
  listView.setOnItemClickListener(this);
  if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
    TypedValue outValue=new TypedValue();
    commander.getContext().getTheme().resolveAttribute(R.attr.selectableItemBackground,outValue,true);
    listView.setSelector(outValue.resourceId);
  }
  commander.registerForContextMenu(listView);
  statusPanel=(LinearLayout)commander.findViewById(R.id.fman_status_panel);
  statusPanelDivider=commander.findViewById(R.id.fman_status_panel_divider);
  statusBar=(TextView)commander.findViewById(R.id.fman_status_bar);
}
Program: 170945
Project: 170945
Buggy source:
public final void Navigate(Uri uri,String posTo){
  try {
    currentPosition=-1;
    listView.clearChoices();
    listView.invalidateViews();
    AdapterIf ca_new=null, ca=(AdapterIf)listView.getAdapter();
    String scheme=uri.getScheme();
    if (scheme == null) {
      scheme="String_Node_Str";
    }
    if (ca == null || !scheme.equals(ca.getScheme())) {
      ca_new=commander.CreateAdapter(uri);
      listView.setAdapter((ListAdapter)ca_new);
      applySettings();
      ca=ca_new;
    }
    ca.setMode(AdapterIf.MODE_SORTING | AdapterIf.MODE_SORT_DIR,adapterMode);
    ca.readSource(uri,Integer.toBinaryString(0) + (posTo == null ? "String_Node_Str" : posTo));
    statusPanel.setVisibility((ca instanceof AdapterHome) ? View.GONE : View.VISIBLE);
    statusBar.setText(ca.toString());
    ViewUtils.Debug(this,"String_Node_Str" + ca.getUri().getPath());
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
public final void Navigate(Uri uri,String posTo){
  try {
    currentPosition=-1;
    listView.clearChoices();
    listView.invalidateViews();
    AdapterIf ca_new=null, ca=(AdapterIf)listView.getAdapter();
    String scheme=uri.getScheme();
    if (scheme == null) {
      scheme="String_Node_Str";
    }
    if (ca == null || !scheme.equals(ca.getScheme())) {
      ca_new=commander.CreateAdapter(uri);
      listView.setAdapter((ListAdapter)ca_new);
      applySettings();
      ca=ca_new;
    }
    ca.setMode(AdapterIf.MODE_SORTING | AdapterIf.MODE_SORT_DIR,adapterMode);
    ca.readSource(uri,Integer.toBinaryString(0) + (posTo == null ? "String_Node_Str" : posTo));
    statusPanel.setVisibility((ca instanceof AdapterHome) ? View.GONE : View.VISIBLE);
    statusPanelDivider.setVisibility(statusPanel.getVisibility());
    statusBar.setText(ca.toString());
    ViewUtils.Debug(this,"String_Node_Str" + ca.getUri().getPath());
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}
Program: 170946
Project: 170946
Buggy source:
public void prepare(AppCompatActivity activity,FormulaChangeIf termChangeIf){
  this.prepare(null);
  super.prepare(SymbolType.EMPTY,activity,termChangeIf);
}

Fixed version (ground truth):
public void prepare(AppCompatActivity activity,FormulaChangeIf termChangeIf){
  this.prepare(null);
  super.prepare(SymbolType.EMPTY,activity,termChangeIf);
  getPaint().setColor(CompatUtils.getThemeColorAttr(activity,R.attr.colorFormulaNormal));
}
Program: 170947
Project: 170947
Buggy source:
public boolean onScaleBegin(ScaleGestureDetector detector){
  isScaled=true;
  scale=1.0f;
  mEdgeGlowLeft.onRelease();
  mEdgeGlowRight.onRelease();
  mEdgeGlowTop.onRelease();
  mEdgeGlowBottom.onRelease();
  return true;
}

Fixed version (ground truth):
public boolean onScaleBegin(ScaleGestureDetector detector){
  if (scaleDetectorActive) {
    isScaled=true;
    scale=1.0f;
    mEdgeGlowLeft.onRelease();
    mEdgeGlowRight.onRelease();
    mEdgeGlowTop.onRelease();
    mEdgeGlowBottom.onRelease();
  }
 else {
    isScaled=false;
  }
  return isScaled;
}
Program: 170948
Project: 170948
Buggy source:
/** 
 * Scrolls the view to make the area defined by <code>top</code> and <code>bottom</code> visible. This method attempts to give the focus to a component visible in this area. If no component can be focused in the new visible area, the focus is reclaimed by this scrollview.
 * @param direction the scroll direction: {@link android.view.View#FOCUS_UP} to go upward{@link android.view.View#FOCUS_DOWN} to downward
 * @param top       the top offset of the new area to be made visible
 * @param bottom    the bottom offset of the new area to be made visible
 * @return true if the key event is consumed by this method, false otherwise
 */
private boolean scrollAndFocus(int directionY,int top,int bottom,int directionX,int left,int right){
  boolean handled=true;
  int height=getHeight();
  int containerTop=getScrollY();
  int containerBottom=containerTop + height;
  boolean up=directionY == View.FOCUS_UP;
  int width=getWidth();
  int containerLeft=getScrollX();
  int containerRight=containerLeft + width;
  boolean leftwards=directionX == View.FOCUS_UP;
  View newFocused=findFocusableViewInBounds(up,top,bottom,leftwards,left,right);
  if (newFocused == null) {
    newFocused=this;
  }
  if ((top >= containerTop && bottom <= containerBottom) || (left >= containerLeft && right <= containerRight)) {
    handled=false;
  }
 else {
    int deltaY=up ? (top - containerTop) : (bottom - containerBottom);
    int deltaX=leftwards ? (left - containerLeft) : (right - containerRight);
    doScroll(deltaX,deltaY);
  }
  return handled;
}

Fixed version (ground truth):
/** 
 * Scrolls the view to make the area defined by <code>top</code> and <code>bottom</code> visible. This method attempts to give the focus to a component visible in this area. If no component can be focused in the new visible area, the focus is reclaimed by this scrollview.
 * @param directionY the scroll direction: {@link android.view.View#FOCUS_UP} to go upward{@link android.view.View#FOCUS_DOWN} to downward
 * @param top       the top offset of the new area to be made visible
 * @param bottom    the bottom offset of the new area to be made visible
 * @return true if the key event is consumed by this method, false otherwise
 */
private boolean scrollAndFocus(int directionY,int top,int bottom,int directionX,int left,int right){
  boolean handled=true;
  int height=getHeight();
  int containerTop=getScrollY();
  int containerBottom=containerTop + height;
  boolean up=directionY == View.FOCUS_UP;
  int width=getWidth();
  int containerLeft=getScrollX();
  int containerRight=containerLeft + width;
  boolean leftwards=directionX == View.FOCUS_UP;
  View newFocused=findFocusableViewInBounds(up,top,bottom,leftwards,left,right);
  if (newFocused == null) {
    newFocused=this;
  }
  if ((top >= containerTop && bottom <= containerBottom) || (left >= containerLeft && right <= containerRight)) {
    handled=false;
  }
 else {
    int deltaY=up ? (top - containerTop) : (bottom - containerBottom);
    int deltaX=leftwards ? (left - containerLeft) : (right - containerRight);
    doScroll(deltaX,deltaY);
  }
  return handled;
}
Program: 170949
Project: 170949
Buggy source:
@Override public boolean onTouchEvent(MotionEvent event){
  boolean retVal=scaleDetectorActive && mScaleGestureDetector.onTouchEvent(event);
  retVal=mGestureDetector.onTouchEvent(event) || retVal;
  final int action=MotionEventCompat.getActionMasked(event);
  if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_POINTER_UP) {
    mGestureListener.finish();
  }
  return retVal || super.onTouchEvent(event);
}

Fixed version (ground truth):
@Override public boolean onTouchEvent(MotionEvent event){
  boolean retVal=mScaleGestureDetector.onTouchEvent(event);
  retVal=mGestureDetector.onTouchEvent(event) || retVal;
  final int action=MotionEventCompat.getActionMasked(event);
  if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_POINTER_UP) {
    mGestureListener.finish();
  }
  return retVal || super.onTouchEvent(event);
}
Program: 170950
Project: 170950
Buggy source:
public void onScaleEnd(ScaleGestureDetector detector){
  if (Build.VERSION.SDK_INT >= 11) {
    scale*=detector.getScaleFactor();
    if (listChangeIf != null) {
      listChangeIf.onScale(scale);
      getMainLayout().setScaleX(1.0f);
      getMainLayout().setScaleY(1.0f);
    }
  }
  isScaled=false;
}

Fixed version (ground truth):
public void onScaleEnd(ScaleGestureDetector detector){
  if (isScaled && Build.VERSION.SDK_INT >= 11) {
    scale*=detector.getScaleFactor();
    if (listChangeIf != null) {
      listChangeIf.onScale(scale);
      getMainLayout().setScaleX(1.0f);
      getMainLayout().setScaleY(1.0f);
    }
  }
  isScaled=false;
}
Program: 170951
Project: 170951
Buggy source:
@Override public boolean onScale(ScaleGestureDetector detector){
  if (listChangeIf != null) {
    scale*=detector.getScaleFactor();
    if (Build.VERSION.SDK_INT >= 11) {
      getMainLayout().setScaleX(scale);
      getMainLayout().setScaleY(scale);
    }
 else {
      listChangeIf.onScale(detector.getScaleFactor());
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean onScale(ScaleGestureDetector detector){
  if (isScaled && listChangeIf != null) {
    scale*=detector.getScaleFactor();
    if (Build.VERSION.SDK_INT >= 11) {
      getMainLayout().setScaleX(scale);
      getMainLayout().setScaleY(scale);
    }
 else {
      listChangeIf.onScale(detector.getScaleFactor());
    }
  }
  return true;
}
Program: 170952
Project: 170952
Buggy source:
/** 
 * Re-implementation for methods for CalculationResult superclass
 */
@Override public void invalidateResult(){
  clearResult();
  showResult();
}

Fixed version (ground truth):
/** 
 * Re-implementation for methods for CalculationResult superclass
 */
@Override public void invalidateResult(){
  constantResultField.getEditText().setText("String_Node_Str");
  arrayResultMatrix.setText("String_Node_Str",getFormulaList().getDimen());
}
Program: 170954
Project: 170954
Buggy source:
@Override public boolean isContentValid(ValidationPassType type){
  boolean isValid=super.isContentValid(type);
switch (type) {
case VALIDATE_SINGLE_FORMULA:
    break;
case VALIDATE_LINKS:
  if (isValid && !leftTerm.isEmpty()) {
    String errorMsg=null;
    final ArrayList<String> indirectIntervals=getIndirectIntervals();
    if (!indirectIntervals.isEmpty() && !getDirectIntervals().isEmpty()) {
      isValid=false;
      errorMsg=String.format(getContext().getResources().getString(R.string.error_indirect_intervals),indirectIntervals.toString());
    }
 else     if (getAllIntervals().size() > 2) {
      isValid=false;
      errorMsg=getContext().getResources().getString(R.string.error_ensure_double_interval);
    }
    leftTerm.setError(errorMsg,ErrorNotification.LAYOUT_BORDER,null);
  }
break;
}
if (!isValid) {
invalidateResult();
}
return disableCalculation() || isValid;
}

Fixed version (ground truth):
@Override public boolean isContentValid(ValidationPassType type){
  boolean isValid=super.isContentValid(type);
switch (type) {
case VALIDATE_SINGLE_FORMULA:
    break;
case VALIDATE_LINKS:
  if (isValid && !leftTerm.isEmpty()) {
    String errorMsg=null;
    final ArrayList<String> indirectIntervals=getIndirectIntervals();
    if (!indirectIntervals.isEmpty() && !getDirectIntervals().isEmpty()) {
      isValid=false;
      errorMsg=String.format(getContext().getResources().getString(R.string.error_indirect_intervals),indirectIntervals.toString());
    }
 else     if (getAllIntervals().size() > 2) {
      isValid=false;
      errorMsg=getContext().getResources().getString(R.string.error_ensure_double_interval);
    }
    leftTerm.setError(errorMsg,ErrorNotification.LAYOUT_BORDER,null);
  }
break;
}
if (!isValid) {
clearResult();
showResult();
}
return disableCalculation() || isValid;
}
Program: 170955
Project: 170955
Buggy source:
@Override public void onResultPropertiesChange(boolean isChanged){
  getFormulaList().finishActiveActionMode();
  if (!isChanged) {
    formulaState=null;
    return;
  }
  if (formulaState != null) {
    getFormulaList().getUndoState().addEntry(formulaState);
    formulaState=null;
  }
  if (properties.disableCalculation) {
    invalidateResult();
  }
  updateResultView(true);
  ViewUtils.invalidateLayout(layout,layout);
}

Fixed version (ground truth):
@Override public void onResultPropertiesChange(boolean isChanged){
  getFormulaList().finishActiveActionMode();
  if (!isChanged) {
    formulaState=null;
    return;
  }
  if (formulaState != null) {
    getFormulaList().getUndoState().addEntry(formulaState);
    formulaState=null;
  }
  if (properties.disableCalculation) {
    clearResult();
  }
  updateResultView(true);
  ViewUtils.invalidateLayout(layout,layout);
}
Program: 170956
Project: 170956
Buggy source:
public void setText(int row,int col,String text){
  final CustomEditText cell=getCell(row,col);
  if (cell != null) {
    cell.setText(text);
  }
}

Fixed version (ground truth):
public void setText(String s,ScaledDimensions dimen){
  for (  CustomEditText field : fields) {
    field.setText(s);
    field.updateTextSize(dimen,0,ScaledDimensions.Type.MATRIX_COLUMN_PADDING);
  }
}
Program: 170957
Project: 170957
Buggy source:
@Override protected Void doInBackground(Void... params){
  for (  CalculationResult f : formulas) {
    if (!f.isEmpty()) {
      try {
        f.calculate(this);
      }
 catch (      CancelException e) {
        break;
      }
      publishProgress(f);
    }
  }
  return null;
}

Fixed version (ground truth):
@Override protected Void doInBackground(Void... params){
  for (  CalculationResult f : formulas) {
    if (!f.isEmpty()) {
      try {
        f.calculate(this);
      }
 catch (      CancelException e) {
        break;
      }
catch (      OutOfMemoryError ex) {
        String error=list.getActivity().getResources().getString(R.string.error_out_of_memory);
        Toast.makeText(list.getActivity(),error,Toast.LENGTH_LONG).show();
        break;
      }
      publishProgress(f);
    }
  }
  return null;
}
Program: 170958
Project: 170958
Buggy source:
@Override public void onSupportActionModeStarted(android.support.v7.view.ActionMode mode){
  activeActionModes.add(mode);
  final BaseFragment f=getVisibleFragment();
  if (f != null) {
    f.updateModeTitle();
  }
}

Fixed version (ground truth):
@Override public void onSupportActionModeStarted(android.support.v7.view.ActionMode mode){
  super.onSupportActionModeStarted(mode);
  activeActionModes.add(mode);
  final BaseFragment f=getVisibleFragment();
  if (f != null) {
    f.updateModeTitle();
  }
}
Program: 170960
Project: 170960
Buggy source:
@Override public void onSupportActionModeFinished(android.support.v7.view.ActionMode mode){
  activeActionModes.remove(mode);
  final BaseFragment f=getVisibleFragment();
  if (f != null) {
    f.enableObjectPropertiesButton(false);
    f.enableObjectDetailsButton(false);
  }
}

Fixed version (ground truth):
@Override public void onSupportActionModeFinished(android.support.v7.view.ActionMode mode){
  super.onSupportActionModeFinished(mode);
  activeActionModes.remove(mode);
  final BaseFragment f=getVisibleFragment();
  if (f != null) {
    f.enableObjectPropertiesButton(false);
    f.enableObjectDetailsButton(false);
  }
}
Program: 170961
Project: 170961
Buggy source:
/** 
 * Parcelable interface: procedure reads the formula state
 */
public void onRestoreInstanceState(Parcelable state){
  if (state == null) {
    return;
  }
  if (state instanceof Bundle) {
    Bundle bundle=(Bundle)state;
    if (IdGenerator.enableIdRestore) {
      setId(bundle.getInt(STATE_FORMULA_ID));
      IdGenerator.compareAndSet(getId());
    }
    inRightOfPrevious=bundle.getBoolean(STATE_INRIGHTOFPREVIOUS);
    for (int i=0; i < terms.size(); i++) {
      if (terms.get(i).isWritable) {
        terms.get(i).readFromBundle(bundle,STATE_TERM + i);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Parcelable interface: procedure reads the formula state
 */
@SuppressLint("String_Node_Str") public void onRestoreInstanceState(Parcelable state){
  if (state == null) {
    return;
  }
  if (state instanceof Bundle) {
    Bundle bundle=(Bundle)state;
    if (IdGenerator.enableIdRestore) {
      setId(bundle.getInt(STATE_FORMULA_ID));
      IdGenerator.compareAndSet(getId());
    }
    inRightOfPrevious=bundle.getBoolean(STATE_INRIGHTOFPREVIOUS);
    for (int i=0; i < terms.size(); i++) {
      if (terms.get(i).isWritable) {
        terms.get(i).readFromBundle(bundle,STATE_TERM + i);
      }
    }
  }
}
Program: 170962
Project: 170962
Buggy source:
/** 
 * Parcelable interface: procedure writes the formula state
 */
public Parcelable onSaveInstanceState(){
  Bundle bundle=new Bundle();
  bundle.putInt(STATE_FORMULA_ID,getId());
  bundle.putBoolean(STATE_INRIGHTOFPREVIOUS,inRightOfPrevious);
  for (int i=0; i < terms.size(); i++) {
    terms.get(i).writeToBundle(bundle,STATE_TERM + i);
  }
  return bundle;
}

Fixed version (ground truth):
/** 
 * Parcelable interface: procedure writes the formula state
 */
@SuppressLint("String_Node_Str") public Parcelable onSaveInstanceState(){
  Bundle bundle=new Bundle();
  bundle.putInt(STATE_FORMULA_ID,getId());
  bundle.putBoolean(STATE_INRIGHTOFPREVIOUS,inRightOfPrevious);
  for (int i=0; i < terms.size(); i++) {
    terms.get(i).writeToBundle(bundle,STATE_TERM + i);
  }
  return bundle;
}
Program: 170963
Project: 170963
Buggy source:
/** 
 * Parcelable interface: procedure reads the formula state
 */
public void onRestoreInstanceState(Parcelable state){
  if (state == null) {
    return;
  }
  if (state instanceof Bundle) {
    Bundle bundle=(Bundle)state;
    axisParameters.assign((AxisProperties)bundle.getParcelable(STATE_AXIS_PARAMETERS));
    plotParameters.assign((PlotProperties)bundle.getParcelable(STATE_PLOT_PARAMETERS));
    if (colorMapView != null) {
      colorMapView.getColorMapParameters().assign((ColorMapProperties)bundle.getParcelable(STATE_COLORMAP_PARAMETERS));
    }
  }
}

Fixed version (ground truth):
/** 
 * Parcelable interface: procedure reads the formula state
 */
@SuppressLint("String_Node_Str") public void onRestoreInstanceState(Parcelable state){
  if (state == null) {
    return;
  }
  if (state instanceof Bundle) {
    Bundle bundle=(Bundle)state;
    axisParameters.assign((AxisProperties)bundle.getParcelable(STATE_AXIS_PARAMETERS));
    plotParameters.assign((PlotProperties)bundle.getParcelable(STATE_PLOT_PARAMETERS));
    if (colorMapView != null) {
      colorMapView.getColorMapParameters().assign((ColorMapProperties)bundle.getParcelable(STATE_COLORMAP_PARAMETERS));
    }
  }
}
Program: 170964
Project: 170964
Buggy source:
/** 
 * Parcelable interface: procedure writes the formula state
 */
public Parcelable onSaveInstanceState(){
  Bundle bundle=new Bundle();
{
    AxisProperties ap=new AxisProperties();
    ap.assign(axisParameters);
    bundle.putParcelable(STATE_AXIS_PARAMETERS,ap);
  }
{
    PlotProperties pp=new PlotProperties();
    pp.assign(plotParameters);
    bundle.putParcelable(STATE_PLOT_PARAMETERS,pp);
  }
  if (colorMapView != null) {
    ColorMapProperties cp=new ColorMapProperties();
    cp.assign(colorMapView.getColorMapParameters());
    bundle.putParcelable(STATE_COLORMAP_PARAMETERS,cp);
  }
  return bundle;
}

Fixed version (ground truth):
/** 
 * Parcelable interface: procedure writes the formula state
 */
@SuppressLint("String_Node_Str") public Parcelable onSaveInstanceState(){
  Bundle bundle=new Bundle();
{
    AxisProperties ap=new AxisProperties();
    ap.assign(axisParameters);
    bundle.putParcelable(STATE_AXIS_PARAMETERS,ap);
  }
{
    PlotProperties pp=new PlotProperties();
    pp.assign(plotParameters);
    bundle.putParcelable(STATE_PLOT_PARAMETERS,pp);
  }
  if (colorMapView != null) {
    ColorMapProperties cp=new ColorMapProperties();
    cp.assign(colorMapView.getColorMapParameters());
    bundle.putParcelable(STATE_COLORMAP_PARAMETERS,cp);
  }
  return bundle;
}
Program: 170965
Project: 170965
Buggy source:
/** 
 * Parcelable interface: procedure reads the formula state
 */
@Override public void onRestoreInstanceState(Parcelable state){
  if (state == null) {
    return;
  }
  if (state instanceof Bundle) {
    Bundle bundle=(Bundle)state;
    final ImageType type=ImageType.valueOf(bundle.getString(SATATE_IMAGE_TYPE));
switch (type) {
case NONE:
      break;
case BITMAP:
    setBitmap((Bitmap)bundle.getParcelable(STATE_IMAGE_BITMAP));
  break;
case SVG:
setSvg(bundle.getString(STATE_IMAGE_SVG));
break;
}
}
}

Fixed version (ground truth):
/** 
 * Parcelable interface: procedure reads the formula state
 */
@Override @SuppressLint("String_Node_Str") public void onRestoreInstanceState(Parcelable state){
  if (state == null) {
    return;
  }
  if (state instanceof Bundle) {
    Bundle bundle=(Bundle)state;
    final ImageType type=ImageType.valueOf(bundle.getString(SATATE_IMAGE_TYPE));
switch (type) {
case NONE:
      break;
case BITMAP:
    setBitmap((Bitmap)bundle.getParcelable(STATE_IMAGE_BITMAP));
  break;
case SVG:
setSvg(bundle.getString(STATE_IMAGE_SVG));
break;
}
}
}
Program: 170966
Project: 170966
Buggy source:
/** 
 * Parcelable interface: procedure writes the formula state
 */
@Override public Parcelable onSaveInstanceState(){
  Bundle bundle=new Bundle();
  bundle.putString(SATATE_IMAGE_TYPE,imageType.toString());
switch (imageType) {
case NONE:
    break;
case BITMAP:
  if (bitmap != null) {
    bundle.putParcelable(STATE_IMAGE_BITMAP,bitmap);
  }
break;
case SVG:
if (svgData != null) {
bundle.putString(STATE_IMAGE_SVG,svgData);
}
break;
}
return bundle;
}

Fixed version (ground truth):
/** 
 * Parcelable interface: procedure writes the formula state
 */
@Override @SuppressLint("String_Node_Str") public Parcelable onSaveInstanceState(){
  Bundle bundle=new Bundle();
  bundle.putString(SATATE_IMAGE_TYPE,imageType.toString());
switch (imageType) {
case NONE:
    break;
case BITMAP:
  if (bitmap != null) {
    bundle.putParcelable(STATE_IMAGE_BITMAP,bitmap);
  }
break;
case SVG:
if (svgData != null) {
bundle.putString(STATE_IMAGE_SVG,svgData);
}
break;
}
return bundle;
}
Program: 170967
Project: 170967
Buggy source:
/** 
 * Returns the cache key that is created from the provided input key.
 * @param input the input key
 * @param < K >   type parameter indicating the type of the input key
 * @param < U >   type parameter indicating the type of the cache key that is returned
 * @return the cache key
 */
<K,U>U getKey(K input);

Fixed version (ground truth):
/** 
 * Returns the cache key that is created from the provided input key.
 * @param input the input key
 * @return the cache key
 */
Object getKey(K input);
Program: 170968
Project: 170968
Buggy source:
/** 
 * Gets the object that is used in the internal cache map as key, by applying the cache key function to the provided key. <p> If no cache key function is present in   {@link DataLoaderOptions}, then the returned value equals the input key.
 * @param key the input key
 * @return the cache key after the input is transformed with the cache key function
 */
public Object getCacheKey(K key){
  return loaderOptions.cacheKeyFunction().isPresent() ? loaderOptions.cacheKeyFunction().get().getKey(key) : key;
}

Fixed version (ground truth):
/** 
 * Gets the object that is used in the internal cache map as key, by applying the cache key function to the provided key. <p> If no cache key function is present in   {@link DataLoaderOptions}, then the returned value equals the input key.
 * @param key the input key
 * @return the cache key after the input is transformed with the cache key function
 */
@SuppressWarnings("String_Node_Str") public Object getCacheKey(K key){
  return loaderOptions.cacheKeyFunction().isPresent() ? loaderOptions.cacheKeyFunction().get().getKey(key) : key;
}
Program: 170969
Project: 170969
Buggy source:
/** 
 * Creates a new data loader with the provided batch load function and options.
 * @param batchLoadFunction the batch load function to use
 * @param options           the batch load options
 */
@SuppressWarnings("String_Node_Str") public DataLoader(BatchLoader<K> batchLoadFunction,DataLoaderOptions<K,V> options){
  Objects.requireNonNull(batchLoadFunction,"String_Node_Str");
  this.batchLoadFunction=batchLoadFunction;
  this.loaderOptions=options == null ? new DataLoaderOptions<>() : options;
  this.futureCache=loaderOptions.cacheMap().isPresent() ? (CacheMap<Object,Future<V>>)loaderOptions.cacheMap().get() : CacheMap.simpleMap();
  this.loaderQueue=new LinkedHashMap<>();
}

Fixed version (ground truth):
/** 
 * Creates a new data loader with the provided batch load function and options.
 * @param batchLoadFunction the batch load function to use
 * @param options           the batch load options
 */
@SuppressWarnings("String_Node_Str") public DataLoader(BatchLoader<K> batchLoadFunction,DataLoaderOptions options){
  Objects.requireNonNull(batchLoadFunction,"String_Node_Str");
  this.batchLoadFunction=batchLoadFunction;
  this.loaderOptions=options == null ? new DataLoaderOptions() : options;
  this.futureCache=loaderOptions.cacheMap().isPresent() ? (CacheMap<Object,Future<V>>)loaderOptions.cacheMap().get() : CacheMap.simpleMap();
  this.loaderQueue=new LinkedHashMap<>();
}
Program: 170970
Project: 170970
Buggy source:
/** 
 * Requests to load the data with the specified key asynchronously, and returns a future of the resulting value. <p> If batching is enabled (the default), you'll have to call   {@link DataLoader#dispatch()} at a later stage tostart batch execution. If you forget this call the future will never be completed (unless already completed, and returned from cache).
 * @param key the key to load
 * @return the future of the value
 */
public Future<V> load(K key){
  Objects.requireNonNull(key,"String_Node_Str");
  Object cacheKey=getCacheKey(key);
  if (loaderOptions.cachingEnabled() && futureCache.containsKey(cacheKey)) {
    return futureCache.get(key);
  }
  Future<V> future=Future.future();
  if (loaderOptions.batchingEnabled()) {
    loaderQueue.put(key,future);
  }
 else {
    CompositeFuture compositeFuture=batchLoadFunction.load(Collections.singleton(key));
    if (compositeFuture.succeeded()) {
      future.complete(compositeFuture.result().result(0));
    }
 else {
      future.fail(compositeFuture.cause());
    }
  }
  if (loaderOptions.cachingEnabled()) {
    futureCache.set(key,future);
  }
  return future;
}

Fixed version (ground truth):
/** 
 * Requests to load the data with the specified key asynchronously, and returns a future of the resulting value. <p> If batching is enabled (the default), you'll have to call   {@link DataLoader#dispatch()} at a later stage tostart batch execution. If you forget this call the future will never be completed (unless already completed, and returned from cache).
 * @param key the key to load
 * @return the future of the value
 */
public Future<V> load(K key){
  Objects.requireNonNull(key,"String_Node_Str");
  Object cacheKey=getCacheKey(key);
  if (loaderOptions.cachingEnabled() && futureCache.containsKey(cacheKey)) {
    return futureCache.get(cacheKey);
  }
  Future<V> future=Future.future();
  if (loaderOptions.batchingEnabled()) {
    loaderQueue.put(key,future);
  }
 else {
    CompositeFuture compositeFuture=batchLoadFunction.load(Collections.singleton(key));
    if (compositeFuture.succeeded()) {
      future.complete(compositeFuture.result().result(0));
    }
 else {
      future.fail(compositeFuture.cause());
    }
  }
  if (loaderOptions.cachingEnabled()) {
    futureCache.set(cacheKey,future);
  }
  return future;
}
Program: 170971
Project: 170971
Buggy source:
/** 
 * Gets the (optional) cache map implementation that is used for caching, if caching is enabled. <p> If missing a standard   {@link java.util.LinkedHashMap} will be used as the cache implementation.
 * @return an optional with the cache map instance, or empty
 */
public Optional<CacheMap<K,Future<V>>> cacheMap(){
  return Optional.ofNullable(cacheMap);
}

Fixed version (ground truth):
/** 
 * Gets the (optional) cache map implementation that is used for caching, if caching is enabled. <p> If missing a standard   {@link java.util.LinkedHashMap} will be used as the cache implementation.
 * @return an optional with the cache map instance, or empty
 */
public Optional<CacheMap> cacheMap(){
  return Optional.ofNullable(cacheMap);
}
Program: 170972
Project: 170972
Buggy source:
/** 
 * Sets the option that determines whether batch loading is enabled.
 * @param batchingEnabled {@code true} to enable batch loading, {@code false} otherwise
 * @return the data loader options for fluent coding
 */
public DataLoaderOptions<K,V> setBatchingEnabled(boolean batchingEnabled){
  this.batchingEnabled=batchingEnabled;
  return this;
}

Fixed version (ground truth):
/** 
 * Sets the option that determines whether batch loading is enabled.
 * @param batchingEnabled {@code true} to enable batch loading, {@code false} otherwise
 * @return the data loader options for fluent coding
 */
public DataLoaderOptions setBatchingEnabled(boolean batchingEnabled){
  this.batchingEnabled=batchingEnabled;
  return this;
}
Program: 170973
Project: 170973
Buggy source:
/** 
 * Sets the function to use for creating the cache key, if caching is enabled.
 * @param cacheKeyFunction the cache key function to use
 * @return the data loader options for fluent coding
 */
public DataLoaderOptions<K,V> setCacheKeyFunction(CacheKey cacheKeyFunction){
  this.cacheKeyFunction=cacheKeyFunction;
  return this;
}

Fixed version (ground truth):
/** 
 * Sets the function to use for creating the cache key, if caching is enabled.
 * @param cacheKeyFunction the cache key function to use
 * @return the data loader options for fluent coding
 */
public DataLoaderOptions setCacheKeyFunction(CacheKey cacheKeyFunction){
  this.cacheKeyFunction=cacheKeyFunction;
  return this;
}
Program: 170974
Project: 170974
Buggy source:
/** 
 * Sets the cache map implementation to use for caching, if caching is enabled.
 * @param cacheMap the cache map instance
 * @return the data loader options for fluent coding
 */
public DataLoaderOptions setCacheMap(CacheMap<K,Future<V>> cacheMap){
  this.cacheMap=cacheMap;
  return this;
}

Fixed version (ground truth):
/** 
 * Sets the cache map implementation to use for caching, if caching is enabled.
 * @param cacheMap the cache map instance
 * @return the data loader options for fluent coding
 */
public <K,V>DataLoaderOptions setCacheMap(CacheMap<K,Future<V>> cacheMap){
  this.cacheMap=cacheMap;
  return this;
}
Program: 170975
Project: 170975
Buggy source:
/** 
 * Sets the option that determines whether caching is enabled.
 * @param cachingEnabled {@code true} to enable caching, {@code false} otherwise
 * @return the data loader options for fluent coding
 */
public DataLoaderOptions<K,V> setCachingEnabled(boolean cachingEnabled){
  this.cachingEnabled=cachingEnabled;
  return this;
}

Fixed version (ground truth):
/** 
 * Sets the option that determines whether caching is enabled.
 * @param cachingEnabled {@code true} to enable caching, {@code false} otherwise
 * @return the data loader options for fluent coding
 */
public DataLoaderOptions setCachingEnabled(boolean cachingEnabled){
  this.cachingEnabled=cachingEnabled;
  return this;
}
Program: 170976
Project: 170976
Buggy source:
public static <K,V>DataLoaderOptions<K,V> create(){
  return new DataLoaderOptions<>();
}

Fixed version (ground truth):
public static DataLoaderOptions create(){
  return new DataLoaderOptions();
}
Program: 170977
Project: 170977
Buggy source:
public static IJsonAdapter getJsonAdapter(){
  return sJsonAdapter;
}

Fixed version (ground truth):
public static IJsonAdapter getJsonAdapter(){
  if (sJsonAdapter == null) {
    throw new IllegalStateException("String_Node_Str");
  }
  return sJsonAdapter;
}
Program: 170978
Project: 170978
Buggy source:
public static SocialSdkConfig getConfig(){
  return sSocialSdkConfig;
}

Fixed version (ground truth):
public static SocialSdkConfig getConfig(){
  if (sSocialSdkConfig == null) {
    throw new IllegalStateException("String_Node_Str");
  }
  return sSocialSdkConfig;
}
Program: 170980
Project: 170980
Buggy source:
public Bitmap decodeSampledBitmapFromUri(Uri fileUri,int reqWidth,int reqHeight) throws IOException {
  InputStream stream=new BufferedInputStream(mApplicationContext.getContentResolver().openInputStream(fileUri));
  stream.mark(stream.available());
  BitmapFactory.Options options=new BitmapFactory.Options();
  options.inJustDecodeBounds=true;
  BitmapFactory.decodeStream(stream,null,options);
  stream.reset();
  options.inSampleSize=calculateInSampleSize(options,reqWidth,reqHeight);
  options.inJustDecodeBounds=false;
  BitmapFactory.decodeStream(stream,null,options);
  stream.reset();
  return BitmapFactory.decodeStream(stream,null,options);
}

Fixed version (ground truth):
public Bitmap decodeSampledBitmapFromUri(Uri fileUri,int reqWidth,int reqHeight) throws IOException {
  InputStream stream=streamFromUri(fileUri);
  stream.mark(stream.available());
  BitmapFactory.Options options=new BitmapFactory.Options();
  options.inJustDecodeBounds=true;
  BitmapFactory.decodeStream(stream,null,options);
  stream.reset();
  options.inSampleSize=calculateInSampleSize(options,reqWidth,reqHeight);
  options.inJustDecodeBounds=false;
  BitmapFactory.decodeStream(stream,null,options);
  stream.close();
  InputStream freshStream=streamFromUri(fileUri);
  return BitmapFactory.decodeStream(freshStream,null,options);
}
Program: 170981
Project: 170981
Buggy source:
@PostConstruct public void init() throws Exception {
  Map<String,Object> beans=applicationContext.getBeansWithAnnotation(MQProducer.class);
  if (CollectionUtils.isEmpty(beans)) {
    return;
  }
  if (producer == null) {
    if (StringUtils.isEmpty(mqProperties.getProducerGroup())) {
      throw new RuntimeException("String_Node_Str");
    }
    if (StringUtils.isEmpty(mqProperties.getNameServerAddress())) {
      throw new RuntimeException("String_Node_Str");
    }
    producer=new DefaultMQProducer(mqProperties.getProducerGroup());
    producer.setNamesrvAddr(mqProperties.getNameServerAddress());
    producer.start();
    registerBean(DefaultMQProducer.class.getName(),producer);
  }
  for (  Map.Entry<String,Object> entry : beans.entrySet()) {
    publishProducer(entry.getKey(),entry.getValue());
  }
}

Fixed version (ground truth):
@PostConstruct public void init() throws Exception {
  Map<String,Object> beans=applicationContext.getBeansWithAnnotation(MQProducer.class);
  if (CollectionUtils.isEmpty(beans)) {
    return;
  }
  if (producer == null) {
    Assert.notNull(mqProperties.getProducerGroup(),"String_Node_Str");
    Assert.notNull(mqProperties.getNameServerAddress(),"String_Node_Str");
    producer=new DefaultMQProducer(mqProperties.getProducerGroup());
    producer.setNamesrvAddr(mqProperties.getNameServerAddress());
    producer.start();
  }
  registerBean(DefaultMQProducer.class.getName(),producer);
  for (  Map.Entry<String,Object> entry : beans.entrySet()) {
    publishProducer(entry.getKey(),entry.getValue());
  }
}
Program: 170982
Project: 170982
Buggy source:
private void prepareApplicationContextMissingProducerGroupConfigure(){
  this.context=new AnnotationConfigApplicationContext();
  EnvironmentTestUtils.addEnvironment(this.context,"String_Node_Str");
  this.context.register(TestProducerWithTopicAndTag.class);
  this.context.register(MQProducerAutoConfiguration.class);
  this.context.refresh();
}

Fixed version (ground truth):
private void prepareApplicationContextMissingProducerGroupConfigure(){
  this.context=new AnnotationConfigApplicationContext();
  EnvironmentTestUtils.addEnvironment(this.context,"String_Node_Str");
  this.context.register(TestProducerWithTopicAndTag.class);
  MQProducerAutoConfiguration.setProducer(null);
  this.context.register(MQProducerAutoConfiguration.class);
  this.context.refresh();
}
Program: 170983
Project: 170983
Buggy source:
private void prepareApplicationContextMissingConfigure(){
  this.context=new AnnotationConfigApplicationContext();
  this.context.register(TestProducerWithTopicAndTag.class);
  this.context.register(MQProducerAutoConfiguration.class);
  this.context.refresh();
}

Fixed version (ground truth):
private void prepareApplicationContextMissingConfigure(){
  this.context=new AnnotationConfigApplicationContext();
  this.context.register(TestProducerWithTopicAndTag.class);
  MQProducerAutoConfiguration.setProducer(null);
  this.context.register(MQProducerAutoConfiguration.class);
  this.context.refresh();
}