nus-yam/ex-repair huggingface dataset:
Program: 170578
Project: 170578
Buggy source:
@Override protected void onAttachedToWindow(){
  super.onAttachedToWindow();
  mDisplayOrientationDetector.enable(ViewCompat.isAttachedToWindow(this) ? DisplayManagerCompat.getInstance(getContext()).getDisplay(Display.DEFAULT_DISPLAY) : null);
}

Fixed version (ground truth):
@Override protected void onAttachedToWindow(){
  super.onAttachedToWindow();
  if (!isInEditMode()) {
    mDisplayOrientationDetector.enable(ViewCompat.isAttachedToWindow(this) ? DisplayManagerCompat.getInstance(getContext()).getDisplay(Display.DEFAULT_DISPLAY) : null);
  }
}
Program: 170580
Project: 170580
Buggy source:
@Override protected void onDetachedFromWindow(){
  mDisplayOrientationDetector.disable();
  super.onDetachedFromWindow();
}

Fixed version (ground truth):
@Override protected void onDetachedFromWindow(){
  if (!isInEditMode()) {
    mDisplayOrientationDetector.disable();
  }
  super.onDetachedFromWindow();
}
Program: 170581
Project: 170581
Buggy source:
@Override protected void onAttachedToWindow(){
  super.onAttachedToWindow();
  mDisplayOrientationDetector.enable(ViewCompat.isAttachedToWindow(this) ? DisplayManagerCompat.getInstance(getContext()).getDisplay(Display.DEFAULT_DISPLAY) : null);
}

Fixed version (ground truth):
@Override protected void onAttachedToWindow(){
  super.onAttachedToWindow();
  if (!isInEditMode()) {
    mDisplayOrientationDetector.enable(ViewCompat.isAttachedToWindow(this) ? DisplayManagerCompat.getInstance(getContext()).getDisplay(Display.DEFAULT_DISPLAY) : null);
  }
}
Program: 170583
Project: 170583
Buggy source:
@Override protected void onAttachedToWindow(){
  super.onAttachedToWindow();
  mDisplayOrientationDetector.enable(ViewCompat.isAttachedToWindow(this) ? DisplayManagerCompat.getInstance(getContext()).getDisplay(Display.DEFAULT_DISPLAY) : null);
}

Fixed version (ground truth):
@Override protected void onAttachedToWindow(){
  super.onAttachedToWindow();
  if (!isInEditMode()) {
    mDisplayOrientationDetector.enable(ViewCompat.isAttachedToWindow(this) ? DisplayManagerCompat.getInstance(getContext()).getDisplay(Display.DEFAULT_DISPLAY) : null);
  }
}
Program: 170585
Project: 170585
Buggy source:
/** 
 * As far as I can see, this extends either width or height of the surface, to match the desired aspect ratio. This means that the external part of the surface will be cropped by the outer view.
 */
protected void refreshScale(){
  getView().post(new Runnable(){
    @Override public void run(){
      if (mDesiredWidth != 0 && mDesiredHeight != 0) {
        AspectRatio aspectRatio=AspectRatio.of(mDesiredWidth,mDesiredHeight);
        int targetHeight=(int)(getView().getWidth() * aspectRatio.toFloat());
        float scaleY;
        if (getView().getHeight() > 0) {
          scaleY=(float)targetHeight / (float)getView().getHeight();
        }
 else {
          scaleY=1;
        }
        if (scaleY > 1) {
          getView().setScaleX(1);
          getView().setScaleY(scaleY);
        }
 else {
          getView().setScaleX(1 / scaleY);
          getView().setScaleY(1);
        }
      }
    }
  }
);
}

Fixed version (ground truth):
/** 
 * As far as I can see, this extends either width or height of the surface, to match the desired aspect ratio. This means that the external part of the surface will be cropped by the outer view.
 */
private void refreshScale(){
  getView().post(new Runnable(){
    @Override public void run(){
      if (mDesiredWidth != 0 && mDesiredHeight != 0) {
        AspectRatio aspectRatio=AspectRatio.of(mDesiredWidth,mDesiredHeight);
        float targetHeight=(float)mSurfaceWidth / aspectRatio.toFloat();
        float scale=1;
        if (mSurfaceHeight > 0) {
          scale=targetHeight / (float)mSurfaceHeight;
        }
        if (scale > 1) {
          getView().setScaleX(1f);
          getView().setScaleY(scale);
        }
 else {
          getView().setScaleX(1f / scale);
          getView().setScaleY(1f);
        }
      }
    }
  }
);
}
Program: 170586
Project: 170586
Buggy source:
@Override public void run(){
  if (mDesiredWidth != 0 && mDesiredHeight != 0) {
    AspectRatio aspectRatio=AspectRatio.of(mDesiredWidth,mDesiredHeight);
    int targetHeight=(int)(getView().getWidth() * aspectRatio.toFloat());
    float scaleY;
    if (getView().getHeight() > 0) {
      scaleY=(float)targetHeight / (float)getView().getHeight();
    }
 else {
      scaleY=1;
    }
    if (scaleY > 1) {
      getView().setScaleX(1);
      getView().setScaleY(scaleY);
    }
 else {
      getView().setScaleX(1 / scaleY);
      getView().setScaleY(1);
    }
  }
}

Fixed version (ground truth):
@Override public void run(){
  if (mDesiredWidth != 0 && mDesiredHeight != 0) {
    AspectRatio aspectRatio=AspectRatio.of(mDesiredWidth,mDesiredHeight);
    float targetHeight=(float)mSurfaceWidth / aspectRatio.toFloat();
    float scale=1;
    if (mSurfaceHeight > 0) {
      scale=targetHeight / (float)mSurfaceHeight;
    }
    if (scale > 1) {
      getView().setScaleX(1f);
      getView().setScaleY(scale);
    }
 else {
      getView().setScaleX(1f / scale);
      getView().setScaleY(1f);
    }
  }
}
Program: 170587
Project: 170587
Buggy source:
TextureViewPreview(Context context,ViewGroup parent){
  final View view=View.inflate(context,R.layout.texture_view,parent);
  mTextureView=(TextureView)view.findViewById(R.id.texture_view);
  mTextureView.setSurfaceTextureListener(new TextureView.SurfaceTextureListener(){
    @Override public void onSurfaceTextureAvailable(    SurfaceTexture surface,    int width,    int height){
      setSurfaceSize(width,height);
      dispatchSurfaceChanged();
    }
    @Override public void onSurfaceTextureSizeChanged(    SurfaceTexture surface,    int width,    int height){
      setSurfaceSize(width,height);
      dispatchSurfaceChanged();
      refreshScale();
    }
    @Override public boolean onSurfaceTextureDestroyed(    SurfaceTexture surface){
      setSurfaceSize(0,0);
      return true;
    }
    @Override public void onSurfaceTextureUpdated(    SurfaceTexture surface){
    }
  }
);
}

