nus-yam/ex-repair huggingface dataset:
Program: 162327
Project: 162327
Buggy source:
@Override public void submit(String name,double dValue){
  long value=((Double)dValue).longValue();
  if (name.startsWith("String_Node_Str")) {
    registry.distributionSummary(stripMetricName(name)).record(value);
  }
 else   if (name.startsWith("String_Node_Str")) {
    registry.timer(stripMetricName(name)).record(value,TimeUnit.MILLISECONDS);
  }
 else {
    final Id id=registry.createId(name);
    final AtomicDouble gauge=getGaugeStorage(id);
    gauge.set(dValue);
    registry.register(new NumericGauge(id,gauge));
  }
}

Fixed version (ground truth):
@Override public void submit(String name,double dValue){
  if (name.startsWith("String_Node_Str")) {
    registry.distributionSummary(stripMetricName(name)).record((long)dValue);
  }
 else   if (name.startsWith("String_Node_Str")) {
    long value=(long)(dValue * 1e6);
    registry.timer(stripMetricName(name)).record(value,TimeUnit.NANOSECONDS);
  }
 else {
    final Id id=registry.createId(name);
    final AtomicDouble gauge=getGaugeStorage(id);
    gauge.set(dValue);
  }
}
Program: 162328
Project: 162328
Buggy source:
private AtomicDouble getGaugeStorage(Id id){
  final AtomicDouble newGauge=new AtomicDouble(0);
  final AtomicDouble existingGauge=gauges.putIfAbsent(id,newGauge);
  return existingGauge == null ? newGauge : existingGauge;
}

Fixed version (ground truth):
private AtomicDouble getGaugeStorage(Id id){
  final AtomicDouble newGauge=new AtomicDouble(0);
  final AtomicDouble existingGauge=gauges.putIfAbsent(id,newGauge);
  return existingGauge == null ? registry.gauge(id,newGauge) : existingGauge;
}
Program: 162329
Project: 162329
Buggy source:
private void incrementInternal(String name,long value){
  if (name.startsWith("String_Node_Str")) {
  }
 else   if (name.startsWith("String_Node_Str")) {
    registry.counter(stripMetricName(name)).increment(value);
  }
 else {
    final Id id=registry.createId(name);
    final AtomicLong gauge=getCounterStorage(id);
    gauge.addAndGet(value);
    registry.register(new NumericGauge(id,gauge));
  }
}

Fixed version (ground truth):
private void incrementInternal(String name,long value){
  if (name.startsWith("String_Node_Str")) {
  }
 else   if (name.startsWith("String_Node_Str")) {
    registry.counter(stripMetricName(name)).increment(value);
  }
 else {
    final Id id=registry.createId(name);
    final AtomicLong gauge=getCounterStorage(id);
    gauge.addAndGet(value);
  }
}
Program: 162330
Project: 162330
Buggy source:
@Override protected Object lookupHandler(String urlPath,HttpServletRequest request) throws Exception {
  if (this.errorController != null && urlPath.equals(this.errorController.getErrorPath())) {
    return null;
  }
  String[] ignored=this.routeLocator.getIgnoredPaths().toArray(new String[0]);
  if (PatternMatchUtils.simpleMatch(ignored,urlPath)) {
    return null;
  }
  return super.lookupHandler(urlPath,request);
}

Fixed version (ground truth):
@Override protected Object lookupHandler(String urlPath,HttpServletRequest request) throws Exception {
  if (this.errorController != null && urlPath.equals(this.errorController.getErrorPath())) {
    return null;
  }
  String[] ignored=this.routeLocator.getIgnoredPaths().toArray(new String[0]);
  if (PatternMatchUtils.simpleMatch(ignored,urlPath)) {
    return null;
  }
  RequestContext ctx=RequestContext.getCurrentContext();
  if (ctx.containsKey("String_Node_Str")) {
    return null;
  }
  return super.lookupHandler(urlPath,request);
}
Program: 162331
Project: 162331
Buggy source:
@Before public void init(){
  this.mapping=new ZuulHandlerMapping(this.locator,new ZuulController());
  this.mapping.setErrorController(this.errors);
  Mockito.when(this.errors.getErrorPath()).thenReturn("String_Node_Str");
}

Fixed version (ground truth):
@Before public void init(){
  RequestContext.getCurrentContext().clear();
  this.mapping=new ZuulHandlerMapping(this.locator,new ZuulController());
  this.mapping.setErrorController(this.errors);
  Mockito.when(this.errors.getErrorPath()).thenReturn("String_Node_Str");
}
Program: 162332
Project: 162332
Buggy source:
private void debugRequestEntity(Map<String,Object> info,InputStream inputStream) throws IOException {
  String entity=IOUtils.toString(inputStream);
  if (StringUtils.hasText(entity)) {
    info.put("String_Node_Str",entity);
  }
}

Fixed version (ground truth):
private void debugRequestEntity(Map<String,Object> info,InputStream inputStream) throws IOException {
  if (RequestContext.getCurrentContext().isChunkedRequestBody()) {
    info.put("String_Node_Str","String_Node_Str");
    return;
  }
  String entity=IOUtils.toString(inputStream);
  if (StringUtils.hasText(entity)) {
    info.put("String_Node_Str",entity.length() <= 4096 ? entity : entity.substring(0,4096) + "String_Node_Str");
  }
}
Program: 162333
Project: 162333
Buggy source:
@Override public int getContentLength(){
  if (this.contentData == null) {
    buildContentData();
  }
  return this.contentLength;
}

Fixed version (ground truth):
@Override public int getContentLength(){
  if (super.getContentLength() <= 0) {
    return super.getContentLength();
  }
  if (this.contentData == null) {
    buildContentData();
  }
  return this.contentLength;
}
Program: 162334
Project: 162334
Buggy source:
@Override public ServletInputStream getInputStream() throws IOException {
  if (RequestContext.getCurrentContext().isChunkedRequestBody()) {
    return this.request.getInputStream();
  }
 else {
    if (this.contentData == null) {
      buildContentData();
    }
    return new ServletInputStreamWrapper(this.contentData);
  }
}

Fixed version (ground truth):
@Override public ServletInputStream getInputStream() throws IOException {
  if (this.contentData == null) {
    buildContentData();
  }
  return new ServletInputStreamWrapper(this.contentData);
}
Program: 162335
Project: 162335
Buggy source:
public static void main(String[] args){
  SpringApplication.run(FormZuulProxyApplication.class,args);
}

Fixed version (ground truth):
public static void main(String[] args){
  new SpringApplicationBuilder(FormZuulProxyApplication.class).properties("String_Node_Str","String_Node_Str","String_Node_Str").run(args);
}
Program: 162336
Project: 162336
Buggy source:
@RequestMapping(value="String_Node_Str",method=RequestMethod.POST) public String file(@RequestParam(required=false) MultipartFile file) throws IOException {
  return "String_Node_Str" + (file == null ? "String_Node_Str" : new String(file.getBytes()));
}

