nus-yam/ex-repair huggingface dataset:
Program: 90240
Project: 90240
Buggy source:
/** 
 * Returns a new QueueConnectionFactory. This is an SunMQ implementation of QueueConnectionFactory. Notice: The return type is explicitly defined with package prefix to avoid name collision with javax.jms.QueueConnectionFactory
 * @throws JMSException
 * @return QueueConnectionFactory
 */
protected javax.jms.QueueConnectionFactory getQueueConnectionFactory() throws JMSException {
  QueueConnectionFactory cFactory=new QueueConnectionFactory();
  ((com.sun.messaging.ConnectionFactory)cFactory).setProperty(com.sun.messaging.ConnectionConfiguration.imqBrokerHostName,getHost());
  ((com.sun.messaging.ConnectionFactory)cFactory).setProperty(com.sun.messaging.ConnectionConfiguration.imqBrokerHostPort,String.valueOf(getPort()));
  ((com.sun.messaging.ConnectionFactory)cFactory).setProperty(com.sun.messaging.ConnectionConfiguration.imqConsumerFlowLimit,"String_Node_Str");
  return cFactory;
}

Fixed version (ground truth):
/** 
 * Returns a new QueueConnectionFactory. This is an SunMQ implementation of QueueConnectionFactory. Notice: The return type is explicitly defined with package prefix to avoid name collision with javax.jms.QueueConnectionFactory
 * @throws JMSException
 * @return QueueConnectionFactory
 */
protected QueueConnectionFactory getQueueConnectionFactory() throws JMSException {
  QueueConnectionFactory cFactory=new QueueConnectionFactory();
  ((ConnectionFactory)cFactory).setProperty(ConnectionConfiguration.imqBrokerHostName,getHost());
  ((ConnectionFactory)cFactory).setProperty(ConnectionConfiguration.imqBrokerHostPort,String.valueOf(getPort()));
  ((ConnectionFactory)cFactory).setProperty(ConnectionConfiguration.imqConsumerFlowLimit,"String_Node_Str");
  return cFactory;
}
Program: 90241
Project: 90241
Buggy source:
/** 
 * Intialises a Open Message Queue JMS connection.
 * @return A JMSConnection
 * @throws IOFailure when connection to JMS broker failed
 */
public static JMSConnectionSunMQ getInstance() throws UnknownID, IOFailure {
  if (instance == null) {
    instance=new JMSConnectionSunMQ();
  }
  return instance;
}

Fixed version (ground truth):
/** 
 * Intialises a Open Message Queue JMS connection.
 * @return A JMSConnection
 * @throws IOFailure when connection to JMS broker failed
 */
public static synchronized JMSConnectionSunMQ getInstance() throws UnknownID, IOFailure {
  if (instance == null) {
    instance=new JMSConnectionSunMQ();
  }
  return instance;
}
Program: 90242
Project: 90242
Buggy source:
/** 
 * Test that files larger than 2GB can be copied! 
 */
public void testCopyLargeFiles() throws IOException {
  byte[] block=new byte[BLOCKSIZE];
  SUBDIR.mkdirs();
  File largeFile=new File(SUBDIR,LARGE_FILE);
  OutputStream os=new FileOutputStream(largeFile);
  System.out.println("String_Node_Str");
  for (long l=0; l < LARGE / ((long)BLOCKSIZE) + 1L; l++) {
    os.write(block);
  }
  System.out.println("String_Node_Str");
  FileUtils.copyDirectory(SUBDIR,SUBDIR2);
  File file1=new File(SUBDIR,LARGE_FILE);
  File file2=new File(SUBDIR2,LARGE_FILE);
  assertEquals("String_Node_Str",file1.length(),file2.length());
}

Fixed version (ground truth):
/** 
 * Test that files larger than 2GB can be copied! 
 */
public void testCopyLargeFiles() throws IOException {
  byte[] block=new byte[BLOCKSIZE];
  SUBDIR.mkdirs();
  File largeFile=new File(SUBDIR,LARGE_FILE);
  OutputStream os=new BufferedOutputStream(new FileOutputStream(largeFile));
  System.out.println("String_Node_Str");
  for (long l=0; l < LARGE / ((long)BLOCKSIZE) + 1L; l++) {
    os.write(block);
  }
  System.out.println("String_Node_Str");
  FileUtils.copyDirectory(SUBDIR,SUBDIR2);
  File file1=new File(SUBDIR,LARGE_FILE);
  File file2=new File(SUBDIR2,LARGE_FILE);
  assertEquals("String_Node_Str",file1.length(),file2.length());
}
Program: 90243
Project: 90243
Buggy source:
/** 
 * Tests that a class has a static factory method getInstance() and that it acts as a singleton. NB This method will create an instance of the class. It is your responsibility to clean up after yourself.
 * @param c the class to test
 * @return the singleton
 */
public static <T>T assertSingleton(Class<T> c){
  assertHasFactoryMethod(c);
  assertPrivateConstructor(c);
  T o1=null;
  T o2=null;
  try {
    Method m=c.getDeclaredMethod("String_Node_Str");
    o1=(T)m.invoke(null);
    o2=(T)m.invoke(null);
  }
 catch (  Exception e) {
    throw new PermissionDenied("String_Node_Str",e);
  }
  TestCase.assertEquals("String_Node_Str" + "String_Node_Str" + c.getName(),o1,o2);
  if (o1 instanceof CleanupIF) {
    ((CleanupIF)o1).cleanup();
  }
  return o1;
}

Fixed version (ground truth):
/** 
 * Tests that a class has a static factory method getInstance() and that it acts as a singleton. NB This method will create an instance of the class. It is your responsibility to clean up after yourself.
 * @param c the class to test
 * @return the singleton
 */
public static <T>T assertSingleton(Class<T> c){
  assertHasFactoryMethod(c);
  assertPrivateConstructor(c);
  T o1=null;
  T o2=null;
  try {
    Method m=c.getDeclaredMethod("String_Node_Str");
    o1=(T)m.invoke(null);
    o2=(T)m.invoke(null);
  }
 catch (  Exception e) {
    throw new PermissionDenied("String_Node_Str",e);
  }
  TestCase.assertSame("String_Node_Str" + "String_Node_Str" + c.getName(),o1,o2);
  if (o1 instanceof CleanupIF) {
    ((CleanupIF)o1).cleanup();
  }
  return o1;
}
Program: 90244
Project: 90244
Buggy source:
public void tearDown() throws Exception {
  super.tearDown();
  Settings.reload();
  System.setSecurityManager(m);
  if (gui != null) {
    gui.close();
  }
}