Fixed version (ground truth):
TextureViewPreview(Context context,ViewGroup parent){
  final View view=View.inflate(context,R.layout.texture_view,parent);
  mTextureView=(TextureView)view.findViewById(R.id.texture_view);
  mTextureView.setSurfaceTextureListener(new TextureView.SurfaceTextureListener(){
    @Override public void onSurfaceTextureAvailable(    SurfaceTexture surface,    int width,    int height){
      setSurfaceSize(width,height);
      dispatchSurfaceChanged();
    }
    @Override public void onSurfaceTextureSizeChanged(    SurfaceTexture surface,    int width,    int height){
      setSurfaceSize(width,height);
      dispatchSurfaceChanged();
    }
    @Override public boolean onSurfaceTextureDestroyed(    SurfaceTexture surface){
      setSurfaceSize(0,0);
      return true;
    }
    @Override public void onSurfaceTextureUpdated(    SurfaceTexture surface){
    }
  }
);
}
Program: 170588
Project: 170588
Buggy source:
@Override public void onSurfaceTextureSizeChanged(SurfaceTexture surface,int width,int height){
  setSurfaceSize(width,height);
  dispatchSurfaceChanged();
  refreshScale();
}

Fixed version (ground truth):
@Override public void onSurfaceTextureSizeChanged(SurfaceTexture surface,int width,int height){
  setSurfaceSize(width,height);
  dispatchSurfaceChanged();
}
Program: 170589
Project: 170589
Buggy source:
@Override void captureImage(){
switch (mMethod) {
case METHOD_STANDARD:
    mCamera.takePicture(null,null,null,new Camera.PictureCallback(){
      @Override public void onPictureTaken(      byte[] data,      Camera camera){
        mCameraListener.onPictureTaken(data);
        camera.startPreview();
      }
    }
);
  break;
case METHOD_STILL:
mCamera.setOneShotPreviewCallback(new Camera.PreviewCallback(){
  @Override public void onPreviewFrame(  byte[] data,  Camera camera){
    new Thread(new ProcessStillTask(data,camera,mCameraInfo,new ProcessStillTask.OnStillProcessedListener(){
      @Override public void onStillProcessed(      final YuvImage yuv){
        mCameraListener.onPictureTaken(yuv);
      }
    }
)).start();
  }
}
);
break;
}
}

Fixed version (ground truth):
@Override void captureImage(){
switch (mMethod) {
case METHOD_STANDARD:
    mCamera.takePicture(null,null,null,new Camera.PictureCallback(){
      @Override public void onPictureTaken(      byte[] data,      Camera camera){
        mCameraListener.onPictureTaken(data);
        camera.startPreview();
      }
    }
);
  break;
case METHOD_STILL:
mCamera.setOneShotPreviewCallback(new Camera.PreviewCallback(){
  @Override public void onPreviewFrame(  byte[] data,  Camera camera){
    new Thread(new ProcessStillTask(data,camera,calculateCaptureRotation(),new ProcessStillTask.OnStillProcessedListener(){
      @Override public void onStillProcessed(      final YuvImage yuv){
        mCameraListener.onPictureTaken(yuv);
      }
    }
)).start();
  }
}
);
break;
}
}
Program: 170590
Project: 170590
Buggy source:
private void openCamera(){
  if (mCamera != null) {
    releaseCamera();
  }
  mCamera=Camera.open(mCameraId);
  mCameraParameters=mCamera.getParameters();
  adjustCameraParameters();
  mCamera.setDisplayOrientation(calculateCameraRotation(mDisplayOrientation));
  mCameraListener.onCameraOpened();
}

Fixed version (ground truth):
private void openCamera(){
  if (mCamera != null) {
    releaseCamera();
  }
  mCamera=Camera.open(mCameraId);
  mCameraParameters=mCamera.getParameters();
  adjustCameraParameters();
  mCamera.setDisplayOrientation(calculatePreviewRotation());
  mCameraListener.onCameraOpened();
}
Program: 170591
Project: 170591
Buggy source:
@Override public void onPreviewFrame(byte[] data,Camera camera){
  new Thread(new ProcessStillTask(data,camera,mCameraInfo,new ProcessStillTask.OnStillProcessedListener(){
    @Override public void onStillProcessed(    final YuvImage yuv){
      mCameraListener.onPictureTaken(yuv);
    }
  }
)).start();
}

Fixed version (ground truth):
@Override public void onPreviewFrame(byte[] data,Camera camera){
  new Thread(new ProcessStillTask(data,camera,calculateCaptureRotation(),new ProcessStillTask.OnStillProcessedListener(){
    @Override public void onStillProcessed(    final YuvImage yuv){
      mCameraListener.onPictureTaken(yuv);
    }
  }
)).start();
}
Program: 170592
Project: 170592
Buggy source:
private void adjustCameraParameters(){
  boolean invertPreviewSizes=mDisplayOrientation % 180 != 0;
  mPreview.setTruePreviewSize(invertPreviewSizes ? getPreviewResolution().getHeight() : getPreviewResolution().getWidth(),invertPreviewSizes ? getPreviewResolution().getWidth() : getPreviewResolution().getHeight());
  mCameraParameters.setPreviewSize(getPreviewResolution().getWidth(),getPreviewResolution().getHeight());
  mCameraParameters.setPictureSize(getCaptureResolution().getWidth(),getCaptureResolution().getHeight());
  int rotation=(calculateCameraRotation(mDisplayOrientation) + (mFacing == CameraKit.Constants.FACING_FRONT ? 180 : 0)) % 360;
  mCameraParameters.setRotation(rotation);
  setFocus(mFocus);
  setFlash(mFlash);
  mCamera.setParameters(mCameraParameters);
}

Fixed version (ground truth):
private void adjustCameraParameters(){
  boolean invertPreviewSizes=mDisplayOrientation % 180 != 0;
  mPreview.setTruePreviewSize(invertPreviewSizes ? getPreviewResolution().getHeight() : getPreviewResolution().getWidth(),invertPreviewSizes ? getPreviewResolution().getWidth() : getPreviewResolution().getHeight());
  mCameraParameters.setPreviewSize(getPreviewResolution().getWidth(),getPreviewResolution().getHeight());
  mCameraParameters.setPictureSize(getCaptureResolution().getWidth(),getCaptureResolution().getHeight());
  int rotation=calculateCaptureRotation();
  mCameraParameters.setRotation(rotation);
  setFocus(mFocus);
  setFlash(mFlash);
  mCamera.setParameters(mCameraParameters);
}
Program: 170593
Project: 170593
Buggy source:
public ProcessStillTask(byte[] data,Camera camera,Camera.CameraInfo cameraInfo,OnStillProcessedListener onStillProcessedListener){
  this.data=data;
  this.camera=camera;
  this.cameraInfo=cameraInfo;
  this.onStillProcessedListener=onStillProcessedListener;
}