Fixed version (ground truth):
@RequestMapping(value="String_Node_Str",method=RequestMethod.POST) public String file(@RequestParam(required=false) MultipartFile file) throws IOException {
  byte[] bytes=new byte[0];
  if (file != null) {
    if (file.getSize() > 1024) {
      bytes=new byte[1024];
      InputStream inputStream=file.getInputStream();
      inputStream.read(bytes);
      byte[] buffer=new byte[1024 * 1024 * 10];
      while (inputStream.read(buffer) >= 0) {
        log.info("String_Node_Str");
      }
    }
 else {
      bytes=file.getBytes();
    }
  }
  return "String_Node_Str" + new String(bytes);
}
Program: 162338
Project: 162338
Buggy source:
public ZuulRoute(String path,String location){
  updateRoute(path,location);
}

Fixed version (ground truth):
public ZuulRoute(String path,String location){
  this.id=extractId(path);
  this.path=path;
  setLocation(location);
}
Program: 162339
Project: 162339
Buggy source:
@Override public Object run(){
  try {
    RequestContext ctx=RequestContext.getCurrentContext();
    int statusCode=(Integer)ctx.get("String_Node_Str");
    if (ctx.containsKey("String_Node_Str")) {
      Object e=ctx.get("String_Node_Str");
      log.warn("String_Node_Str",Throwable.class.cast(e));
      ctx.getRequest().setAttribute("String_Node_Str",e);
    }
    ctx.getRequest().setAttribute("String_Node_Str",statusCode);
    RequestDispatcher dispatcher=ctx.getRequest().getRequestDispatcher(errorPath);
    if (dispatcher != null) {
      dispatcher.forward(ctx.getRequest(),ctx.getResponse());
    }
  }
 catch (  Exception e) {
    Throwables.propagate(e);
  }
  return null;
}

Fixed version (ground truth):
@Override public Object run(){
  try {
    RequestContext ctx=RequestContext.getCurrentContext();
    int statusCode=(Integer)ctx.get("String_Node_Str");
    if (ctx.containsKey("String_Node_Str")) {
      Object e=ctx.get("String_Node_Str");
      log.warn("String_Node_Str",Throwable.class.cast(e));
      ctx.getRequest().setAttribute("String_Node_Str",e);
    }
    ctx.getRequest().setAttribute("String_Node_Str",statusCode);
    RequestDispatcher dispatcher=ctx.getRequest().getRequestDispatcher(errorPath);
    if (dispatcher != null) {
      ctx.set(SEND_ERROR_FILTER_RAN,true);
      dispatcher.forward(ctx.getRequest(),ctx.getResponse());
    }
  }
 catch (  Exception e) {
    Throwables.propagate(e);
  }
  return null;
}
Program: 162340
Project: 162340
Buggy source:
@Override public boolean shouldFilter(){
  RequestContext ctx=RequestContext.getCurrentContext();
  return ctx.containsKey("String_Node_Str");
}

Fixed version (ground truth):
@Override public boolean shouldFilter(){
  RequestContext ctx=RequestContext.getCurrentContext();
  return ctx.containsKey("String_Node_Str") && !ctx.getBoolean(SEND_ERROR_FILTER_RAN,false);
}
Program: 162341
Project: 162341
Buggy source:
@Bean public FilterInitializer zuulFilterInitializer(){
  return new FilterInitializer(filters);
}

Fixed version (ground truth):
@Bean public ZuulFilterInitializer zuulFilterInitializer(){
  return new ZuulFilterInitializer(filters);
}
Program: 162342
Project: 162342
Buggy source:
protected LinkedHashMap<String,ZuulRoute> locateRoutes(){
  LinkedHashMap<String,ZuulRoute> routesMap=new LinkedHashMap<>();
  addConfiguredRoutes(routesMap);
  routesMap.putAll(staticRoutes);
  List<String> services=discovery.getServices();
  for (  String serviceId : services) {
    String key="String_Node_Str" + serviceId + "String_Node_Str";
    if (!properties.getIgnoredServices().contains(serviceId) && !routesMap.containsKey(key)) {
      routesMap.put(key,new ZuulRoute(key,serviceId));
    }
  }
  if (routesMap.get(DEFAULT_ROUTE) != null) {
    String defaultServiceId=routesMap.get(DEFAULT_ROUTE).getServiceId();
    routesMap.remove(DEFAULT_ROUTE);
    routesMap.put(DEFAULT_ROUTE,new ZuulRoute(defaultServiceId));
  }
  LinkedHashMap<String,ZuulRoute> values=new LinkedHashMap<>();
  for (  Entry<String,ZuulRoute> entry : routesMap.entrySet()) {
    String path=entry.getKey();
    if (!path.startsWith("String_Node_Str")) {
      path="String_Node_Str" + path;
    }
    if (StringUtils.hasText(properties.getPrefix())) {
      path=properties.getPrefix() + path;
      if (!path.startsWith("String_Node_Str")) {
        path="String_Node_Str" + path;
      }
    }
    values.put(path,entry.getValue());
  }
  return values;
}

Fixed version (ground truth):
protected LinkedHashMap<String,ZuulRoute> locateRoutes(){
  LinkedHashMap<String,ZuulRoute> routesMap=new LinkedHashMap<>();
  addConfiguredRoutes(routesMap);
  routesMap.putAll(staticRoutes);
  List<String> services=discovery.getServices();
  for (  String serviceId : services) {
    String key="String_Node_Str" + serviceId + "String_Node_Str";
    if (!properties.getIgnoredServices().contains(serviceId) && !routesMap.containsKey(key)) {
      routesMap.put(key,new ZuulRoute(key,serviceId));
    }
  }
  if (routesMap.get(DEFAULT_ROUTE) != null) {
    ZuulRoute defaultRoute=routesMap.get(DEFAULT_ROUTE);
    routesMap.remove(DEFAULT_ROUTE);
    routesMap.put(DEFAULT_ROUTE,new ZuulRoute(defaultRoute.getPath(),defaultRoute.getLocation()));
  }
  LinkedHashMap<String,ZuulRoute> values=new LinkedHashMap<>();
  for (  Entry<String,ZuulRoute> entry : routesMap.entrySet()) {
    String path=entry.getKey();
    if (!path.startsWith("String_Node_Str")) {
      path="String_Node_Str" + path;
    }
    if (StringUtils.hasText(properties.getPrefix())) {
      path=properties.getPrefix() + path;
      if (!path.startsWith("String_Node_Str")) {
        path="String_Node_Str" + path;
      }
    }
    values.put(path,entry.getValue());
  }
  return values;
}
Program: 162343
Project: 162343
Buggy source:
private MultivaluedMap<String,String> buildZuulRequestHeaders(HttpServletRequest request){
  RequestContext context=RequestContext.getCurrentContext();
  MultivaluedMap<String,String> headers=new MultivaluedMapImpl();
  Enumeration<?> headerNames=request.getHeaderNames();
  if (headerNames != null) {
    while (headerNames.hasMoreElements()) {
      String name=(String)headerNames.nextElement();
      String value=request.getHeader(name);
      if (!name.toLowerCase().contains("String_Node_Str"))       headers.putSingle(name,value);
    }
  }
  Map<String,String> zuulRequestHeaders=context.getZuulRequestHeaders();
  for (  String header : zuulRequestHeaders.keySet()) {
    headers.putSingle(header,zuulRequestHeaders.get(header));
  }
  headers.putSingle("String_Node_Str","String_Node_Str");
  if (headers.containsKey("String_Node_Str"))   headers.remove("String_Node_Str");
  return headers;
}