Fixed version (ground truth):
public void tearDown() throws Exception {
  super.tearDown();
  Settings.reload();
  System.setSecurityManager(m);
  if (gui != null) {
    gui.cleanup();
  }
}
Program: 90245
Project: 90245
Buggy source:
public void testRun() throws IOException, SAXException {
  gui=HarvestDefinitionGUI.getInstance();
  WebConversation conv=new WebConversation();
  conv.setExceptionsThrownOnErrorStatus(false);
  WebResponse resp=conv.getResponse("String_Node_Str" + Integer.toString(TestInfo.GUI_WEB_SERVER_PORT) + "String_Node_Str"+ TestInfo.GUI_WEB_SERVER_WEBBASE);
  assertTrue("String_Node_Str" + resp.getURL() + "String_Node_Str"+ resp.getResponseCode(),resp.getResponseCode() == 200);
}

Fixed version (ground truth):
public void testRun() throws IOException, SAXException {
  gui=GUIWebServer.getInstance();
  WebConversation conv=new WebConversation();
  conv.setExceptionsThrownOnErrorStatus(false);
  WebResponse resp=conv.getResponse("String_Node_Str" + Integer.toString(TestInfo.GUI_WEB_SERVER_PORT) + "String_Node_Str"+ TestInfo.GUI_WEB_SERVER_WEBBASE);
  assertTrue("String_Node_Str" + resp.getURL() + "String_Node_Str"+ resp.getResponseCode(),resp.getResponseCode() == 200);
}
Program: 90247
Project: 90247
Buggy source:
/** 
 * Constructor.
 */
private JMSConnectionSunMQ(){
  super();
  log.info("String_Node_Str");
  initConnection();
}

Fixed version (ground truth):
/** 
 * Constructor.
 */
private JMSConnectionSunMQ(){
  super();
  log.info("String_Node_Str" + getClass().getName());
  initConnection();
}
Program: 90249
Project: 90249
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  mTutorial=new TutorialOverlayHelper(this,"String_Node_Str").setBackgroundColor(R.color.popup_background).setFocusable(true).setTouchable(true).setOutsideTouchable(true).setContentView(R.layout.popup_view).show(this,500L);
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  mTutorial=new TutorialOverlayHelper(this,"String_Node_Str").setBackgroundColorResource(R.color.popup_background).setFocusable(true).setTouchable(true).setOutsideTouchable(true).setContentView(R.layout.popup_view).show(this,500L);
}
Program: 90250
Project: 90250
Buggy source:
/** 
 * Used to receive and process incoming JavaScript events
 */
void handleEvent(String event,String data){
  List<EventListener> listeners=mEventListenerMap.get(event);
  if (listeners != null) {
    for (    EventListener listener : listeners) {
      listener.onEvent(event,data);
    }
  }
}

Fixed version (ground truth):
/** 
 * Used to receive and process incoming JavaScript events
 */
void handleEvent(String event,String data){
  Set<EventListener> listeners=mEventListenerMap.get(event);
  if (listeners != null) {
    for (    EventListener listener : listeners) {
      listener.onEvent(event,data);
    }
  }
}
Program: 90251
Project: 90251
Buggy source:
/** 
 * Stop listening for the given event.
 * @param event The event to stop listening for.
 * @param listener The listener
 */
public void removeListener(String event,EventListener listener){
  List<EventListener> currentListener=mEventListenerMap.get(event);
  if (currentListener == null) {
    currentListener=new ArrayList<EventListener>();
  }
  currentListener.remove(listener);
  mEventListenerMap.put(event,currentListener);
}

Fixed version (ground truth):
/** 
 * Stop listening for the given event.
 * @param event The event to stop listening for.
 * @param listener The listener
 */
public void removeListener(String event,EventListener listener){
  Set<EventListener> currentListener=mEventListenerMap.get(event);
  if (currentListener == null) {
    currentListener=new HashSet<EventListener>();
  }
  currentListener.remove(listener);
  mEventListenerMap.put(event,currentListener);
}
Program: 90252
Project: 90252
Buggy source:
/** 
 * Register a listener for the given event.
 * @param event The event to listen for.
 * @param listener The listener
 */
public void addListener(String event,EventListener listener){
  List<EventListener> currentListeners=mEventListenerMap.get(event);
  if (currentListeners == null) {
    currentListeners=new ArrayList<EventListener>();
  }
  currentListeners.add(listener);
  mEventListenerMap.put(event,currentListeners);
}

Fixed version (ground truth):
/** 
 * Register a listener for the given event.
 * @param event The event to listen for.
 * @param listener The listener
 */
public void addListener(String event,EventListener listener){
  Set<EventListener> currentListeners=mEventListenerMap.get(event);
  if (currentListeners == null) {
    currentListeners=new HashSet<EventListener>();
  }
  currentListeners.add(listener);
  mEventListenerMap.put(event,currentListeners);
}
Program: 90253
Project: 90253
Buggy source:
@ExceptionHandler(Exception.class) public void handleException(Exception e,HttpServletResponse response,HttpServletRequest request) throws IOException {
  storeException(request,response,e);
  ResponseStatus responseStatus=AnnotationUtils.findAnnotation(e.getClass(),ResponseStatus.class);
  if (responseStatus != null) {
    HttpStatus httpStatus=responseStatus.value();
    logger.error(httpStatus.getReasonPhrase(),e);
    String message=e.getMessage();
    if (message == null || message.trim().isEmpty()) {
      message=responseStatus.reason();
    }
    response.sendError(httpStatus.value(),message);
  }
 else {
    logger.error("String_Node_Str",e);
    response.sendError(HttpStatus.INTERNAL_SERVER_ERROR.value(),e.getMessage());
  }
}

Fixed version (ground truth):
@ExceptionHandler(Exception.class) public void handleException(Exception e,HttpServletResponse response,HttpServletRequest request) throws IOException {
  storeException(request,response,e);
  ResponseStatus responseStatus=AnnotationUtils.findAnnotation(e.getClass(),ResponseStatus.class);
  if (responseStatus != null) {
    HttpStatus httpStatus=responseStatus.value();
    if (httpStatus.is5xxServerError()) {
      logger.error(httpStatus.getReasonPhrase(),e);
    }
 else     if (httpStatus != HttpStatus.NOT_FOUND) {
      logger.error(httpStatus.getReasonPhrase() + "String_Node_Str" + e.toString());
    }
    String message=e.getMessage();
    if (message == null || message.trim().isEmpty()) {
      message=responseStatus.reason();
    }
    response.sendError(httpStatus.value(),message);
  }
 else {
    logger.error("String_Node_Str",e);
    response.sendError(HttpStatus.INTERNAL_SERVER_ERROR.value(),e.getMessage());
  }
}
Program: 90254
Project: 90254
Buggy source:
private void doSearchImage(Context ctx,Bitmap image,Algorithm type) throws Exception {
  startSearch(ctx,image);
  do {
    optimize(type);
  }
 while (false == checkConvergence());
}