Fixed version (ground truth):
public ProcessStillTask(byte[] data,Camera camera,int rotation,OnStillProcessedListener onStillProcessedListener){
  this.data=data;
  this.camera=camera;
  this.rotation=rotation;
  this.onStillProcessedListener=onStillProcessedListener;
}
Program: 170594
Project: 170594
Buggy source:
@Override public void run(){
  Camera.Parameters parameters=camera.getParameters();
  int width=parameters.getPreviewSize().width;
  int height=parameters.getPreviewSize().height;
  int rotation=cameraInfo.orientation;
  byte[] rotatedData=new Rotation(data,width,height,rotation).getYuv();
  int postWidth;
  int postHeight;
switch (rotation) {
case 90:
case 270:
    postWidth=height;
  postHeight=width;
break;
case 0:
case 180:
default :
postWidth=width;
postHeight=height;
break;
}
YuvImage yuv=new YuvImage(rotatedData,parameters.getPreviewFormat(),postWidth,postHeight,null);
onStillProcessedListener.onStillProcessed(yuv);
}

Fixed version (ground truth):
@Override public void run(){
  Camera.Parameters parameters=camera.getParameters();
  int width=parameters.getPreviewSize().width;
  int height=parameters.getPreviewSize().height;
  byte[] rotatedData=new Rotation(data,width,height,rotation).getYuv();
  int postWidth;
  int postHeight;
switch (rotation) {
case 90:
case 270:
    postWidth=height;
  postHeight=width;
break;
case 0:
case 180:
default :
postWidth=width;
postHeight=height;
break;
}
YuvImage yuv=new YuvImage(rotatedData,parameters.getPreviewFormat(),postWidth,postHeight,null);
onStillProcessedListener.onStillProcessed(yuv);
}
Program: 170595
Project: 170595
Buggy source:
private void adjustCameraParameters(){
  mPreview.setTruePreviewSize(getPreviewResolution().getWidth(),getPreviewResolution().getHeight());
  mCameraParameters.setPreviewSize(getPreviewResolution().getWidth(),getPreviewResolution().getHeight());
  mCameraParameters.setPictureSize(getCaptureResolution().getWidth(),getCaptureResolution().getHeight());
  int rotation=(calculateCameraRotation(mDisplayOrientation) + (mFacing == CameraKit.Constants.FACING_FRONT ? 180 : 0)) % 360;
  mCameraParameters.setRotation(rotation);
  setFocus(mFocus);
  setFlash(mFlash);
  mCamera.setParameters(mCameraParameters);
}

Fixed version (ground truth):
private void adjustCameraParameters(){
  boolean invertPreviewSizes=mDisplayOrientation % 180 != 0;
  mPreview.setTruePreviewSize(invertPreviewSizes ? getPreviewResolution().getHeight() : getPreviewResolution().getWidth(),invertPreviewSizes ? getPreviewResolution().getWidth() : getPreviewResolution().getHeight());
  mCameraParameters.setPreviewSize(getPreviewResolution().getWidth(),getPreviewResolution().getHeight());
  mCameraParameters.setPictureSize(getCaptureResolution().getWidth(),getCaptureResolution().getHeight());
  int rotation=(calculateCameraRotation(mDisplayOrientation) + (mFacing == CameraKit.Constants.FACING_FRONT ? 180 : 0)) % 360;
  mCameraParameters.setRotation(rotation);
  setFocus(mFocus);
  setFlash(mFlash);
  mCamera.setParameters(mCameraParameters);
}
Program: 170596
Project: 170596
Buggy source:
@Override public void onSurfaceTextureAvailable(SurfaceTexture surface,int width,int height){
  setSize(width,height);
  configureTransform();
  dispatchSurfaceChanged();
}

Fixed version (ground truth):
@Override public void onSurfaceTextureAvailable(SurfaceTexture surface,int width,int height){
  setSize(width,height);
  dispatchSurfaceChanged();
}
Program: 170597
Project: 170597
Buggy source:
@Override public void onSurfaceTextureSizeChanged(SurfaceTexture surface,int width,int height){
  setSize(width,height);
  configureTransform();
  dispatchSurfaceChanged();
  setTruePreviewSize(mTrueWidth,mTrueHeight);
}

Fixed version (ground truth):
@Override public void onSurfaceTextureSizeChanged(SurfaceTexture surface,int width,int height){
  setSize(width,height);
  dispatchSurfaceChanged();
  setTruePreviewSize(mTrueWidth,mTrueHeight);
}
Program: 170598
Project: 170598
Buggy source:
@Override void setDisplayOrientation(int displayOrientation){
  mDisplayOrientation=displayOrientation;
  configureTransform();
}

Fixed version (ground truth):
@Override void setDisplayOrientation(int displayOrientation){
  mDisplayOrientation=displayOrientation;
}
Program: 170599
Project: 170599
Buggy source:
TextureViewPreview(Context context,ViewGroup parent){
  final View view=View.inflate(context,R.layout.texture_view,parent);
  mTextureView=(TextureView)view.findViewById(R.id.texture_view);
  mTextureView.setSurfaceTextureListener(new TextureView.SurfaceTextureListener(){
    @Override public void onSurfaceTextureAvailable(    SurfaceTexture surface,    int width,    int height){
      setSize(width,height);
      configureTransform();
      dispatchSurfaceChanged();
    }
    @Override public void onSurfaceTextureSizeChanged(    SurfaceTexture surface,    int width,    int height){
      setSize(width,height);
      configureTransform();
      dispatchSurfaceChanged();
      setTruePreviewSize(mTrueWidth,mTrueHeight);
    }
    @Override public boolean onSurfaceTextureDestroyed(    SurfaceTexture surface){
      setSize(0,0);
      return true;
    }
    @Override public void onSurfaceTextureUpdated(    SurfaceTexture surface){
    }
  }
);
}