Fixed version (ground truth):
private MultivaluedMap<String,String> buildZuulRequestHeaders(HttpServletRequest request){
  RequestContext context=RequestContext.getCurrentContext();
  MultivaluedMap<String,String> headers=new MultivaluedMapImpl();
  Enumeration<?> headerNames=request.getHeaderNames();
  if (headerNames != null) {
    while (headerNames.hasMoreElements()) {
      String name=(String)headerNames.nextElement();
      String value=request.getHeader(name);
      if (!name.toLowerCase().contains("String_Node_Str"))       headers.putSingle(name,value);
    }
  }
  Map<String,String> zuulRequestHeaders=context.getZuulRequestHeaders();
  for (  String header : zuulRequestHeaders.keySet()) {
    headers.putSingle(header,zuulRequestHeaders.get(header));
  }
  headers.putSingle("String_Node_Str","String_Node_Str");
  if (headers.containsKey("String_Node_Str"))   headers.remove("String_Node_Str");
  if (headers.containsKey("String_Node_Str"))   headers.remove("String_Node_Str");
  return headers;
}
Program: 162345
Project: 162345
Buggy source:
@Override public void onDrawerSlide(View drawerView,float slideOffset){
  materialIcon.setTransformationOffset(AnimationState.BURGER_ARROW,direction ? 2 - slideOffset : slideOffset);
}

Fixed version (ground truth):
@Override public void onDrawerSlide(View drawerView,float slideOffset){
  materialIcon.setTransformationOffset(MaterialMenuDrawable.AnimationState.BURGER_ARROW,direction ? 2 - slideOffset : slideOffset);
}
Program: 162346
Project: 162346
Buggy source:
@Override public void run(){
  item.width=item.view.getMeasuredWidth();
  item.height=item.view.getMeasuredHeight();
  item.view.setAlpha(1);
  ((ViewGroup)getActivityContentView()).removeView(item.view);
}

Fixed version (ground truth):
@Override public void run(){
  if (item.view.getMeasuredWidth() == 0 && tries < MAX_TRIES) {
    item.view.post(this);
    return;
  }
  item.width=item.view.getMeasuredWidth();
  item.height=item.view.getMeasuredHeight();
  item.view.setAlpha(1);
  ((ViewGroup)getActivityContentView()).removeView(item.view);
}
Program: 162347
Project: 162347
Buggy source:
/** 
 * Constructor that takes the parameters collected using   {@link FloatingActionMenu.Builder}
 * @param mainActionView
 * @param startAngle
 * @param endAngle
 * @param radius
 * @param subActionItems
 * @param animationHandler
 * @param animated
 */
public FloatingActionMenu(View mainActionView,int startAngle,int endAngle,int radius,ArrayList<Item> subActionItems,MenuAnimationHandler animationHandler,boolean animated){
  this.mainActionView=mainActionView;
  this.startAngle=startAngle;
  this.endAngle=endAngle;
  this.radius=radius;
  this.subActionItems=subActionItems;
  this.animationHandler=animationHandler;
  this.animated=animated;
  this.open=false;
  this.mainActionView.setClickable(true);
  this.mainActionView.setOnClickListener(new ActionViewClickListener());
  if (animationHandler != null) {
    animationHandler.setMenu(this);
  }
  for (  final Item item : subActionItems) {
    if (item.width == 0 || item.height == 0) {
      ((ViewGroup)getActivityContentView()).addView(item.view);
      item.view.setAlpha(0);
      item.view.post(new Runnable(){
        @Override public void run(){
          item.width=item.view.getMeasuredWidth();
          item.height=item.view.getMeasuredHeight();
          item.view.setAlpha(1);
          ((ViewGroup)getActivityContentView()).removeView(item.view);
        }
      }
);
    }
  }
}

Fixed version (ground truth):
/** 
 * Constructor that takes the parameters collected using   {@link FloatingActionMenu.Builder}
 * @param mainActionView
 * @param startAngle
 * @param endAngle
 * @param radius
 * @param subActionItems
 * @param animationHandler
 * @param animated
 */
public FloatingActionMenu(View mainActionView,int startAngle,int endAngle,int radius,ArrayList<Item> subActionItems,MenuAnimationHandler animationHandler,boolean animated){
  this.mainActionView=mainActionView;
  this.startAngle=startAngle;
  this.endAngle=endAngle;
  this.radius=radius;
  this.subActionItems=subActionItems;
  this.animationHandler=animationHandler;
  this.animated=animated;
  this.open=false;
  this.mainActionView.setClickable(true);
  this.mainActionView.setOnClickListener(new ActionViewClickListener());
  if (animationHandler != null) {
    animationHandler.setMenu(this);
  }
  for (  final Item item : subActionItems) {
    if (item.width == 0 || item.height == 0) {
      ((ViewGroup)getActivityContentView()).addView(item.view);
      item.view.setAlpha(0);
      item.view.post(new ItemViewQueueListener(item));
    }
  }
}
Program: 162348
Project: 162348
Buggy source:
public static NiftyDialogBuilder getInstance(Context context){
  int ort=context.getResources().getConfiguration().orientation;
  if (mOrientation != ort) {
    mOrientation=ort;
    instance=null;
  }
  if (instance == null && !((Activity)context).isFinishing()) {
synchronized (NiftyDialogBuilder.class) {
      if (instance == null) {
        instance=new NiftyDialogBuilder(context,R.style.dialog_untran);
      }
    }
  }
  return instance;
}

Fixed version (ground truth):
public static NiftyDialogBuilder getInstance(Context context){
  int ort=context.getResources().getConfiguration().orientation;
  if (mOrientation != ort) {
    mOrientation=ort;
    instance=null;
  }
  if (instance == null || ((Activity)context).isFinishing()) {
synchronized (NiftyDialogBuilder.class) {
      if (instance == null) {
        instance=new NiftyDialogBuilder(context,R.style.dialog_untran);
      }
    }
  }
  return instance;
}
Program: 162349
Project: 162349
Buggy source:
@Override public void show(){
  if (mTitle.getText().equals("String_Node_Str"))   mDialogView.findViewById(R.id.topPanel).setVisibility(View.GONE);
  super.show();
}