Fixed version (ground truth):
private void doSearchImage(Context ctx,Bitmap image,Algorithm type) throws Exception {
  startSearch(ctx,image);
  do {
    optimize(type);
  }
 while (false == checkConvergence(type));
}
Program: 90256
Project: 90256
Buggy source:
private boolean checkConvergence(){
  if (mOptCount > OPTIMIZATION_LIMIT) {
    return true;
  }
  if (mParamHist.size() >= 3) {
    QMatrix currentParam=mParamHist.get(mParamHist.size() - 1);
    QMatrix lastParam=mParamHist.get(mParamHist.size() - 2);
    QMatrix lastlastParam=mParamHist.get(mParamHist.size() - 3);
    float currDiff=currentParam.minus(lastParam).innerProduct();
    float lastDiff=currentParam.minus(lastlastParam).innerProduct();
    Log.v(TAG,"String_Node_Str" + currDiff + "String_Node_Str"+ lastDiff);
    if (currDiff > lastDiff || currDiff < CONVERGENCE_THRESHOLD) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
private boolean checkConvergence(Algorithm type){
  if (Algorithm.QUICK == type && mOptCount >= QUICK_OPTIMIZATION_LIMIT) {
    return true;
  }
 else   if (mOptCount >= OPTIMIZATION_LIMIT) {
    return true;
  }
  if (mParamHist.size() >= 3) {
    QMatrix currentParam=mParamHist.get(mParamHist.size() - 1);
    QMatrix lastParam=mParamHist.get(mParamHist.size() - 2);
    QMatrix lastlastParam=mParamHist.get(mParamHist.size() - 3);
    float currDiff=currentParam.minus(lastParam).innerProduct();
    float lastDiff=currentParam.minus(lastlastParam).innerProduct();
    Log.v(TAG,"String_Node_Str" + currDiff + "String_Node_Str"+ lastDiff);
    if (currDiff > lastDiff || currDiff < CONVERGENCE_THRESHOLD) {
      return true;
    }
  }
  return false;
}
Program: 90257
Project: 90257
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_camera);
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_camera);
  mCameraID=1;
  mCamera=getCameraInstance();
  mCamera.setDisplayOrientation(90);
  mPreview=new CameraPreview(this,mCamera,this,this);
  FrameLayout preview=(FrameLayout)findViewById(R.id.CameraPreview);
  preview.addView(mPreview);
  getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
Program: 90258
Project: 90258
Buggy source:
public void init(Context ctx,FaceModel model){
  mModel=model;
  mFilter=new Filter2D(ctx,mModel.patchModel.weightsList,mModel.patchModel.biasList,null,mModel.numPts,mModel.patchModel.sampleWidth,mModel.patchModel.sampleHeight,(mModel.patchModel.sampleWidth + SEARCH_WIN_W - 1),(mModel.patchModel.sampleHeight + SEARCH_WIN_H - 1));
  QMatrix.init(ctx);
}

Fixed version (ground truth):
public void init(Context ctx,FaceModel model){
  QMatrix.init(ctx);
  mModel=model;
  mFilter=new Filter2D(ctx,mModel.patchModel.weightsList,mModel.patchModel.biasList,null,mModel.numPts,mModel.patchModel.sampleWidth,mModel.patchModel.sampleHeight,(mModel.patchModel.sampleWidth + SEARCH_WIN_W - 1),(mModel.patchModel.sampleHeight + SEARCH_WIN_H - 1));
  mParamHist=new ArrayList<QMatrix>();
}
Program: 90259
Project: 90259
Buggy source:
private QMatrix createInvCovariance(QMatrix meanPos,float[] responseImg){
  QMatrix result=new QMatrix(mModel.numPts * 2,mModel.numPts * 2);
  QMatrix currPtsConv=new QMatrix(2,2);
  float[] zeros=new float[]{0,0,0,0};
  for (int i=0; i < mModel.numPts; i++) {
    float meanX=meanPos.get(i * 2) - mCropPositions.get(i * 2) + (SEARCH_WIN_W - 1);
    float meanY=meanPos.get(i * 2 + 1) - mCropPositions.get(i * 2 + 1) + (SEARCH_WIN_H - 1);
    currPtsConv.set(0,zeros);
    int respImgOffset=i * SEARCH_WIN_W * SEARCH_WIN_H;
    for (int j=0; j < SEARCH_WIN_W; j++) {
      for (int k=0; k < SEARCH_WIN_H; k++) {
        float a=responseImg[respImgOffset + k * SEARCH_WIN_H + j];
        float dx=j - meanX;
        float dy=k - meanY;
        currPtsConv.set(0,currPtsConv.get(0) + a * dx * dx);
        currPtsConv.set(1,currPtsConv.get(1) + a * dx * dy);
        currPtsConv.set(3,currPtsConv.get(3) + a * dy * dy);
      }
    }
    currPtsConv.set(2,currPtsConv.get(1));
    QMatrix invConvPts=currPtsConv.invert();
    result.set(i * 2,i * 2,invConvPts.get(0));
    result.set(i * 2 + 1,i * 2,invConvPts.get(1));
    result.set(i * 2,i * 2 + 1,invConvPts.get(2));
    result.set(i * 2 + 1,i * 2 + 1,invConvPts.get(3));
  }
  return result;
}

Fixed version (ground truth):
private QMatrix createInvCovariance(QMatrix meanPos,float[] responseImg){
  QMatrix result=new QMatrix(mModel.numPts * 2,mModel.numPts * 2);
  QMatrix currPtsConv=new QMatrix(2,2);
  float[] zeros=new float[]{0,0,0,0};
  for (int i=0; i < mModel.numPts; i++) {
    float meanX=meanPos.get(i * 2) - mCropPositions.get(i * 2) + (SEARCH_WIN_W - 1);
    float meanY=meanPos.get(i * 2 + 1) - mCropPositions.get(i * 2 + 1) + (SEARCH_WIN_H - 1);
    currPtsConv.set(0,zeros);
    int respImgOffset=i * SEARCH_WIN_W * SEARCH_WIN_H;
    for (int j=0; j < SEARCH_WIN_W; j++) {
      for (int k=0; k < SEARCH_WIN_H; k++) {
        float a=responseImg[respImgOffset + k * SEARCH_WIN_H + j];
        float dx=j - meanX;
        float dy=k - meanY;
        currPtsConv.set(0,currPtsConv.get(0) + a * dx * dx);
        currPtsConv.set(1,currPtsConv.get(1) + a * dx * dy);
        currPtsConv.set(3,currPtsConv.get(3) + a * dy * dy);
      }
    }
    currPtsConv.set(2,currPtsConv.get(1));
    QMatrix invConvPts=currPtsConv.invert();
    if (Float.isNaN(invConvPts.get(0)) || Float.isNaN(invConvPts.get(1)) || Float.isNaN(invConvPts.get(2))|| Float.isNaN(invConvPts.get(3))) {
      invConvPts.set(0,zeros);
    }
    result.set(i * 2,i * 2,invConvPts.get(0));
    result.set(i * 2 + 1,i * 2,invConvPts.get(1));
    result.set(i * 2,i * 2 + 1,invConvPts.get(2));
    result.set(i * 2 + 1,i * 2 + 1,invConvPts.get(3));
  }
  return result;
}
Program: 90260
Project: 90260
Buggy source:
private void updateCurrent(QMatrix newPositions){
  FuncTracer.startFunc();
  QMatrix jacob=createJacobian(mCurrentParams);
  QMatrix transJacob=jacob.transpose();
  QMatrix deltaParams=transJacob.mult(jacob).invert().mult(transJacob).mult(newPositions.minusSelf(mCurrentPositions));
  mCurrentParams=regularizeParams(deltaParams.plusSelf(mCurrentParams));
  mCurrentPositions=getShape(mCurrentParams);
  FuncTracer.endFunc();
}