Fixed version (ground truth):
TextureViewPreview(Context context,ViewGroup parent){
  final View view=View.inflate(context,R.layout.texture_view,parent);
  mTextureView=(TextureView)view.findViewById(R.id.texture_view);
  mTextureView.setSurfaceTextureListener(new TextureView.SurfaceTextureListener(){
    @Override public void onSurfaceTextureAvailable(    SurfaceTexture surface,    int width,    int height){
      setSize(width,height);
      dispatchSurfaceChanged();
    }
    @Override public void onSurfaceTextureSizeChanged(    SurfaceTexture surface,    int width,    int height){
      setSize(width,height);
      dispatchSurfaceChanged();
      setTruePreviewSize(mTrueWidth,mTrueHeight);
    }
    @Override public boolean onSurfaceTextureDestroyed(    SurfaceTexture surface){
      setSize(0,0);
      return true;
    }
    @Override public void onSurfaceTextureUpdated(    SurfaceTexture surface){
    }
  }
);
}
Program: 170600
Project: 170600
Buggy source:
private void adjustCameraParameters(){
  mPreview.setTruePreviewSize(getPreviewResolution().getWidth(),getPreviewResolution().getHeight());
  mCameraParameters.setPreviewSize(getPreviewResolution().getWidth(),getPreviewResolution().getHeight());
  mCameraParameters.setPictureSize(getCaptureResolution().getWidth(),getCaptureResolution().getHeight());
  mCameraParameters.setRotation(calculateCameraRotation(mDisplayOrientation) + (mFacing == CameraKit.Constants.FACING_FRONT ? 180 : 0));
  setFocus(mFocus);
  setFlash(mFlash);
  mCamera.setParameters(mCameraParameters);
}

Fixed version (ground truth):
private void adjustCameraParameters(){
  mPreview.setTruePreviewSize(getPreviewResolution().getWidth(),getPreviewResolution().getHeight());
  mCameraParameters.setPreviewSize(getPreviewResolution().getWidth(),getPreviewResolution().getHeight());
  mCameraParameters.setPictureSize(getCaptureResolution().getWidth(),getCaptureResolution().getHeight());
  int rotation=(calculateCameraRotation(mDisplayOrientation) + (mFacing == CameraKit.Constants.FACING_FRONT ? 180 : 0)) % 360;
  mCameraParameters.setRotation(rotation);
  setFocus(mFocus);
  setFlash(mFlash);
  mCamera.setParameters(mCameraParameters);
}
Program: 170601
Project: 170601
Buggy source:
public void cancelAllTask(){
synchronized (mTaskPoolLock) {
    SLogger.i(TAG,"String_Node_Str");
    if (sTaskPool.size() != 0) {
      for (int i=0; i < sTaskPool.size(); i++) {
        final int key=sTaskPool.keyAt(i);
        SoterTaskThread.getInstance().postToWorker(new Runnable(){
          @Override public void run(){
            BaseSoterTask task=sTaskPool.get(key);
            if (task != null) {
              task.onRemovedFromTaskPoolActively();
            }
          }
        }
);
      }
    }
    sTaskPool.clear();
  }
}

Fixed version (ground truth):
public void cancelAllTask(){
synchronized (mTaskPoolLock) {
    SLogger.i(TAG,"String_Node_Str");
    if (sTaskPool.size() != 0) {
      for (int i=0; i < sTaskPool.size(); i++) {
        final int key=sTaskPool.keyAt(i);
        SoterTaskThread.getInstance().postToWorker(new Runnable(){
          @Override public void run(){
synchronized (mTaskPoolLock) {
              BaseSoterTask task=sTaskPool.get(key);
              if (task != null) {
                task.onRemovedFromTaskPoolActively();
              }
            }
          }
        }
);
      }
    }
    sTaskPool.clear();
  }
}
Program: 170602
Project: 170602
Buggy source:
public void publishAuthCancellation(){
synchronized (mTaskPoolLock) {
    SLogger.i(TAG,"String_Node_Str");
    if (sTaskPool.size() != 0) {
      for (int i=0; i < sTaskPool.size(); i++) {
        final int key=sTaskPool.keyAt(i);
        SoterTaskThread.getInstance().postToWorker(new Runnable(){
          @Override public void run(){
            BaseSoterTask task=sTaskPool.get(key);
            if (task != null && (task instanceof AuthCancellationCallable)) {
              if (!((AuthCancellationCallable)task).isCancelled()) {
                ((AuthCancellationCallable)task).callCancellationInternal();
              }
            }
          }
        }
);
      }
    }
  }
}

Fixed version (ground truth):
public void publishAuthCancellation(){
synchronized (mTaskPoolLock) {
    SLogger.i(TAG,"String_Node_Str");
    if (sTaskPool.size() != 0) {
      for (int i=0; i < sTaskPool.size(); i++) {
        final int key=sTaskPool.keyAt(i);
        SoterTaskThread.getInstance().postToWorker(new Runnable(){
          @Override public void run(){
synchronized (mTaskPoolLock) {
              BaseSoterTask task=sTaskPool.get(key);
              if (task != null && (task instanceof AuthCancellationCallable)) {
                if (!((AuthCancellationCallable)task).isCancelled()) {
                  ((AuthCancellationCallable)task).callCancellationInternal();
                }
              }
            }
          }
        }
);
      }
    }
  }
}
Program: 170603
Project: 170603
Buggy source:
@Override public void run(){
  BaseSoterTask task=sTaskPool.get(key);
  if (task != null && (task instanceof AuthCancellationCallable)) {
    if (!((AuthCancellationCallable)task).isCancelled()) {
      ((AuthCancellationCallable)task).callCancellationInternal();
    }
  }
}

Fixed version (ground truth):
@Override public void run(){
synchronized (mTaskPoolLock) {
    BaseSoterTask task=sTaskPool.get(key);
    if (task != null && (task instanceof AuthCancellationCallable)) {
      if (!((AuthCancellationCallable)task).isCancelled()) {
        ((AuthCancellationCallable)task).callCancellationInternal();
      }
    }
  }
}
Program: 170605
Project: 170605
Buggy source:
private SoterTaskThread(){
  HandlerThread taskHandlerThread=new HandlerThread(HANDLER_THREAD_NAME);
  taskHandlerThread.start();
  mTaskHandler=new Handler(taskHandlerThread.getLooper());
  mMainLooperHandler=new Handler(Looper.getMainLooper());
}