Fixed version (ground truth):
@Override public void show(){
  super.show();
}
Program: 162350
Project: 162350
Buggy source:
public static NiftyDialogBuilder getInstance(Context context){
  int ort=context.getResources().getConfiguration().orientation;
  if (mOrientation != ort) {
    mOrientation=ort;
    instance=null;
  }
  if (instance == null) {
synchronized (NiftyDialogBuilder.class) {
      if (instance == null) {
        instance=new NiftyDialogBuilder(context,R.style.dialog_untran);
      }
    }
  }
  return instance;
}

Fixed version (ground truth):
public static NiftyDialogBuilder getInstance(Context context){
  int ort=context.getResources().getConfiguration().orientation;
  if (mOrientation != ort) {
    mOrientation=ort;
    instance=null;
  }
  if (instance == null && !((Activity)context).isFinishing()) {
synchronized (NiftyDialogBuilder.class) {
      if (instance == null) {
        instance=new NiftyDialogBuilder(context,R.style.dialog_untran);
      }
    }
  }
  return instance;
}
Program: 162351
Project: 162351
Buggy source:
public static NiftyDialogBuilder getInstance(Context context){
  int ort=context.getResources().getConfiguration().orientation;
  if (mOrientation != ort) {
    mOrientation=ort;
    instance=null;
  }
  if (instance == null || ((Activity)context).isFinishing()) {
synchronized (NiftyDialogBuilder.class) {
      if (instance == null) {
        instance=new NiftyDialogBuilder(context,R.style.dialog_untran);
      }
    }
  }
  return instance;
}

Fixed version (ground truth):
public static NiftyDialogBuilder getInstance(Context context){
  instance=new NiftyDialogBuilder(context,R.style.dialog_untran);
  return instance;
}
Program: 162353
Project: 162353
Buggy source:
/** 
 * Run to doing something
 */