Fixed version (ground truth):
private void updateCurrent(QMatrix newPositions){
  FuncTracer.startFunc();
  QMatrix jacob=createJacobian(mCurrentParams);
  QMatrix transJacob=jacob.transpose();
  QMatrix deltaParams=transJacob.mult(jacob).invert().mult(transJacob).mult(newPositions.minusSelf(mCurrentPositions));
  Log.i(TAG,"String_Node_Str" + deltaParams.innerProduct());
  mCurrentParams=regularizeParams(deltaParams.plusSelf(mCurrentParams));
  mCurrentPositions=getShape(mCurrentParams);
  FuncTracer.endFunc();
}
Program: 90261
Project: 90261
Buggy source:
public void optimize(Algorithm type) throws Exception {
  FuncTracer.startFunc();
  mFilter.setPatches(cropPatches());
  if (Algorithm.ASM == type) {
    mFilter.process(ResponseType.RAW);
    searchPeak(mFilter.gerResponseImages());
  }
 else   if (Algorithm.CQF == type) {
    mFilter.process(ResponseType.REG_NORMALIZED);
    searchConvQuadFit(mFilter.gerResponseImages());
  }
 else   if (Algorithm.KDE == type) {
    mFilter.process(ResponseType.REGULARIZED);
    searchMeanShift(mFilter.gerResponseImages());
  }
 else {
    throw new Exception("String_Node_Str");
  }
  FuncTracer.endFunc();
}

Fixed version (ground truth):
private void optimize(Algorithm type) throws Exception {
  FuncTracer.startFunc();
  mFilter.setPatches(cropPatches());
switch (type) {
case CQF:
    mFilter.process(ResponseType.REG_NORMALIZED);
  searchConvQuadFit(mFilter.gerResponseImages());
break;
case KDE:
mFilter.process(ResponseType.REGULARIZED);
searchMeanShift(mFilter.gerResponseImages());
break;
case ASM:
default :
mFilter.process(ResponseType.RAW);
searchPeak(mFilter.gerResponseImages());
break;
}
mParamHist.add(new QMatrix(mCurrentParams,true));
while (mParamHist.size() > PARAM_HIST_SIZE) {
mParamHist.remove(0);
}
mOptCount++;
FuncTracer.endFunc();
}
Program: 90262
Project: 90262
Buggy source:
private byte[] cropPatches(){
  FuncTracer.startFunc();
  QMatrix currShape=getCurrentShape();
  int filterW=mModel.patchModel.sampleWidth;
  int filterH=mModel.patchModel.sampleHeight;
  int patchW=filterW + SEARCH_WIN_W - 1;
  int patchH=filterH + SEARCH_WIN_H - 1;
  int shiftW=-(patchW - 1) / 2;
  int shiftH=-(patchH - 1) / 2;
  byte[] ret=new byte[mModel.numPts * patchW * patchH];
  mCropPositions=currShape;
  for (int i=0; i < mModel.numPts; i++) {
    int centerX=(int)(currShape.get(i * 2));
    int centerY=(int)(currShape.get(i * 2 + 1));
    for (int j=0; j < patchH; j++) {
      for (int k=0; k < patchW; k++) {
        int posX=centerX + shiftW + k;
        int posY=centerY + shiftH + j;
        if (posX < 0 || posY < 0 || posX > mImageW || posY > mImageH) {
          ret[i * patchW * patchH + j * patchW + k]=0;
        }
 else {
          ret[i * patchW * patchH + j * patchW + k]=(mImgGrayScaled[(int)(posY * mImageW) + posX]);
        }
      }
    }
  }
  FuncTracer.endFunc();
  return ret;
}

Fixed version (ground truth):
private byte[] cropPatches(){
  FuncTracer.startFunc();
  QMatrix currShape=getCurrentShape();
  int filterW=mModel.patchModel.sampleWidth;
  int filterH=mModel.patchModel.sampleHeight;
  int patchW=filterW + SEARCH_WIN_W - 1;
  int patchH=filterH + SEARCH_WIN_H - 1;
  int shiftW=-(patchW - 1) / 2;
  int shiftH=-(patchH - 1) / 2;
  byte[] ret=new byte[mModel.numPts * patchW * patchH];
  mCropPositions=currShape;
  for (int i=0; i < mModel.numPts; i++) {
    int centerX=(int)(currShape.get(i * 2));
    int centerY=(int)(currShape.get(i * 2 + 1));
    for (int j=0; j < patchH; j++) {
      for (int k=0; k < patchW; k++) {
        int posX=centerX + shiftW + k;
        int posY=centerY + shiftH + j;
        if (posX < 0 || posY < 0 || posX > mImageW || posY > mImageH) {
          ret[i * patchW * patchH + j * patchW + k]=100;
        }
 else {
          ret[i * patchW * patchH + j * patchW + k]=(mImgGrayScaled[(int)(posY * mImageW) + posX]);
        }
      }
    }
  }
  FuncTracer.endFunc();
  return ret;
}
Program: 90263
Project: 90263
Buggy source:
private void updateCurrentCQF(QMatrix newPositions,float[] responseImg){
  FuncTracer.startFunc();
  QMatrix jacob=createJacobian(mCurrentParams);
  QMatrix transJacob=jacob.transpose();
  QMatrix invCovariance=createInvCovariance(newPositions,responseImg);
  invCovariance.printOut();
  QMatrix deltaParams=transJacob.mult(invCovariance).mult(jacob).invert().mult(transJacob).mult(invCovariance).mult(newPositions.minusSelf(mCurrentPositions));
  mCurrentParams=regularizeParams(deltaParams.plusSelf(mCurrentParams));
  mCurrentPositions=getShape(mCurrentParams);
  FuncTracer.endFunc();
}