Fixed version (ground truth):
private SoterTaskThread(){
  HandlerThread taskHandlerThread=new HandlerThread(HANDLER_THREAD_NAME);
  taskHandlerThread.start();
  Looper taskLooper=taskHandlerThread.getLooper();
  if (taskLooper != null) {
    mTaskHandler=new Handler(taskHandlerThread.getLooper());
  }
 else {
    SLogger.e(TAG,"String_Node_Str");
    mTaskHandler=new Handler(Looper.getMainLooper());
  }
  mMainLooperHandler=new Handler(Looper.getMainLooper());
}
Program: 170606
Project: 170606
Buggy source:
@Override public void onAuthenticationSucceeded(FingerprintManagerCompat.AuthenticationResult result){
  SLogger.i(TAG,"String_Node_Str");
  SoterTaskThread.getInstance().postToWorker(new Runnable(){
    @Override public void run(){
      if (!SoterCoreUtil.isNullOrNil(mChallenge)) {
        try {
          mSignatureToAuth.update(mChallenge.getBytes());
          executeWhenAuthenticated(mSignatureToAuth);
        }
 catch (        SignatureException e) {
          SLogger.e(TAG,"String_Node_Str");
          SLogger.printErrStackTrace(TAG,e,"String_Node_Str");
          onAuthenticationError(-1000,"String_Node_Str");
        }
      }
 else {
        SLogger.e(TAG,"String_Node_Str");
        onAuthenticationError(-1000,"String_Node_Str");
      }
    }
  }
);
  SoterTaskThread.getInstance().postToMainThread(new Runnable(){
    @Override public void run(){
      if (mFingerprintStateCallback != null) {
        mFingerprintStateCallback.onAuthenticationSucceed();
      }
    }
  }
);
  compatLogicWhenDone();
}

Fixed version (ground truth):
@Override public void onAuthenticationSucceeded(FingerprintManagerCompat.AuthenticationResult result){
  SLogger.i(TAG,"String_Node_Str");
  SoterTaskThread.getInstance().postToWorker(new Runnable(){
    @Override public void run(){
      if (!SoterCoreUtil.isNullOrNil(mChallenge)) {
        try {
          mSignatureToAuth.update(mChallenge.getBytes(Charset.forName("String_Node_Str")));
          executeWhenAuthenticated(mSignatureToAuth);
        }
 catch (        SignatureException e) {
          SLogger.e(TAG,"String_Node_Str");
          SLogger.printErrStackTrace(TAG,e,"String_Node_Str");
          onAuthenticationError(-1000,"String_Node_Str");
        }
      }
 else {
        SLogger.e(TAG,"String_Node_Str");
        onAuthenticationError(-1000,"String_Node_Str");
      }
    }
  }
);
  SoterTaskThread.getInstance().postToMainThread(new Runnable(){
    @Override public void run(){
      if (mFingerprintStateCallback != null) {
        mFingerprintStateCallback.onAuthenticationSucceed();
      }
    }
  }
);
  compatLogicWhenDone();
}
Program: 170607
Project: 170607
Buggy source:
private String getCompatDistinguishSalt(@NonNull String previousSalt){
  String saltMd5=SoterCoreUtil.getMessageDigest(previousSalt.getBytes());
  if (!SoterCoreUtil.isNullOrNil(saltMd5) && saltMd5.length() >= MAX_SALT_STR_LEN) {
    return saltMd5.substring(0,MAX_SALT_STR_LEN);
  }
  Log.e(TAG,"String_Node_Str");
  return null;
}

Fixed version (ground truth):
private String getCompatDistinguishSalt(@NonNull String previousSalt){
  String saltMd5=SoterCoreUtil.getMessageDigest(previousSalt.getBytes(Charset.forName("String_Node_Str")));
  if (!SoterCoreUtil.isNullOrNil(saltMd5) && saltMd5.length() >= MAX_SALT_STR_LEN) {
    return saltMd5.substring(0,MAX_SALT_STR_LEN);
  }
  Log.e(TAG,"String_Node_Str");
  return null;
}
Program: 170608
Project: 170608
Buggy source:
/** 
 * 获取子部门id
 */
@Override public List<Integer> getSubDeptId(Integer deptid){
  Wrapper<Dept> wrapper=new EntityWrapper<>();
  wrapper=wrapper.like("String_Node_Str","String_Node_Str" + deptid + "String_Node_Str");
  List<Dept> depts=this.deptMapper.selectList(wrapper);
  ArrayList<Integer> deptids=new ArrayList<>();
  if (depts != null || depts.size() > 0) {
    for (    Dept dept : depts) {
      deptids.add(dept.getId());
    }
  }
  return deptids;
}

Fixed version (ground truth):
/** 
 * 获取子部门id
 */
@Override public List<Integer> getSubDeptId(Integer deptid){
  Wrapper<Dept> wrapper=new EntityWrapper<>();
  wrapper=wrapper.like("String_Node_Str","String_Node_Str" + deptid + "String_Node_Str");
  List<Dept> depts=this.deptMapper.selectList(wrapper);
  ArrayList<Integer> deptids=new ArrayList<>();
  if (depts != null && depts.size() > 0) {
    for (    Dept dept : depts) {
      deptids.add(dept.getId());
    }
  }
  return deptids;
}
Program: 170609
Project: 170609
Buggy source:
private Menu createSubMenu(Menu parentMenu){
  Menu menu=new Menu();
  menu.setId(IdWorker.getId());
  menu.setPcode(parentMenu.getCode());
  menu.setPcodes(parentMenu.getPcodes() + "String_Node_Str" + parentMenu.getId()+ "String_Node_Str");
  menu.setIcon("String_Node_Str");
  menu.setNum(99);
  menu.setLevels(3);
  menu.setIsmenu(IsMenu.NO.getCode());
  menu.setStatus(1);
  menu.setIsopen(0);
  return menu;
}

Fixed version (ground truth):
private Menu createSubMenu(Menu parentMenu){
  Menu menu=new Menu();
  menu.setId(IdWorker.getId());
  menu.setPcode(parentMenu.getCode());
  menu.setPcodes(parentMenu.getPcodes() + "String_Node_Str" + parentMenu.getCode()+ "String_Node_Str");
  menu.setIcon("String_Node_Str");
  menu.setNum(99);
  menu.setLevels(3);
  menu.setIsmenu(IsMenu.NO.getCode());
  menu.setStatus(1);
  menu.setIsopen(0);
  return menu;
}
Program: 170610
Project: 170610
Buggy source:
public String[] getPcodeAndPcodes(){
  if (parentMenuName.equals("String_Node_Str")) {
    return new String[]{"String_Node_Str","String_Node_Str"};
  }
  PreparedStatement preparedStatement=null;
  try {
    preparedStatement=connection.prepareStatement("String_Node_Str");
    preparedStatement.setString(1,"String_Node_Str" + parentMenuName + "String_Node_Str");
    ResultSet results=preparedStatement.executeQuery();
    while (results.next()) {
      String pcode=String.valueOf(results.getLong("String_Node_Str"));
      String pcodes=results.getString("String_Node_Str");
      if (ToolUtil.isNotEmpty(pcode) && ToolUtil.isNotEmpty(pcodes)) {
        String[] strings={pcode,pcodes};
        return strings;
      }
 else {
        return null;
      }
    }
  }
 catch (  SQLException e) {
    e.printStackTrace();
  }
 finally {
    try {
      if (preparedStatement != null) {
        preparedStatement.close();
      }
      if (connection != null) {
        connection.close();
      }
    }
 catch (    SQLException e) {
      e.printStackTrace();
    }
  }
  return null;
}