@Override public void run(){
  if (!mDone) {
synchronized (this) {
      if (!mDone) {
        call();
        mDone=true;
        try {
          this.notifyAll();
        }
 catch (        Exception ignored) {
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Run to doing something
 */
@Override public void run(){
  if (!mDone) {
synchronized (this) {
      if (!mDone) {
        mResult=call();
        mDone=true;
        try {
          this.notifyAll();
        }
 catch (        Exception ignored) {
        }
      }
    }
  }
}
Program: 162354
Project: 162354
Buggy source:
/** 
 * Sets the minimum value for this AbsSeekBar if the supplied argument is bigger than the Current MAX value, the MAX value will be set to MIN+1 <p> Also if the current progress is out of the new range, it will be set to MIN </p>
 * @param min Progress min value
 * @see #setMax(int)
 * @see #setProgress(int)
 */
public void setMin(int min){
  mMin=min;
  if (mMin > mMax) {
    setMax(mMin + 1);
  }
  updateKeyboardRange();
  mSeekBarDrawable.setNumSegments(mMax - mMin);
  if (mValue < mMin || mValue > mMax) {
    setProgress(mMin);
  }
}

Fixed version (ground truth):
/** 
 * Sets the minimum value for this AbsSeekBar if the supplied argument is bigger than the Current MAX value, the MAX value will be set to MIN+1 <p> Also if the current progress is out of the new range, it will be set to MIN </p>
 * @param min Progress min value
 * @see #setMax(int)
 * @see #setProgress(int)
 */
public void setMin(int min){
  mMin=min;
  if (mMin > mMax) {
    setMax(mMin + 1);
  }
  updateKeyboardRange();
  mSeekBarDrawable.setNumSegments(mMax - mMin);
  if (mValue < mMin || mValue > mMax) {
    setProgress(mMin);
  }
 else {
    updateThumbPosForScale(-1);
  }
}
Program: 162355
Project: 162355
Buggy source:
/** 
 * Sets the maximum value for this AbsSeekBar if the supplied argument is smaller than the Current MIN value, the MIN value will be set to MAX-1 <p/> <p> Also if the current progress is out of the new range, it will be set to MIN </p>
 * @param max Progress max value
 * @see #setMin(int)
 * @see #setProgress(int)
 */
public void setMax(int max){
  mMax=max;
  if (mMax < mMin) {
    setMin(mMax - 1);
  }
  updateKeyboardRange();
  mSeekBarDrawable.setNumSegments(mMax - mMin);
  if (mValue < mMin || mValue > mMax) {
    setProgress(mMin);
  }
}

Fixed version (ground truth):
/** 
 * Sets the maximum value for this AbsSeekBar if the supplied argument is smaller than the Current MIN value, the MIN value will be set to MAX-1 <p/> <p> Also if the current progress is out of the new range, it will be set to MIN </p>
 * @param max Progress max value
 * @see #setMin(int)
 * @see #setProgress(int)
 */
public void setMax(int max){
  mMax=max;
  if (mMax < mMin) {
    setMin(mMax - 1);
  }
  updateKeyboardRange();
  mSeekBarDrawable.setNumSegments(mMax - mMin);
  if (mValue < mMin || mValue > mMax) {
    setProgress(mMin);
  }
 else {
    updateThumbPosForScale(-1);
  }
}
Program: 162356
Project: 162356
Buggy source:
private void draw(Canvas canvas,Paint paint,int thumbColor,int colorLeft,int colorRight,float halfLeft,float halfRight){
  Rect bounds=getBounds();
  int thumbX=mPoint.x;
  int thumbY=mPoint.y;
  int startLeft=bounds.left + mTouchRadius;
  int startRight=bounds.right - mTouchRadius;
  if (halfLeft > 0) {
    paint.setColor(colorLeft);
    canvas.drawRect(startLeft,thumbY - halfLeft,thumbX,thumbY + halfLeft,paint);
  }
  if (halfRight > 0) {
    paint.setColor(colorRight);
    canvas.drawRect(thumbX,thumbY - halfRight,startRight,thumbY + halfRight,paint);
  }
  if (mTickRadius > halfRight) {
    for (int i=0; i <= mNumSegments; i++) {
      float x=startRight - i * mTickDistance;
      if (x <= thumbX)       break;
      canvas.drawCircle(x,thumbY,mTickRadius,paint);
    }
  }
  if (mThumbRadius > halfLeft) {
    paint.setColor(colorLeft);
    for (int i=0; i <= mNumSegments; i++) {
      float x=i * mTickDistance + startLeft;
      if (x > thumbX)       break;
      canvas.drawCircle(x,thumbY,mTickRadius,paint);
    }
  }
  if (!isOpen && mThumbRadius > 0) {
    paint.setColor(thumbColor);
    canvas.drawCircle(thumbX,thumbY,mThumbRadius,paint);
  }
}

Fixed version (ground truth):
private void draw(Canvas canvas,Paint paint,int thumbColor,int colorLeft,int colorRight,float halfLeft,float halfRight){
  Rect bounds=getBounds();
  int thumbX=mPoint.x;
  int thumbY=mPoint.y;
  int startLeft=bounds.left + mTouchRadius;
  int startRight=bounds.right - mTouchRadius;
  if (halfLeft > 0) {
    paint.setColor(colorLeft);
    canvas.drawRect(startLeft,thumbY - halfLeft,thumbX,thumbY + halfLeft,paint);
  }
  if (halfRight > 0) {
    paint.setColor(colorRight);
    canvas.drawRect(thumbX,thumbY - halfRight,startRight,thumbY + halfRight,paint);
  }
  if (mTickRadius > halfRight) {
    for (int i=0; i <= mNumSegments; i++) {
      float x=startRight - i * mTickDistance;
      if (x <= thumbX)       break;
      canvas.drawCircle(x,thumbY,mTickRadius,paint);
    }
  }
  if (mTickRadius > halfLeft) {
    paint.setColor(colorLeft);
    for (int i=0; i <= mNumSegments; i++) {
      float x=i * mTickDistance + startLeft;
      if (x > thumbX)       break;
      canvas.drawCircle(x,thumbY,mTickRadius,paint);
    }
  }
  if (!isOpen && mThumbRadius > 0) {
    paint.setColor(thumbColor);
    canvas.drawCircle(thumbX,thumbY,mThumbRadius,paint);
  }
}
Program: 162357
Project: 162357
Buggy source:
public void setNumSegments(int numSegments){
  this.mNumSegments=numSegments;
}

Fixed version (ground truth):
public void setNumSegments(int numSegments){
  this.mNumSegments=numSegments;
  this.mTickDistance=(float)this.mContentWidth / (float)numSegments;
}
Program: 162359
Project: 162359
Buggy source:
@Override protected void refresh(long startTime,long curTime,long timeLong){
  final float angle=ANGLE_ADD;
  mStartAngle+=angle;
  if (mStartAngle > 360) {
    mStartAngle-=360;
  }
  mSweepAngle+=mAngleIncrement;
  if (mSweepAngle > MAX_ANGLE_SWEEP) {
    mAngleIncrement=-mAngleIncrement;
  }
 else   if (mSweepAngle < 0) {
    mAngleIncrement=-mAngleIncrement;
    mSweepAngle=0;
    getNextForegroundColor();
  }
}

Fixed version (ground truth):
@Override protected void refresh(long startTime,long curTime,long timeLong){
  final float angle=ANGLE_ADD;
  mStartAngle+=angle;
  if (mStartAngle > 360) {
    mStartAngle-=360;
  }
  if (mSweepAngle > MAX_ANGLE_SWEEP) {
    mAngleIncrement=-mAngleIncrement;
  }
 else   if (mSweepAngle < MIN_ANGLE_SWEEP) {
    mSweepAngle=MIN_ANGLE_SWEEP;
    return;
  }
 else   if (mSweepAngle == MIN_ANGLE_SWEEP) {
    mAngleIncrement=-mAngleIncrement;
    getNextForegroundColor();
  }
  mSweepAngle+=mAngleIncrement;
}
Program: 162360
Project: 162360
Buggy source:
private void saveOrRecoveryRun(int visibility){
  if (visibility == VISIBLE) {
    if (mNeedRun) {
      start();
    }
  }
 else {
    if (mDrawable.isRunning()) {
      mNeedRun=true;
      mDrawable.stop();
    }
  }
}

Fixed version (ground truth):
private void saveOrRecoveryRun(int visibility){
  if (mDrawable == null) {
    return;
  }
  if (visibility == VISIBLE) {
    if (mNeedRun) {
      start();
    }
  }
 else {
    if (mDrawable.isRunning()) {
      mNeedRun=true;
      mDrawable.stop();
    }
  }
}
Program: 162361
Project: 162361
Buggy source:
@Override protected void onAttachedToWindow(){
  super.onAttachedToWindow();
  if (mAutoRun && mDrawable.getProgress() == 0)   mDrawable.start();
}

Fixed version (ground truth):
@Override protected void onAttachedToWindow(){
  super.onAttachedToWindow();
  if (mAutoRun && mDrawable.getProgress() == 0) {
    if (getVisibility() == VISIBLE)     mDrawable.start();
 else     mNeedRun=true;
  }
}
Program: 162362
Project: 162362
Buggy source:
/** 
 * Dispose unbindService stopService
 */
public static void dispose(){
synchronized (Command.class) {
    if (EXECUTORSERVICE != null) {
      try {
        EXECUTORSERVICE.shutdownNow();
      }
 catch (      Exception e) {
        e.printStackTrace();
      }
      EXECUTORSERVICE=null;
    }
    if (IS_BIND) {
      Context context=GeniusKit.getApplication();
      if (context != null) {
        try {
          context.unbindService(I_CONN);
        }
 catch (        Exception e) {
          e.printStackTrace();
        }
      }
      I_COMMAND=null;
      IS_BIND=false;
    }
  }
}

Fixed version (ground truth):
/** 
 * Dispose unbindService stopService
 */
public static void dispose(){
synchronized (Command.class) {
    if (EXECUTORSERVICE != null) {
      try {
        EXECUTORSERVICE.shutdownNow();
      }
 catch (      Exception e) {
        e.printStackTrace();
      }
      EXECUTORSERVICE=null;
    }
    if (IS_BIND) {
      Context context=Kit.getApplication();
      if (context != null) {
        try {
          context.unbindService(I_CONN);
        }
 catch (        Exception e) {
          e.printStackTrace();
        }
      }
      I_COMMAND=null;
      IS_BIND=false;
    }
  }
}
Program: 162363
Project: 162363
Buggy source:
/** 
 * Start bind Service
 */
private static void bindService(){
synchronized (Command.class) {
    if (!IS_BIND) {
      Context context=GeniusKit.getApplication();
      if (context == null) {
        throw new NullPointerException("String_Node_Str");
      }
 else {
        context.bindService(new Intent(context,CommandService.class),I_CONN,Context.BIND_AUTO_CREATE);
        IS_BIND=true;
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Start bind Service
 */
private static void bindService(){
synchronized (Command.class) {
    if (!IS_BIND) {
      Context context=Kit.getApplication();
      if (context == null) {
        throw new NullPointerException("String_Node_Str");
      }
 else {
        context.bindService(new Intent(context,CommandService.class),I_CONN,Context.BIND_AUTO_CREATE);
        IS_BIND=true;
      }
    }
  }
}
Program: 162364
Project: 162364
Buggy source:
/** 
 * Set whether to open the log storage; open the log will be stored in the software directory
 * @param isOpen    Open
 * @param fileCount File Count,Default 10 Size
 * @param fileSize  One File Size,Default 2Mb
 */
public static void setSaveLog(boolean isOpen,int fileCount,float fileSize){
  if (GeniusKit.getApplication() == null)   throw new NullPointerException("String_Node_Str");
  if (isOpen) {
    if (Writer == null)     Writer=new LogWriter(fileCount,fileSize,LogWriter.getDefaultLogPath());
  }
 else   if (Writer != null) {
    Writer.unRegisterBroadCast();
    Writer.done();
    Writer=null;
  }
}

Fixed version (ground truth):
/** 
 * Set whether to open the log storage; open the log will be stored in the software directory
 * @param isOpen    Open
 * @param fileCount File Count,Default 10 Size
 * @param fileSize  One File Size,Default 2Mb
 */
public static void setSaveLog(boolean isOpen,int fileCount,float fileSize){
  if (Kit.getApplication() == null)   throw new NullPointerException("String_Node_Str");
  if (isOpen) {
    if (Writer == null)     Writer=new LogWriter(fileCount,fileSize,LogWriter.getDefaultLogPath());
  }
 else   if (Writer != null) {
    Writer.unRegisterBroadCast();
    Writer.done();
    Writer=null;
  }
}
Program: 162365
Project: 162365
Buggy source:
/** 
 * get log file path
 */
protected static String getDefaultLogPath(){
  return GeniusKit.getApplication().getApplicationContext().getFilesDir().getAbsolutePath() + File.separator + "String_Node_Str"+ File.separator+ "String_Node_Str";
}

Fixed version (ground truth):
/** 
 * get log file path
 */
protected static String getDefaultLogPath(){
  return Kit.getApplication().getApplicationContext().getFilesDir().getAbsolutePath() + File.separator + "String_Node_Str"+ File.separator+ "String_Node_Str";
}
Program: 162366
Project: 162366
Buggy source:
/** 
 * unRegister Usb BroadCast
 */
protected void unRegisterBroadCast(){
  if (mUsbBroadCastReceiver != null) {
    GeniusKit.getApplication().unregisterReceiver(mUsbBroadCastReceiver);
    mUsbBroadCastReceiver=null;
  }
}

Fixed version (ground truth):
/** 
 * unRegister Usb BroadCast
 */
protected void unRegisterBroadCast(){
  if (mUsbBroadCastReceiver != null) {
    Kit.getApplication().unregisterReceiver(mUsbBroadCastReceiver);
    mUsbBroadCastReceiver=null;
  }
}
Program: 162367
Project: 162367
Buggy source:
/** 
 * register Usb BroadCast
 */
protected void registerBroadCast(String path){
  if (path != null && path.length() > 0)   mExternalStoragePath=path;
  unRegisterBroadCast();
  IntentFilter iFilter=new IntentFilter();
  iFilter.addAction(Intent.ACTION_MEDIA_MOUNTED);
  iFilter.addDataScheme("String_Node_Str");
  iFilter.setPriority(1000);
  mUsbBroadCastReceiver=new BroadcastReceiver(){
    @Override public void onReceive(    Context context,    Intent intent){
      String action=intent.getAction();
      if (action.equals(Intent.ACTION_MEDIA_MOUNTED)) {
        copyLogFile(mExternalStoragePath);
      }
    }
  }
;
  GeniusKit.getApplication().registerReceiver(mUsbBroadCastReceiver,iFilter);
}

Fixed version (ground truth):
/** 
 * register Usb BroadCast
 */
protected void registerBroadCast(String path){
  if (path != null && path.length() > 0)   mExternalStoragePath=path;
  unRegisterBroadCast();
  IntentFilter iFilter=new IntentFilter();
  iFilter.addAction(Intent.ACTION_MEDIA_MOUNTED);
  iFilter.addDataScheme("String_Node_Str");
  iFilter.setPriority(1000);
  mUsbBroadCastReceiver=new BroadcastReceiver(){
    @Override public void onReceive(    Context context,    Intent intent){
      String action=intent.getAction();
      if (action.equals(Intent.ACTION_MEDIA_MOUNTED)) {
        copyLogFile(mExternalStoragePath);
      }
    }
  }
;
  Kit.getApplication().registerReceiver(mUsbBroadCastReceiver,iFilter);
}
Program: 162369
Project: 162369
Buggy source:
@Override public boolean setState(int[] stateSet){
  int[] oldState=getState();
  boolean oldPressed=false;
  for (  int i : oldState) {
    if (i == android.R.attr.state_pressed) {
      oldPressed=true;
    }
  }
  boolean status=super.setState(stateSet);
  boolean focused=false;
  boolean pressed=false;
  for (  int i : stateSet) {
    if (i == android.R.attr.state_focused) {
      focused=true;
    }
 else     if (i == android.R.attr.state_pressed) {
      pressed=true;
    }
  }
  if (pressed) {
    animateToPressed();
  }
 else   if (oldPressed) {
    animateToNormal();
  }
 else   if (focused) {
    mCurrentScale=1f;
    invalidateSelf();
  }
 else {
    mCurrentScale=0;
    invalidateSelf();
  }
  return status;
}

Fixed version (ground truth):
@Override public boolean setState(int[] stateSet){
  if (stateSet == null)   return false;
  int[] oldState=getState();
  boolean oldPressed=false;
  for (  int i : oldState) {
    if (i == android.R.attr.state_pressed) {
      oldPressed=true;
    }
  }
  boolean status=super.setState(stateSet);
  boolean focused=false;
  boolean pressed=false;
  for (  int i : stateSet) {
    if (i == android.R.attr.state_focused) {
      focused=true;
    }
 else     if (i == android.R.attr.state_pressed) {
      pressed=true;
    }
  }
  if (pressed) {
    animateToPressed();
  }
 else   if (oldPressed) {
    animateToNormal();
  }
 else   if (focused) {
    mCurrentScale=1f;
    invalidateSelf();
  }
 else {
    mCurrentScale=0;
    invalidateSelf();
  }
  return status;
}
Program: 162370
Project: 162370
Buggy source:
@Override public boolean setState(int[] stateSet){
  boolean status=super.setState(stateSet);
  boolean oldChecked=mChecked;
  boolean oldEnabled=mEnabled;
  mChecked=false;
  mEnabled=true;
  for (  int i : stateSet) {
    if (i == android.R.attr.state_checked) {
      mChecked=true;
    }
 else     if (i == -android.R.attr.state_enabled) {
      mEnabled=false;
    }
  }
  if (status || oldChecked != mChecked || oldEnabled != mEnabled) {
    onStateChange(getColor(),oldChecked,mChecked);
    invalidateSelf();
  }
  return status;
}

Fixed version (ground truth):
@Override public boolean setState(int[] stateSet){
  if (stateSet == null)   return false;
  boolean status=super.setState(stateSet);
  boolean oldChecked=mChecked;
  boolean oldEnabled=mEnabled;
  mChecked=false;
  mEnabled=true;
  for (  int i : stateSet) {
    if (i == android.R.attr.state_checked) {
      mChecked=true;
    }
 else     if (i == -android.R.attr.state_enabled) {
      mEnabled=false;
    }
  }
  if (status || oldChecked != mChecked || oldEnabled != mEnabled) {
    onStateChange(getColor(),oldChecked,mChecked);
    invalidateSelf();
  }
  return status;
}
Program: 162371
Project: 162371
Buggy source:
@Override public boolean setState(int[] stateSet){
  boolean changed=super.setState(stateSet);
  changed=updateTintColor(stateSet) || changed;
  return changed;
}

Fixed version (ground truth):
@Override public boolean setState(int[] stateSet){
  if (stateSet == null)   return false;
  boolean changed=super.setState(stateSet);
  changed=updateTintColor(stateSet) || changed;
  return changed;
}
Program: 162372
Project: 162372
Buggy source:
private void init(AttributeSet attrs,int defStyleAttr,int defStyleRes){
  if (attrs == null)   return;
  final Context context=getContext();
  final Resources resource=getResources();
  final float density=resource.getDisplayMetrics().density;
  int baseSize=(int)(density * 2);
  final TypedArray a=context.obtainStyledAttributes(attrs,R.styleable.CheckBox,defStyleAttr,defStyleRes);
  int borderSize=a.getDimensionPixelOffset(R.styleable.CheckBox_gBorderSize,baseSize);
  int intervalSize=a.getDimensionPixelOffset(R.styleable.CheckBox_gIntervalSize,baseSize);
  int markSize=a.getDimensionPixelOffset(R.styleable.CheckBox_gMarkSize,-1);
  ColorStateList color=a.getColorStateList(R.styleable.CheckBox_gMarkColor);
  String fontFile=a.getString(R.styleable.CheckBox_gFont);
  a.recycle();
  if (color == null)   color=resource.getColorStateList(R.color.g_default_check_box);
  boolean isCustom=true;
  if (markSize < 0) {
    markSize=(int)(density * 22);
    isCustom=false;
  }
  mMarkDrawable=new CircleCheckDrawable(color);
  mMarkDrawable.setBorderSize(borderSize);
  mMarkDrawable.setIntervalSize(intervalSize);
  mMarkDrawable.setMarkSize(markSize,isCustom);
  setButtonDrawable(mMarkDrawable);
  refreshDrawableState();
  if (!this.isInEditMode()) {
    if (fontFile != null && fontFile.length() > 0) {
      Typeface typeface=Ui.getFont(getContext(),fontFile);
      if (typeface != null)       setTypeface(typeface);
    }
  }
}

Fixed version (ground truth):
private void init(AttributeSet attrs,int defStyleAttr,int defStyleRes){
  if (attrs == null)   return;
  final Context context=getContext();
  final Resources resource=getResources();
  final float density=resource.getDisplayMetrics().density;
  int baseSize=(int)(density * 2);
  final TypedArray a=context.obtainStyledAttributes(attrs,R.styleable.CheckBox,defStyleAttr,defStyleRes);
  int borderSize=a.getDimensionPixelOffset(R.styleable.CheckBox_gBorderSize,baseSize);
  int intervalSize=a.getDimensionPixelOffset(R.styleable.CheckBox_gIntervalSize,baseSize);
  int markSize=a.getDimensionPixelOffset(R.styleable.CheckBox_gMarkSize,-1);
  ColorStateList color=a.getColorStateList(R.styleable.CheckBox_gMarkColor);
  String fontFile=a.getString(R.styleable.CheckBox_gFont);
  a.recycle();
  if (color == null)   color=resource.getColorStateList(R.color.g_default_check_box);
  boolean isCustom=true;
  if (markSize < 0) {
    markSize=(int)(density * 22);
    isCustom=false;
  }
  mMarkDrawable=new CircleCheckDrawable(color);
  mMarkDrawable.setBorderSize(borderSize);
  mMarkDrawable.setIntervalSize(intervalSize);
  mMarkDrawable.setMarkSize(markSize,isCustom);
  setButtonDrawable(mMarkDrawable);
  if (!this.isInEditMode()) {
    if (fontFile != null && fontFile.length() > 0) {
      Typeface typeface=Ui.getFont(getContext(),fontFile);
      if (typeface != null)       setTypeface(typeface);
    }
  }
}
Program: 162373
Project: 162373
Buggy source:
private void initHintTitleText(){
  if (isShowTitle()) {
    mCurTitleProperty=new TitleProperty();
    if (mTitlePaint == null) {
      mTitlePaint=new TextPaint();
      mTitlePaint.setFlags(Paint.ANTI_ALIAS_FLAG);
      mTitlePaint.setTextAlign(Paint.Align.LEFT);
      mTitlePaint.setTypeface(getTypeface());
    }
    if (mTextWatcher == null) {
      mTextWatcher=new TextWatcher(){
        @Override public void beforeTextChanged(        CharSequence s,        int start,        int count,        int after){
        }
        @Override public void onTextChanged(        CharSequence s,        int start,        int before,        int count){
        }
        @Override public void afterTextChanged(        Editable s){
          if (isShowTitle()) {
            boolean have=s != null && s.length() > 0;
            if (have != isHaveText) {
              isHaveText=have;
              animateShowTitle(isHaveText);
            }
          }
        }
      }
;
      addTextChangedListener(mTextWatcher);
    }
    Editable editable=getText();
    animateShowTitle(editable != null && editable.length() > 0);
  }
 else {
    if (mTextWatcher != null) {
      removeTextChangedListener(mTextWatcher);
      mTextWatcher=null;
    }
    mTitlePaint=null;
    mCurTitleProperty=null;
    mAnimator=null;
  }
}

Fixed version (ground truth):
private void initHintTitleText(){
  if (isShowTitle()) {
    mCurTitleProperty=new TitleProperty();
    if (mTitlePaint == null) {
      mTitlePaint=new TextPaint(Paint.ANTI_ALIAS_FLAG);
      mTitlePaint.density=getResources().getDisplayMetrics().density;
      mTitlePaint.setTextAlign(Paint.Align.LEFT);
      mTitlePaint.setTypeface(getTypeface());
    }
    if (mTextWatcher == null) {
      mTextWatcher=new TextWatcher(){
        @Override public void beforeTextChanged(        CharSequence s,        int start,        int count,        int after){
        }
        @Override public void onTextChanged(        CharSequence s,        int start,        int before,        int count){
        }
        @Override public void afterTextChanged(        Editable s){
          if (isShowTitle()) {
            boolean have=s != null && s.length() > 0;
            if (have != isHaveText) {
              isHaveText=have;
              animateShowTitle(isHaveText);
            }
          }
        }
      }
;
      addTextChangedListener(mTextWatcher);
    }
    Editable editable=getText();
    animateShowTitle(editable != null && editable.length() > 0);
  }
 else {
    if (mTextWatcher != null) {
      removeTextChangedListener(mTextWatcher);
      mTextWatcher=null;
    }
    mTitlePaint=null;
    mCurTitleProperty=null;
    mAnimator=null;
  }
}
Program: 162374
Project: 162374
Buggy source:
@Override protected void onDraw(Canvas canvas){
  super.onDraw(canvas);
  if (isShowTitle() && mTitlePaint != null && mCurTitleProperty != null && mCurTitleProperty.mAlpha != 0) {
    CharSequence buf=getHint();
    if (buf != null) {
      mTitlePaint.setTextSize(mCurTitleProperty.mTextSize);
      int color=getCurrentHintTextColor();
      int alpha=Ui.modulateAlpha(Color.alpha(color),mCurTitleProperty.mAlpha);
      if (color != 0 && alpha != 0) {
        mTitlePaint.setColor(color);
        mTitlePaint.setAlpha(alpha);
        canvas.drawText(buf,0,buf.length(),mCurTitleProperty.mLeft,mCurTitleProperty.mTop + mCurTitleProperty.mTextSize,mTitlePaint);
      }
    }
  }
}

Fixed version (ground truth):
@Override protected void onDraw(Canvas canvas){
  super.onDraw(canvas);
  if (isShowTitle() && mTitlePaint != null && mCurTitleProperty != null && mCurTitleProperty.mAlpha != 0) {
    CharSequence buf=getHint();
    if (buf != null) {
      int color=getCurrentHintTextColor();
      int alpha=Ui.modulateAlpha(Color.alpha(color),mCurTitleProperty.mAlpha);
      if (color != 0 && alpha != 0) {
        mTitlePaint.setTextSize(mCurTitleProperty.mTextSize);
        mTitlePaint.setColor(color);
        mTitlePaint.setAlpha(alpha);
        final int scrollX=getScrollX();
        final int scrollY=getScrollY();
        if ((scrollX | scrollY) == 0) {
          canvas.drawText(buf,0,buf.length(),mCurTitleProperty.mLeft,mCurTitleProperty.mTop + mCurTitleProperty.mTextSize,mTitlePaint);
        }
 else {
          canvas.translate(scrollX,scrollY);
          canvas.drawText(buf,0,buf.length(),mCurTitleProperty.mLeft,mCurTitleProperty.mTop + mCurTitleProperty.mTextSize,mTitlePaint);
          canvas.translate(-scrollX,-scrollY);
        }
      }
    }
  }
}
Program: 162375
Project: 162375
Buggy source:
public void animateToNormal(){
  unscheduleSelf(mUpdater);
  if (mCurrentScale > INACTIVE_SCALE) {
    mReverse=true;
    mRunning=true;
    mAnimationInitialValue=mCurrentScale;
    float durationFactor=1f - ((mAnimationInitialValue - ACTIVE_SCALE) / (INACTIVE_SCALE - ACTIVE_SCALE));
    mDuration=(int)(ANIMATION_DURATION * durationFactor);
    mStartTime=SystemClock.uptimeMillis();
    scheduleSelf(mUpdater,mStartTime + FRAME_DURATION);
  }
}

Fixed version (ground truth):
public void animateToNormal(){
  unscheduleSelf(mUpdater);
  if (mCurrentScale > 0) {
    mReverse=true;
    mRunning=true;
    mAnimationInitialValue=mCurrentScale;
    float durationFactor=mAnimationInitialValue;
    mDuration=(int)(Ui.ANIMATION_DURATION * durationFactor);
    mStartTime=SystemClock.uptimeMillis();
    scheduleSelf(mUpdater,mStartTime + Ui.FRAME_DURATION);
  }
}
Program: 162376
Project: 162376
Buggy source:
@Override public boolean setState(int[] stateSet){
  int[] oldState=getState();
  boolean oldPressed=false;
  for (  int i : oldState) {
    if (i == android.R.attr.state_pressed) {
      oldPressed=true;
    }
  }
  boolean status=super.setState(stateSet);
  boolean focused=false;
  boolean pressed=false;
  for (  int i : stateSet) {
    if (i == android.R.attr.state_focused) {
      focused=true;
    }
 else     if (i == android.R.attr.state_pressed) {
      pressed=true;
    }
  }
  if (pressed) {
    animateToPressed();
  }
 else   if (oldPressed) {
    animateToNormal();
  }
 else   if (focused) {
    mCurrentScale=ACTIVE_SCALE;
    invalidateSelf();
  }
 else {
    mCurrentScale=INACTIVE_SCALE;
    invalidateSelf();
  }
  return status;
}

Fixed version (ground truth):
@Override public boolean setState(int[] stateSet){
  int[] oldState=getState();
  boolean oldPressed=false;
  for (  int i : oldState) {
    if (i == android.R.attr.state_pressed) {
      oldPressed=true;
    }
  }
  boolean status=super.setState(stateSet);
  boolean focused=false;
  boolean pressed=false;
  for (  int i : stateSet) {
    if (i == android.R.attr.state_focused) {
      focused=true;
    }
 else     if (i == android.R.attr.state_pressed) {
      pressed=true;
    }
  }
  if (pressed) {
    animateToPressed();
  }
 else   if (oldPressed) {
    animateToNormal();
  }
 else   if (focused) {
    mCurrentScale=1f;
    invalidateSelf();
  }
 else {
    mCurrentScale=0;
    invalidateSelf();
  }
  return status;
}
Program: 162377
Project: 162377
Buggy source:
public void animateToPressed(){
  unscheduleSelf(mUpdater);
  if (mCurrentScale < ACTIVE_SCALE) {
    mReverse=false;
    mRunning=true;
    mAnimationInitialValue=mCurrentScale;
    float durationFactor=1f - ((mAnimationInitialValue - INACTIVE_SCALE) / (ACTIVE_SCALE - INACTIVE_SCALE));
    mDuration=(int)(ANIMATION_DURATION * durationFactor);
    mStartTime=SystemClock.uptimeMillis();
    scheduleSelf(mUpdater,mStartTime + FRAME_DURATION);
  }
}

Fixed version (ground truth):
public void animateToPressed(){
  unscheduleSelf(mUpdater);
  if (mCurrentScale < 1f) {
    mReverse=false;
    mRunning=true;
    mAnimationInitialValue=mCurrentScale;
    float durationFactor=1f - mAnimationInitialValue;
    mDuration=(int)(Ui.ANIMATION_DURATION * durationFactor);
    mStartTime=SystemClock.uptimeMillis();
    scheduleSelf(mUpdater,mStartTime + Ui.FRAME_DURATION);
  }
}