Fixed version (ground truth):
private void updateCurrentCQF(QMatrix newPositions,float[] responseImg){
  FuncTracer.startFunc();
  QMatrix jacob=createJacobian(mCurrentParams);
  QMatrix transJacob=jacob.transpose();
  QMatrix invCovariance=createInvCovariance(newPositions,responseImg);
  newPositions.printOut();
  invCovariance.printOut();
  QMatrix deltaParams=transJacob.mult(invCovariance).mult(jacob).invert().mult(transJacob).mult(invCovariance).mult(newPositions.minusSelf(mCurrentPositions));
  mCurrentParams=regularizeParams(deltaParams.plusSelf(mCurrentParams));
  mCurrentPositions=getShape(mCurrentParams);
  FuncTracer.endFunc();
}
Program: 90264
Project: 90264
Buggy source:
public void searchInImage(Context ctx,Bitmap image,float leftX,float leftY,float rightX,float rightY) throws Exception {
  if (null == mModel) {
    throw new Exception("String_Node_Str");
  }
  int leftEyeIndex=mModel.pathModel.paths[mModel.pathModel.paths.length - 2][0];
  int rightEyeIndex=mModel.pathModel.paths[mModel.pathModel.paths.length - 1][0];
  double meanLeftX=mModel.shapeModel.mMeanShape.get(leftEyeIndex * 2);
  double meanLeftY=mModel.shapeModel.mMeanShape.get(leftEyeIndex * 2 + 1);
  double meanRightX=mModel.shapeModel.mMeanShape.get(rightEyeIndex * 2);
  double meanRightY=mModel.shapeModel.mMeanShape.get(rightEyeIndex * 2 + 1);
  double meanAngle=Math.atan((meanRightY - meanLeftY) / (meanRightX - meanLeftX));
  double currAngle=Math.atan((rightY - leftY) / (rightX - leftX));
  double diffAngle=currAngle - meanAngle;
  double meanDist=Math.hypot(meanRightX - meanLeftX,meanRightY - meanLeftY);
  double currDist=Math.hypot(rightX - leftX,rightY - leftY);
  double scale=meanDist / currDist;
  mScaleFactor=scale;
  Bitmap imgProcess=Bitmap.createScaledBitmap(image,(int)(image.getWidth() * scale),(int)(image.getHeight() * scale),true);
  leftX*=scale;
  leftY*=scale;
  rightX*=scale;
  rightY*=scale;
  mCurrentParams=new QMatrix(mModel.numEVectors + 4,1);
  mCurrentParams.set(0,(float)Math.cos(diffAngle));
  mCurrentParams.set(1,(float)Math.sin(diffAngle));
  mCurrentParams.set(2,(float)((rightX + leftX) / 2 - (meanRightX + meanLeftX) / 2));
  mCurrentParams.set(3,(float)((rightY + leftY) / 2 - (meanRightY + meanLeftY) / 2));
  mImageW=imgProcess.getWidth();
  mImageH=imgProcess.getHeight();
  RenderScript rs=RenderScript.create(ctx);
  ScriptC_im2float script=new ScriptC_im2float(rs);
  Allocation inAlloc=Allocation.createFromBitmap(rs,imgProcess);
  Type.Builder tb=new Type.Builder(rs,Element.U8(rs));
  tb.setX(mImageW).setY(mImageH);
  mImgGrayScaled=new byte[mImageW * mImageH];
  Allocation outAlloc=Allocation.createTyped(rs,tb.create());
  script.forEach_root(inAlloc,outAlloc);
  outAlloc.copyTo(mImgGrayScaled);
  mCurrentPositions=getCurrentShape();
  mOriginalPositions=new QMatrix(mCurrentPositions,true);
}

Fixed version (ground truth):
public void searchInImage(Context ctx,Bitmap image,Algorithm type) throws Exception {
  FuncTracer.startFunc();
  startSearch(ctx,image);
  do {
    optimize(type);
  }
 while (false == checkConvergence());
  FuncTracer.endFunc();
}
Program: 90265
Project: 90265
Buggy source:
public float[] gerResponseImages(){
  return mResponse;
}