Fixed version (ground truth):
public String[] getPcodeAndPcodes(){
  if (parentMenuName.equals("String_Node_Str")) {
    return new String[]{"String_Node_Str","String_Node_Str"};
  }
  PreparedStatement preparedStatement=null;
  try {
    preparedStatement=connection.prepareStatement("String_Node_Str");
    preparedStatement.setString(1,"String_Node_Str" + parentMenuName + "String_Node_Str");
    ResultSet results=preparedStatement.executeQuery();
    while (results.next()) {
      String pcode=results.getString("String_Node_Str");
      String pcodes=results.getString("String_Node_Str");
      if (ToolUtil.isNotEmpty(pcode) && ToolUtil.isNotEmpty(pcodes)) {
        String[] strings={pcode,pcodes};
        return strings;
      }
 else {
        return null;
      }
    }
  }
 catch (  SQLException e) {
    e.printStackTrace();
  }
 finally {
    try {
      if (preparedStatement != null) {
        preparedStatement.close();
      }
      if (connection != null) {
        connection.close();
      }
    }
 catch (    SQLException e) {
      e.printStackTrace();
    }
  }
  return null;
}
Program: 170611
Project: 170611
Buggy source:
@Override public void onClick(View v){
  HttpUrl url=RetrofitUrlManager.getInstance().fetchDomain(GANK_DOMAIN_NAME);
  if (url == null || !url.equals(HttpUrl.parse(mUrl3.getText().toString()))) {
    RetrofitUrlManager.getInstance().putDomain(DOUBAN_DOMAIN_NAME,mUrl3.getText().toString());
  }
  NetWorkManager.getInstance().getThreeApiService().getBook(1220562).subscribeOn(Schedulers.io()).doOnSubscribe(new Consumer<Disposable>(){
    @Override public void accept(    Disposable disposable) throws Exception {
      mProgressDialog.show();
    }
  }
).subscribeOn(AndroidSchedulers.mainThread()).observeOn(AndroidSchedulers.mainThread()).doAfterTerminate(new Action(){
    @Override public void run() throws Exception {
      mProgressDialog.dismiss();
    }
  }
).subscribe(new Consumer<ResponseBody>(){
    @Override public void accept(    ResponseBody response) throws Exception {
      String string=response.string();
      Log.d("String_Node_Str",string);
      mDisplay.setText(string);
    }
  }
,new Consumer<Throwable>(){
    @Override public void accept(    Throwable throwable) throws Exception {
      throwable.printStackTrace();
      mDisplay.setText(throwable.getMessage());
    }
  }
);
}

Fixed version (ground truth):
@Override public void onClick(View v){
  DomainHolder holder=RetrofitUrlManager.getInstance().fetchDomain(DOUBAN_DOMAIN_NAME);
  if (holder == null || !holder.getUrlStr().equals(mUrl3.getText().toString())) {
    RetrofitUrlManager.getInstance().putDomain(DOUBAN_DOMAIN_NAME,mUrl3.getText().toString());
  }
  NetWorkManager.getInstance().getThreeApiService().getBook(1220562).subscribeOn(Schedulers.io()).doOnSubscribe(new Consumer<Disposable>(){
    @Override public void accept(    Disposable disposable) throws Exception {
      mProgressDialog.show();
    }
  }
).subscribeOn(AndroidSchedulers.mainThread()).observeOn(AndroidSchedulers.mainThread()).doAfterTerminate(new Action(){
    @Override public void run() throws Exception {
      mProgressDialog.dismiss();
    }
  }
).subscribe(new Consumer<ResponseBody>(){
    @Override public void accept(    ResponseBody response) throws Exception {
      String string=response.string();
      Log.d("String_Node_Str",string);
      mDisplay.setText(string);
    }
  }
,new Consumer<Throwable>(){
    @Override public void accept(    Throwable throwable) throws Exception {
      throwable.printStackTrace();
      mDisplay.setText(throwable.getMessage());
    }
  }
);
}
Program: 170613
Project: 170613
Buggy source:
@Override public HttpUrl parseUrl(String domainUrl){
  return Utils.checkUrl(domainUrl);
}

Fixed version (ground truth):
@Override public HttpUrl parseUrl(HttpUrl domainUrl,HttpUrl url){
  if (null == domainUrl)   return url;
  return url.newBuilder().scheme(domainUrl.scheme()).host(domainUrl.host()).port(domainUrl.port()).build();
}
Program: 170614
Project: 170614
Buggy source:
/** 
 * 取出对应 DomainName 的 Url
 * @param domainName
 * @return
 */
public HttpUrl fetchDomain(String domainName){
  return mDomainNameHub.get(domainName);
}

Fixed version (ground truth):
/** 
 * 取出对应 DomainName 的 Url
 * @param domainName
 * @return
 */
public DomainHolder fetchDomain(String domainName){
  return mDomainNameHub.get(domainName);
}
Program: 170615
Project: 170615
Buggy source:
/** 
 * 全局动态替换baseUrl，优先级： Header中配置的url > 全局配置的url
 * @param url
 */
public void setGlobalDomain(String url){
synchronized (mDomainNameHub) {
    mDomainNameHub.put(GLOBAL_DOMAIN_NAME,mUrlParser.parseUrl(url));
  }
}

Fixed version (ground truth):
/** 
 * 全局动态替换baseUrl，优先级： Header中配置的url > 全局配置的url
 * @param url
 */
public void setGlobalDomain(String url){
synchronized (mDomainNameHub) {
    mDomainNameHub.put(GLOBAL_DOMAIN_NAME,new DomainHolder(url));
  }
}
Program: 170616
Project: 170616
Buggy source:
/** 
 * 存放 Domain 的映射关系
 * @param domainName
 * @param domainUrl
 */
public void putDomain(String domainName,String domainUrl){
synchronized (mDomainNameHub) {
    mDomainNameHub.put(domainName,mUrlParser.parseUrl(domainUrl));
  }
}

Fixed version (ground truth):
/** 
 * 存放 Domain 的映射关系
 * @param domainName
 * @param domainUrl
 */
public void putDomain(String domainName,String domainUrl){
synchronized (mDomainNameHub) {
    mDomainNameHub.put(domainName,new DomainHolder(domainUrl));
  }
}
Program: 170617
Project: 170617
Buggy source:
/** 
 * 对   {@link Request} 进行一些必要的加工
 * @param request
 * @return
 */
public Request processRequest(Request request){
  boolean hasDomainHeader;
  HttpUrl newUrl=null;
  String domainName=obtainDomainNameFromHeaders(request);
  hasDomainHeader=!TextUtils.isEmpty(domainName) && (newUrl=fetchDomain(domainName)) != null;
  if (!hasDomainHeader) {
    newUrl=fetchDomain(GLOBAL_DOMAIN_NAME);
    if (null == newUrl) {
      return request;
    }
  }
  Log.d(RetrofitUrlManager.TAG,"String_Node_Str" + newUrl.toString() + "String_Node_Str"+ request.url().toString()+ "String_Node_Str");
  Object[] listeners=listenersToArray();
  if (listeners != null) {
    for (int i=0; i < listeners.length; i++) {
      ((onUrlChangeListener)listeners[i]).onUrlChange(newUrl,request.url());
    }
  }
  return request.newBuilder().removeHeader(DOMAIN_NAME).url(newUrl).build();
}

Fixed version (ground truth):
/** 
 * 对   {@link Request} 进行一些必要的加工
 * @param request
 * @return
 */
public Request processRequest(Request request){
  Request.Builder newBuilder=request.newBuilder();
  String domainName=obtainDomainNameFromHeaders(request);
  DomainHolder holder;
  if (!TextUtils.isEmpty(domainName)) {
    holder=fetchDomain(domainName);
    newBuilder.removeHeader(DOMAIN_NAME);
  }
 else {
    holder=fetchDomain(GLOBAL_DOMAIN_NAME);
  }
  if (null != holder) {
    HttpUrl newUrl=mUrlParser.parseUrl(holder.getDomain(),request.url());
    Log.d(RetrofitUrlManager.TAG,"String_Node_Str" + newUrl.toString() + "String_Node_Str"+ request.url().toString()+ "String_Node_Str");
    Object[] listeners=listenersToArray();
    if (listeners != null) {
      for (int i=0; i < listeners.length; i++) {
        ((onUrlChangeListener)listeners[i]).onUrlChange(newUrl,request.url());
      }
    }
    return request.newBuilder().url(newUrl).build();
  }
  return newBuilder.build();
}
Program: 170618
Project: 170618
Buggy source:
/** 
 * 将   {@link RetrofitUrlManager#mDomainNameHub} 中映射的 Url 解析成完整的{@link HttpUrl}用来替换 @  {@link Request#url} 达到动态切换 Url
 * @param domainUrl
 * @return
 */
HttpUrl parseUrl(String domainUrl);

Fixed version (ground truth):
/** 
 * 将   {@link RetrofitUrlManager#mDomainNameHub} 中映射的 Url 解析成完整的{@link HttpUrl}用来替换 @  {@link Request#url} 达到动态切换 Url
 * @param domainUrl
 * @return
 */
HttpUrl parseUrl(HttpUrl domainUrl,HttpUrl url);
Program: 170619
Project: 170619
Buggy source:
public static HttpUrl checkUrl(String url){
  HttpUrl parseUrl=HttpUrl.parse(url);
  if (null == parseUrl) {
    throw new InvalidUrlException(url);
  }
 else {
    return parseUrl;
  }
}

Fixed version (ground truth):
static HttpUrl checkUrl(String url){
  HttpUrl parseUrl=HttpUrl.parse(url);
  if (null == parseUrl) {
    throw new InvalidUrlException(url);
  }
 else {
    return parseUrl;
  }
}
Program: 170620
Project: 170620
Buggy source:
public void btnSetGlobalUrl(View view){
  DomainHolder domainHolder=RetrofitUrlManager.getInstance().getGlobalDomain();
  if (null == domainHolder || !domainHolder.getUrlStr().equals(mGlobalUrl.getText().toString().trim()))   RetrofitUrlManager.getInstance().setGlobalDomain(mGlobalUrl.getText().toString().trim());
  Toast.makeText(getApplicationContext(),"String_Node_Str",Toast.LENGTH_SHORT).show();
}

Fixed version (ground truth):
public void btnSetGlobalUrl(View view){
  HttpUrl httpUrl=RetrofitUrlManager.getInstance().getGlobalDomain();
  if (null == httpUrl || !httpUrl.toString().equals(mGlobalUrl.getText().toString().trim()))   RetrofitUrlManager.getInstance().setGlobalDomain(mGlobalUrl.getText().toString().trim());
  Toast.makeText(getApplicationContext(),"String_Node_Str",Toast.LENGTH_SHORT).show();
}
Program: 170622
Project: 170622
Buggy source:
/** 
 * 重新计算displayMetrics.xhdpi, 使单位pt重定义为设计稿的相对长度
 * @see #activate()
 * @param context
 * @param designWidth 设计稿的宽度
 */
private static void resetDensity(Context context,float designWidth){
  if (context == null)   return;
  Point size=new Point();
  ((WindowManager)context.getSystemService(WINDOW_SERVICE)).getDefaultDisplay().getSize(size);
  Resources resources=context.getResources();
  resources.getDisplayMetrics().xdpi=size.x / designWidth * 72f;
  if ("String_Node_Str".equals(resources.getClass().getSimpleName())) {
    try {
      Field field=Resources.class.getDeclaredField("String_Node_Str");
      field.setAccessible(true);
      DisplayMetrics metrics=(DisplayMetrics)field.get(resources);
      metrics.xdpi=size.x / designWidth * 72f;
    }
 catch (    NoSuchFieldException e) {
      e.printStackTrace();
    }
catch (    IllegalAccessException e) {
      e.printStackTrace();
    }
  }
}

Fixed version (ground truth):
/** 
 * 重新计算displayMetrics.xhdpi, 使单位pt重定义为设计稿的相对长度
 * @see #activate()
 * @param context
 * @param designWidth 设计稿的宽度
 */