Fixed version (ground truth):
public float[] gerResponseImages(){
  for (int i=0; i < mResponse.length; i++) {
    if (Float.isNaN(mResponse[i])) {
      mResponse[i]=0;
    }
  }
  return mResponse;
}
Program: 90266
Project: 90266
Buggy source:
@Override protected void onActivityResult(int requestCode,int resultCode,Intent data){
  if (GALLERY_INTENT_ID == requestCode) {
    try {
      currPic=Media.getBitmap(getContentResolver(),data.getData());
      if (currPic.getWidth() > 1080) {
        currPic=Bitmap.createScaledBitmap(currPic,1080,1920,false);
      }
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
    imgFrame.setImageBitmap(currPic);
    try {
      FuncTracer.startProc("String_Node_Str");
      if (null == proc) {
        proc=new FaceAlignProc();
        proc.init(appCntx,model);
      }
      proc.searchInImage(appCntx,currPic);
      for (int t=0; t < 5; t++) {
        proc.optimize(Algorithm.CQF);
      }
      FuncTracer.endProc("String_Node_Str");
      imgFrame.addPlot(proc);
    }
 catch (    Exception e) {
      FuncTracer.procException(e);
      e.printStackTrace();
    }
  }
}

Fixed version (ground truth):
@Override protected void onActivityResult(int requestCode,int resultCode,Intent data){
  if (GALLERY_INTENT_ID == requestCode) {
    try {
      currPic=Media.getBitmap(getContentResolver(),data.getData());
      if (currPic.getWidth() > 1080) {
        currPic=Bitmap.createScaledBitmap(currPic,1080,1920,false);
      }
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
    imgFrame.setImageBitmap(currPic);
    try {
      FuncTracer.startProc("String_Node_Str");
      if (null == proc) {
        proc=new FaceAlignProc();
        proc.init(appCntx,model);
      }
      proc.searchInImage(appCntx,currPic,Algorithm.CQF);
      FuncTracer.endProc("String_Node_Str");
      imgFrame.addPlot(proc);
    }
 catch (    Exception e) {
      FuncTracer.procException(e);
      e.printStackTrace();
    }
  }
}
Program: 90267
Project: 90267
Buggy source:
public void init(Context ctx,FaceModel model){
  mModel=model;
  mCurrentParams=new Mat(mModel.numEVectors + 4,1,CvType.CV_32F,new Scalar(0));
  mCurrentParams.put(0,0,1.0);
  mFilter=new Filter2D(ctx,mModel.patchModel.weightsList,mModel.patchModel.biasList,null,mModel.numPts,mModel.patchModel.sampleWidth,mModel.patchModel.sampleHeight,(mModel.patchModel.sampleWidth + SEARCH_WIN_W - 1),(mModel.patchModel.sampleHeight + SEARCH_WIN_H - 1));
}

Fixed version (ground truth):
public void init(Context ctx,FaceModel model){
  mModel=model;
  mFilter=new Filter2D(ctx,mModel.patchModel.weightsList,mModel.patchModel.biasList,null,mModel.numPts,mModel.patchModel.sampleWidth,mModel.patchModel.sampleHeight,(mModel.patchModel.sampleWidth + SEARCH_WIN_W - 1),(mModel.patchModel.sampleHeight + SEARCH_WIN_H - 1));
}
Program: 90269
Project: 90269
Buggy source:
@Override protected void onActivityResult(int requestCode,int resultCode,Intent data){
  if (GALLERY_INTENT_ID == requestCode) {
    try {
      currPic=Media.getBitmap(getContentResolver(),data.getData());
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
    imgFrame.setImageBitmap(currPic);
    if (null == proc) {
      try {
        proc=new FaceAlignProc();
        proc.init(appCntx,model);
        float[] eyes=makeInitialGuess(currPic);
        if (true) {
          proc.searchInImage(appCntx,currPic,(int)eyes[0],(int)eyes[1],(int)eyes[2],(int)eyes[3]);
        }
 else {
          String temp=data.getData().toString();
          if (temp.contains("String_Node_Str")) {
            proc.searchInImage(appCntx,currPic,418,952,611,945);
          }
 else           if (temp.contains("String_Node_Str")) {
            proc.searchInImage(appCntx,currPic,388,946,636,956);
          }
 else           if (temp.contains("String_Node_Str")) {
            proc.searchInImage(appCntx,currPic,365,840,689,844);
          }
 else           if (temp.contains("String_Node_Str")) {
            proc.searchInImage(appCntx,currPic,444,1076,672,1060);
          }
 else           if (temp.contains("String_Node_Str")) {
            proc.searchInImage(appCntx,currPic,438,968,744,948);
          }
 else           if (temp.contains("String_Node_Str")) {
            proc.searchInImage(appCntx,currPic,1016,1152,1288,1136);
          }
 else           if (temp.contains("String_Node_Str")) {
            proc.searchInImage(appCntx,currPic,902,908,1191,946);
          }
 else {
            proc.searchInImage(appCntx,currPic,418,952,611,945);
          }
        }
        for (int t=0; t < 3; t++) {
          proc.optimize(Algorithm.ASM);
        }
        imgFrame.addPlot(proc);
      }
 catch (      Exception e) {
        e.printStackTrace();
      }
    }
  }
}

Fixed version (ground truth):
@Override protected void onActivityResult(int requestCode,int resultCode,Intent data){
  if (GALLERY_INTENT_ID == requestCode) {
    try {
      currPic=Media.getBitmap(getContentResolver(),data.getData());
      if (currPic.getWidth() > 1080) {
        currPic=Bitmap.createScaledBitmap(currPic,1080,1920,false);
      }
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
    imgFrame.setImageBitmap(currPic);
    try {
      if (null == proc) {
        proc=new FaceAlignProc();
        proc.init(appCntx,model);
      }
      proc.searchInImage(appCntx,currPic);
      for (int t=0; t < 3; t++) {
        proc.optimize(Algorithm.ASM);
      }
      imgFrame.addPlot(proc);
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
  }
}
Program: 90270
Project: 90270
Buggy source:
synchronized void onSizeChanged(){
  this.destroy();
  this.mapViewCanvas=new Canvas();
  this.width=this.mapView.getWidth();
  this.height=this.mapView.getHeight();
  this.mapViewBitmap1=Bitmap.createBitmap(this.width,this.height,Bitmap.Config.RGB_565);
  this.mapViewBitmap2=Bitmap.createBitmap(this.width,this.height,Bitmap.Config.RGB_565);
  clear();
  this.mapViewCanvas.setBitmap(this.mapViewBitmap1);
}

Fixed version (ground truth):
synchronized void onSizeChanged(){
  this.width=this.mapView.getWidth();
  this.height=this.mapView.getHeight();
  this.mapViewBitmap1=Bitmap.createBitmap(this.width,this.height,Bitmap.Config.RGB_565);
  this.mapViewBitmap2=Bitmap.createBitmap(this.width,this.height,Bitmap.Config.RGB_565);
  clear();
  this.mapViewCanvas.setBitmap(this.mapViewBitmap1);
}
Program: 90271
Project: 90271
Buggy source:
synchronized void destroy(){
  if (this.mapViewBitmap1 != null) {
    this.mapViewBitmap1.recycle();
  }
  if (this.mapViewBitmap2 != null) {
    this.mapViewBitmap2.recycle();
  }
  this.mapViewCanvas=null;
}

Fixed version (ground truth):
synchronized void destroy(){
  if (this.mapViewBitmap1 != null) {
    this.mapViewBitmap1.recycle();
  }
  if (this.mapViewBitmap2 != null) {
    this.mapViewBitmap2.recycle();
  }
}
Program: 90272
Project: 90272
Buggy source:
void destroy(){
  this.overlayController.interrupt();
  this.mapMover.interrupt();
  this.mapWorker.interrupt();
  this.zoomAnimator.interrupt();
  try {
    this.mapWorker.join();
  }
 catch (  InterruptedException e) {
    Thread.currentThread().interrupt();
  }
  this.frameBuffer.destroy();
  this.mapScaleBar.destroy();
  this.inMemoryTileCache.destroy();
  this.fileSystemTileCache.destroy();
  this.databaseRenderer.destroy();
  this.mapDatabase.closeFile();
}

Fixed version (ground truth):
void destroy(){
  this.overlayController.interrupt();
  this.mapMover.interrupt();
  this.mapWorker.interrupt();
  this.zoomAnimator.interrupt();
  try {
    this.mapWorker.join();
  }
 catch (  InterruptedException e) {
    Thread.currentThread().interrupt();
  }
  this.frameBuffer.destroy();
  this.mapScaleBar.destroy();
  this.inMemoryTileCache.destroy();
  this.fileSystemTileCache.destroy();
  this.mapDatabase.closeFile();
}
Program: 90274
Project: 90274
Buggy source:
private boolean checkSize(){
  this.sizeChange.writeLock().lock();
  try {
    if (this.changeSizeNeeded) {
      return changeSize();
    }
    return true;
  }
  finally {
    this.sizeChange.writeLock().unlock();
  }
}

Fixed version (ground truth):
private boolean checkSize(){
  if (this.changeSizeNeeded) {
    return changeSize();
  }
  return true;
}
Program: 90275
Project: 90275
Buggy source:
private void recycleBitmaps(){
  if (this.bitmap1 != null) {
    this.bitmap1.recycle();
    this.bitmap1=null;
  }
  if (this.bitmap2 != null) {
    this.bitmap2.recycle();
    this.bitmap2=null;
  }
  this.overlayCanvas=null;
}

Fixed version (ground truth):
private void recycleBitmaps(){
  recycleBitmap(this.bitmap1);
  recycleBitmap(this.bitmap2);
}
Program: 90276
Project: 90276
Buggy source:
@Override protected void afterRun(){
  this.recycleBitmaps();
}

Fixed version (ground truth):
@Override protected void afterRun(){
  recycleBitmaps();
}
Program: 90277
Project: 90277
Buggy source:
private void redraw(){
  if (this.overlayCanvas == null) {
    this.overlayCanvas=new Canvas();
  }
  this.bitmap2.eraseColor(Color.TRANSPARENT);
  this.overlayCanvas.setBitmap(this.bitmap2);
  MapPosition mapPositionBefore=this.mapView.getMapViewPosition().getMapPosition();
  BoundingBox boundingBox=this.mapView.getMapViewPosition().getBoundingBox();
  List<Overlay> overlays=this.mapView.getOverlays();
synchronized (overlays) {
    for (    Overlay overlay : overlays) {
      overlay.draw(boundingBox,mapPositionBefore.zoomLevel,this.overlayCanvas);
    }
  }
  MapPosition mapPositionAfter=this.mapView.getMapViewPosition().getMapPosition();
synchronized (this.matrix) {
    adjustMatrix(mapPositionBefore,mapPositionAfter);
    swapBitmaps();
  }
  this.mapView.postInvalidate();
}

Fixed version (ground truth):
private void redraw(){
  this.bitmap2.eraseColor(Color.TRANSPARENT);
  this.overlayCanvas.setBitmap(this.bitmap2);
  MapPosition mapPositionBefore=this.mapView.getMapViewPosition().getMapPosition();
  BoundingBox boundingBox=this.mapView.getMapViewPosition().getBoundingBox();
  List<Overlay> overlays=this.mapView.getOverlays();
synchronized (overlays) {
    for (    Overlay overlay : overlays) {
      overlay.draw(boundingBox,mapPositionBefore.zoomLevel,this.overlayCanvas);
    }
  }
  MapPosition mapPositionAfter=this.mapView.getMapViewPosition().getMapPosition();
synchronized (this.matrix) {
    adjustMatrix(mapPositionBefore,mapPositionAfter);
    swapBitmaps();
  }
  this.mapView.postInvalidate();
}
Program: 90278
Project: 90278
Buggy source:
public OverlayController(MapView mapView){
  super();
  this.mapView=mapView;
  this.matrix=new Matrix();
  this.changeSizeNeeded=true;
}

Fixed version (ground truth):
public OverlayController(MapView mapView){
  super();
  this.mapView=mapView;
  this.matrix=new Matrix();
  this.overlayCanvas=new Canvas();
  this.changeSizeNeeded=true;
}
Program: 90279
Project: 90279
Buggy source:
private boolean changeSize(){
  int newWidth=this.mapView.getWidth();
  int newHeight=this.mapView.getHeight();
  if (newWidth > 0 && newHeight > 0) {
    if (this.width == newWidth && this.height == newHeight) {
      this.changeSizeNeeded=false;
      this.redrawNeeded=false;
      return false;
    }
    recycleBitmaps();
    this.width=newWidth;
    this.height=newHeight;
    this.bitmap1=Bitmap.createBitmap(newWidth,newHeight,Bitmap.Config.ARGB_8888);
    this.bitmap2=Bitmap.createBitmap(newWidth,newHeight,Bitmap.Config.ARGB_8888);
    this.changeSizeNeeded=false;
    this.redrawNeeded=true;
    return true;
  }
  return false;
}

Fixed version (ground truth):
private boolean changeSize(){
  recycleBitmaps();
  int width=this.mapView.getWidth();
  int height=this.mapView.getHeight();
  if (width > 0 && height > 0) {
    this.bitmap1=Bitmap.createBitmap(width,height,Bitmap.Config.ARGB_8888);
    this.bitmap2=Bitmap.createBitmap(width,height,Bitmap.Config.ARGB_8888);
    this.changeSizeNeeded=false;
    this.redrawNeeded=true;
    return true;
  }
  return false;
}
Program: 90280
Project: 90280
Buggy source:
private void checkRedraw(){
  this.sizeChange.readLock().lock();
  try {
    if (this.redrawNeeded) {
      this.redrawNeeded=false;
      redraw();
    }
  }
  finally {
    this.sizeChange.readLock().unlock();
  }
}

Fixed version (ground truth):
private void checkRedraw(){
  if (this.redrawNeeded) {
    this.redrawNeeded=false;
    redraw();
  }
}
Program: 90281
Project: 90281
Buggy source:
@Override public void setBitmapShader(org.mapsforge.map.graphics.Bitmap bitmap){
  if (bitmap == null) {
    return;
  }
  this.bitmap=bitmap;
  android.graphics.Bitmap androidBitmap=android.graphics.Bitmap.createBitmap(bitmap.getPixels(),bitmap.getWidth(),bitmap.getHeight(),Config.ARGB_8888);
  Shader shader=new BitmapShader(androidBitmap,TileMode.REPEAT,TileMode.REPEAT);
  this.paint.setShader(shader);
}

Fixed version (ground truth):
@Override public void setBitmapShader(org.mapsforge.map.graphics.Bitmap bitmap){
  if (bitmap == null) {
    return;
  }
  android.graphics.Bitmap androidBitmap=android.graphics.Bitmap.createBitmap(bitmap.getPixels(),bitmap.getWidth(),bitmap.getHeight(),Config.ARGB_8888);
  Shader shader=new BitmapShader(androidBitmap,TileMode.REPEAT,TileMode.REPEAT);
  this.paint.setShader(shader);
}
Program: 90282
Project: 90282
Buggy source:
@Override public void destroy(){
  this.fill.destroy();
  this.stroke.destroy();
}

Fixed version (ground truth):
@Override public void destroy(){
}
Program: 90283
Project: 90283
Buggy source:
@Override public void destroy(){
  this.stroke.destroy();
}

Fixed version (ground truth):
@Override public void destroy(){
}
Program: 90284
Project: 90284
Buggy source:
@Override public synchronized void destroy(){
  if (this.bitmapGet != null) {
    this.bitmapGet.recycle();
  }
  if (this.capacity == 0) {
    return;
  }
  if (!this.persistent || !serializeMap(this.cacheDirectory,this.map)) {
    for (    File file : this.map.values()) {
      if (!file.delete()) {
        file.deleteOnExit();
      }
    }
    this.map.clear();
    if (this.cacheDirectory != null) {
      File[] filesToDelete=this.cacheDirectory.listFiles(ImageFileNameFilter.INSTANCE);
      if (filesToDelete != null) {
        for (        File file : filesToDelete) {
          if (!file.delete()) {
            file.deleteOnExit();
          }
        }
      }
      if (!this.cacheDirectory.delete()) {
        this.cacheDirectory.deleteOnExit();
      }
    }
  }
}

Fixed version (ground truth):
@Override public synchronized void destroy(){
  if (!this.persistent || !serializeMap(this.cacheDirectory,this.map)) {
    for (    File file : this.map.values()) {
      if (!file.delete()) {
        file.deleteOnExit();
      }
    }
    this.map.clear();
    File[] filesToDelete=this.cacheDirectory.listFiles(ImageFileNameFilter.INSTANCE);
    if (filesToDelete != null) {
      for (      File file : filesToDelete) {
        if (!file.delete()) {
          file.deleteOnExit();
        }
      }
    }
    if (!this.cacheDirectory.delete()) {
      this.cacheDirectory.deleteOnExit();
    }
  }
}
Program: 90285
Project: 90285
Buggy source:
@Override public synchronized void put(MapGeneratorJob mapGeneratorJob,Bitmap bitmap){
  if (this.capacity == 0) {
    return;
  }
  FileOutputStream fileOutputStream=null;
  try {
    File outputFile;
    do {
      ++this.cacheId;
      outputFile=new File(this.cacheDirectory,this.cacheId + IMAGE_FILE_NAME_EXTENSION);
    }
 while (outputFile.exists());
    this.byteBuffer.rewind();
    bitmap.copyPixelsToBuffer(this.byteBuffer);
    byte[] array=this.byteBuffer.array();
    fileOutputStream=new FileOutputStream(outputFile);
    fileOutputStream.write(array,0,array.length);
    this.map.put(mapGeneratorJob,outputFile);
  }
 catch (  IOException e) {
    LOGGER.log(Level.SEVERE,"String_Node_Str",e);
    this.capacity=0;
  }
 finally {
    try {
      if (fileOutputStream != null) {
        fileOutputStream.close();
      }
    }
 catch (    IOException e) {
      LOGGER.log(Level.SEVERE,null,e);
    }
  }
}

Fixed version (ground truth):
@Override public synchronized void put(MapGeneratorJob mapGeneratorJob,Bitmap bitmap){
  if (this.capacity == 0) {
    return;
  }
  FileOutputStream fileOutputStream=null;
  try {
    File outputFile;
    do {
      ++this.cacheId;
      outputFile=new File(this.cacheDirectory,this.cacheId + IMAGE_FILE_NAME_EXTENSION);
    }
 while (outputFile.exists());
    this.byteBuffer.rewind();
    bitmap.copyPixelsToBuffer(this.byteBuffer);
    byte[] array=this.byteBuffer.array();
    fileOutputStream=new FileOutputStream(outputFile);
    fileOutputStream.write(array,0,array.length);
    this.map.put(mapGeneratorJob,outputFile);
  }
 catch (  IOException e) {
    LOGGER.log(Level.SEVERE,null,e);
  }
 finally {
    try {
      if (fileOutputStream != null) {
        fileOutputStream.close();
      }
    }
 catch (    IOException e) {
      LOGGER.log(Level.SEVERE,null,e);
    }
  }
}
Program: 90286
Project: 90286
Buggy source:
/** 
 * @param capacity the maximum number of entries in this cache.
 * @param mapViewId the ID of the MapView to separate caches for different MapViews.
 * @throws IllegalArgumentException if the capacity is negative.
 */
public FileSystemTileCache(int capacity,int mapViewId){
  this.mapViewId=mapViewId;
  this.capacity=checkCapacity(capacity);
  if (this.capacity > 0 && this.cacheDirectory != null) {
    Map<MapGeneratorJob,File> deserializedMap=deserializeMap(this.cacheDirectory);
    if (deserializedMap == null) {
      this.map=createMap(this.capacity);
    }
 else {
      this.map=deserializedMap;
    }
    this.byteBuffer=ByteBuffer.allocate(TILE_SIZE_IN_BYTES);
    this.bitmapGet=Bitmap.createBitmap(Tile.TILE_SIZE,Tile.TILE_SIZE,Config.RGB_565);
  }
 else {
    this.byteBuffer=null;
    this.bitmapGet=null;
    this.map=createMap(0);
  }
}

Fixed version (ground truth):
/** 
 * @param capacity the maximum number of entries in this cache.
 * @param mapViewId the ID of the MapView to separate caches for different MapViews.
 * @throws IllegalArgumentException if the capacity is negative.
 */
public FileSystemTileCache(int capacity,int mapViewId){
  this.capacity=getCapacity(capacity);
  String externalStorageDirectory=Environment.getExternalStorageDirectory().getAbsolutePath();
  String cacheDirectoryPath=externalStorageDirectory + CACHE_DIRECTORY + mapViewId;
  this.cacheDirectory=createDirectory(cacheDirectoryPath);
  Map<MapGeneratorJob,File> deserializedMap=deserializeMap(this.cacheDirectory);
  if (deserializedMap == null) {
    this.map=createMap(this.capacity);
  }
 else {
    this.map=deserializedMap;
  }
  this.byteBuffer=ByteBuffer.allocate(TILE_SIZE_IN_BYTES);
  this.bitmapGet=Bitmap.createBitmap(Tile.TILE_SIZE,Tile.TILE_SIZE,Config.RGB_565);
}
Program: 90287
Project: 90287
Buggy source:
@Override public synchronized void setCapacity(int capacity){
  if (this.capacity == capacity) {
    return;
  }
  this.capacity=checkCapacity(capacity);
  if (this.capacity != 0) {
    Map<MapGeneratorJob,File> newMap=createMap(this.capacity);
    if (this.map != null) {
      newMap.putAll(this.map);
    }
    this.map=newMap;
  }
}

Fixed version (ground truth):
@Override public synchronized void setCapacity(int capacity){
  if (this.capacity == capacity) {
    return;
  }
  this.capacity=getCapacity(capacity);
  Map<MapGeneratorJob,File> newMap=createMap(this.capacity);
  newMap.putAll(this.map);
  this.map=newMap;
}
Program: 90289
Project: 90289
Buggy source:
/** 
 * Gets the center point of the dimension.
 * @return the center point
 */
public Point getCenter(){
  return new Point(this.width / 2,this.height / 2);
}

Fixed version (ground truth):
/** 
 * Gets the center point of the dimension.
 * @return the center point
 */
public Point getCenter(){
  return new Point((float)this.width / 2,(float)this.height / 2);
}