private static void resetDensity(Context context,float designWidth){
  if (context == null)   return;
  Point size=new Point();
  ((WindowManager)context.getSystemService(WINDOW_SERVICE)).getDefaultDisplay().getSize(size);
  Resources resources=context.getResources();
  resources.getDisplayMetrics().xdpi=size.x / designWidth * 72f;
  if ("String_Node_Str".equals(resources.getClass().getSimpleName()) || "String_Node_Str".equals(resources.getClass().getSimpleName())) {
    try {
      Field field=Resources.class.getDeclaredField("String_Node_Str");
      field.setAccessible(true);
      DisplayMetrics metrics=(DisplayMetrics)field.get(resources);
      metrics.xdpi=size.x / designWidth * 72f;
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
  }
}
Program: 170623
Project: 170623
Buggy source:
/** 
 * @param application application
 * @param width 设计稿宽度
 */
public RudenessScreenHelper(Application application,float width){
  mApplication=application;
  designWidth=width;
  activityLifecycleCallbacks=new Application.ActivityLifecycleCallbacks(){
    @Override public void onActivityCreated(    Activity activity,    Bundle savedInstanceState){
      resetDensity(mApplication,designWidth);
      resetDensity(activity,designWidth);
    }
    @Override public void onActivityStarted(    Activity activity){
    }
    @Override public void onActivityResumed(    Activity activity){
    }
    @Override public void onActivityPaused(    Activity activity){
    }
    @Override public void onActivityStopped(    Activity activity){
    }
    @Override public void onActivitySaveInstanceState(    Activity activity,    Bundle outState){
    }
    @Override public void onActivityDestroyed(    Activity activity){
    }
  }
;
}

Fixed version (ground truth):
/** 
 * @param application application
 * @param width 设计稿宽度
 */
public RudenessScreenHelper(Application application,float width){
  mApplication=application;
  designWidth=width;
  activityLifecycleCallbacks=new Application.ActivityLifecycleCallbacks(){
    @Override public void onActivityCreated(    Activity activity,    Bundle savedInstanceState){
    }
    @Override public void onActivityStarted(    Activity activity){
      resetDensity(mApplication,designWidth);
      resetDensity(activity,designWidth);
    }
    @Override public void onActivityResumed(    Activity activity){
    }
    @Override public void onActivityPaused(    Activity activity){
    }
    @Override public void onActivityStopped(    Activity activity){
    }
    @Override public void onActivitySaveInstanceState(    Activity activity,    Bundle outState){
    }
    @Override public void onActivityDestroyed(    Activity activity){
    }
  }
;
}
Program: 170624
Project: 170624
Buggy source:
@Override public void onActivityCreated(Activity activity,Bundle savedInstanceState){
  resetDensity(mApplication,designWidth);
  resetDensity(activity,designWidth);
}

Fixed version (ground truth):
@Override public void onActivityCreated(Activity activity,Bundle savedInstanceState){
}
Program: 170625
Project: 170625
Buggy source:
@Override public void onActivityStarted(Activity activity){
}

Fixed version (ground truth):
@Override public void onActivityStarted(Activity activity){
  resetDensity(mApplication,designWidth);
  resetDensity(activity,designWidth);
}
Program: 170626
Project: 170626
Buggy source:
/** 
 * 重新计算displayMetrics.xhdpi, 使单位pt重定义为设计稿的相对长度
 * @see #activate()
 * @param context
 * @param designWidth 设计稿的宽度
 */
private static void resetDensity(Context context,float designWidth){
  Point size=new Point();
  ((WindowManager)context.getSystemService(WINDOW_SERVICE)).getDefaultDisplay().getSize(size);
  context.getResources().getDisplayMetrics().xdpi=size.x / designWidth * 72f;
}

Fixed version (ground truth):
/** 
 * 重新计算displayMetrics.xhdpi, 使单位pt重定义为设计稿的相对长度
 * @see #activate()
 * @param context
 * @param designWidth 设计稿的宽度
 */
private static void resetDensity(Context context,float designWidth){
  if (context == null)   return;
  Point size=new Point();
  ((WindowManager)context.getSystemService(WINDOW_SERVICE)).getDefaultDisplay().getSize(size);
  Resources resources=context.getResources();
  resources.getDisplayMetrics().xdpi=size.x / designWidth * 72f;
  if ("String_Node_Str".equals(resources.getClass().getSimpleName())) {
    try {
      Field field=Resources.class.getDeclaredField("String_Node_Str");
      field.setAccessible(true);
      DisplayMetrics metrics=(DisplayMetrics)field.get(resources);
      metrics.xdpi=size.x / designWidth * 72f;
    }
 catch (    NoSuchFieldException e) {
      e.printStackTrace();
    }
catch (    IllegalAccessException e) {
      e.printStackTrace();
    }
  }
}
Program: 170627
Project: 170627
Buggy source:
public LineRenderer(final Chart chart){
  super(chart);
  linePath=new Path();
  chart.setInternalViewportChangeListener(new OnViewportChangeListener(){
    @Override public void onViewportChange(    Viewport viewport){
      mViewport=viewport;
      calcDataSetMinMax();
    }
  }
);
  final Highlight highlight=new Highlight();
  chart.addOnTouchPointChangeListener(new Chart.OnTouchPointChangeListener(){
    @Override public void touch(    float x,    float y){
synchronized (lineData) {
        for (        LineDataSet line : getDataSet()) {
          if (line.isHighlightedVerticalEnable() && !line.getValues().isEmpty()) {
            int offset=line.getStartIndexOffset();
            int index=getEntryIndexByCoordinate(x,y) - offset;
            if (index > 0 && index < line.getValues().size()) {
              final PointValue pointValue=line.getEntryForIndex(index);
              float xPosition=pointValue.getX();
              float yPosition=pointValue.getY();
              if (xPosition > 0 && yPosition > 0) {
                highlight.setX(xPosition);
                highlight.setY(yPosition);
                highlight.setDataIndex(index);
                chart.highlightValue(highlight);
              }
            }
          }
        }
      }
    }
  }
);
}

Fixed version (ground truth):
public LineRenderer(final Chart chart){
  super(chart);
  linePath=new Path();
  chart.setInternalViewportChangeListener(new OnViewportChangeListener(){
    @Override public void onViewportChange(    Viewport viewport){
      mViewport=viewport;
      calcDataSetMinMax();
    }
  }
);
  final Highlight highlight=new Highlight();
  chart.addOnTouchPointChangeListener(new Chart.OnTouchPointChangeListener(){
    @Override public void touch(    float x,    float y){
synchronized (lineData) {
        for (        LineDataSet line : getDataSet()) {
          if (line.isHighlightedVerticalEnable() && !line.getValues().isEmpty()) {
            int offset=line.getStartIndexOffset();
            int index=getEntryIndexByCoordinate(x,y) - offset;
            if (index > 0 && index < line.getValues().size()) {
              final PointValue pointValue=line.getEntryForIndex(index);
              float xPosition=pointValue.getX();
              float yPosition=pointValue.getY();
              if (xPosition >= 0 && yPosition >= 0) {
                highlight.setX(xPosition);
                highlight.setY(yPosition);
                highlight.setDataIndex(index);
                chart.highlightValue(highlight);
              }
            }
          }
        }
      }
    }
  }
);
}