nus-yam/ex-repair huggingface dataset:
Program: 4361
Project: 4361
Buggy source:
public void add(Atom child){
  if (children.size() > 0) {
    children.getLast().finish();
  }
  children.add(child);
}

Fixed version (ground truth):
public void add(Atom child){
  if (children.size() > 0) {
    children.get(children.size() - 1).finish();
  }
  children.add(child);
}
Program: 4362
Project: 4362
Buggy source:
private void displayFolder(String path){
  List<FileInfo> fileInfos=cache.get(path);
  if (fileInfos == null)   fileInfos=androidDevice.list(path);
  List<FileInfo> files=new Vector<>();
  for (  FileInfo fi2 : fileInfos) {
    if (fi2.directory)     continue;
    files.add(fi2);
  }
  jListFichiers.setListData(files.toArray());
}

Fixed version (ground truth):
private void displayFolder(String path){
  List<FileInfo> fileInfos=cache.get(path);
  if (fileInfos == null)   fileInfos=androidDevice.list(path);
  List<FileInfo> files=new ArrayList<>();
  for (  FileInfo fi2 : fileInfos) {
    if (fi2.directory)     continue;
    files.add(fi2);
  }
  jListFichiers.setListData(files.toArray());
}
Program: 4363
Project: 4363
Buggy source:
int getMask(int length){
  int res=0;
  for (int i=0; i < length; i++) {
    res=(res << 1) + 1;
  }
  return res;
}

Fixed version (ground truth):
protected int getMask(int length){
  int res=0;
  for (int i=0; i < length; i++) {
    res=(res << 1) + 1;
  }
  return res;
}
Program: 4364
Project: 4364
Buggy source:
int getPixel(Object inData){
  return getPixel((byte[])inData);
}

Fixed version (ground truth):
protected int getPixel(Object inData){
  return getPixel((byte[])inData);
}
Program: 4365
Project: 4365
Buggy source:
/** 
 * Convert a raw image into a buffered image.
 * @param rawImage the image to convert.
 * @return the converted image.
 */
public static BufferedImage convertImage(RawImage rawImage){
switch (rawImage.bpp) {
case SIXTEEN_BIT_IMAGE:
    return rawImage16toARGB(rawImage);
case THIRTY_TWO_BIT_IMAGE:
  return rawImage32toARGB(rawImage);
}
throw new IllegalArgumentException("String_Node_Str" + rawImage.bpp);
}

Fixed version (ground truth):
/** 
 * Convert a raw image into a buffered image.
 * @param rawImage the image to convert.
 * @return the converted image.
 */
public static BufferedImage convertImage(RawImage rawImage){
switch (rawImage.bpp) {
case SIXTEEN_BIT_IMAGE:
    return rawImage16toARGB(rawImage);
case THIRTY_TWO_BIT_IMAGE:
  return rawImage32toARGB(rawImage);
default :
throw new IllegalStateException("String_Node_Str" + rawImage.bpp);
}
}
Program: 4366
Project: 4366
Buggy source:
public void stop(){
  LOGGER.debug("String_Node_Str");
  screenCaptureRunnable.stop();
  LOGGER.debug("String_Node_Str");
}

Fixed version (ground truth):
public void stop(){
  screenCaptureRunnable.stop();
}
Program: 4367
Project: 4367
Buggy source:
public void start(){
  LOGGER.debug("String_Node_Str");
  screenCaptureThread.start();
  LOGGER.debug("String_Node_Str");
}

Fixed version (ground truth):
public void start(){
  screenCaptureThread.start();
}
Program: 4368
Project: 4368
Buggy source:
public static int getKeyCode(KeyEvent e){
  LOGGER.debug("String_Node_Str" + e + "String_Node_Str");
  int code=InputKeyEvent.KEYCODE_UNKNOWN.getCode();
  char c=e.getKeyChar();
  int keyCode=e.getKeyCode();
  InputKeyEvent inputKeyEvent=InputKeyEvent.getByCharacterOrKeyCode(Character.toLowerCase(c),keyCode);
  if (inputKeyEvent != null) {
    code=inputKeyEvent.getCode();
  }
  LOGGER.debug("String_Node_Str" + e + "String_Node_Str");
  return code;
}

Fixed version (ground truth):
public static int getKeyCode(KeyEvent e){
  LOGGER.debug("String_Node_Str" + e + "String_Node_Str");
  int code=InputKeyEvent.KEYCODE_UNKNOWN.getCode();
  char c=e.getKeyChar();
  int keyCode=e.getKeyCode();
  InputKeyEvent inputKeyEvent=InputKeyEvent.getByCharacterOrKeyCode(Character.toLowerCase(c),keyCode);
  if (inputKeyEvent != null) {
    code=inputKeyEvent.getCode();
  }
  LOGGER.debug(String.format("String_Node_Str",String.valueOf(e),code));
  return code;
}
Program: 4369
Project: 4369
Buggy source:
@Override public void flush(){
  try {
    os.flush();
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
@Override public void flush(){
  try {
    os.flush();
  }
 catch (  IOException e) {
    throw new IORuntimeException(e);
  }
}
Program: 4370
Project: 4370
Buggy source:
@Override public void addOutput(byte[] buf,int off,int len){
  try {
    os.write(buf,off,len);
  }
 catch (  IOException ex) {
    throw new RuntimeException(ex);
  }
}

Fixed version (ground truth):
@Override public void addOutput(byte[] buf,int off,int len){
  try {
    os.write(buf,off,len);
  }
 catch (  IOException e) {
    throw new IORuntimeException(e);
  }
}
Program: 4372
Project: 4372
Buggy source:
@Override public void init(){
  try {
    if (useNativeLook())     UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
  }
 catch (  Exception ex) {
    throw new RuntimeException(ex);
  }
}

Fixed version (ground truth):
@Override public void init(){
  try {
    if (useNativeLook())     UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
  }
 catch (  Exception ex) {
    throw new AndroidScreenCastRuntimeException(ex);
  }
}
Program: 4373
Project: 4373
Buggy source:
@Override public void handleException(Thread thread,Throwable ex){
  try {
    StringWriter sw=new StringWriter();
    ex.printStackTrace(new PrintWriter(sw));
    if (sw.toString().contains("String_Node_Str"))     return;
    ex.printStackTrace(System.err);
    if (jd != null && jd.isVisible())     return;
    jd=new JDialogError(ex);
    SwingUtilities.invokeLater(() -> jd.setVisible(true));
  }
 catch (  Exception ex2) {
  }
}

Fixed version (ground truth):
@Override public void handleException(Thread thread,Throwable ex){
  try {
    StringWriter sw=new StringWriter();
    ex.printStackTrace(new PrintWriter(sw));
    if (sw.toString().contains("String_Node_Str"))     return;
    ex.printStackTrace(System.err);
    if (jd != null && jd.isVisible())     return;
    jd=new JDialogError(ex);
    SwingUtilities.invokeLater(() -> jd.setVisible(true));
  }
 catch (  Exception ignored) {
  }
}
Program: 4374
Project: 4374
Buggy source:
private void setErrorDetails(Throwable ex){
  errorDialogLabel.setText(ex.getClass().getSimpleName());
  if (ex.getClass() == RuntimeException.class && ex.getCause() != null)   ex=ex.getCause();
  try (StringWriter stringWriter=new StringWriter()){
    AndroidScreenCastRuntimeException realCause=getCause(ex);
    if (realCause != null) {
      errorDialogLabel.setText(realCause.getClass().getSimpleName());
      stringWriter.append(realCause.getMessage()).append('\n').append('\n');
      stringWriter.append(realCause.getAdditionalInformation());
    }
 else {
      stringWriter.append(ex.getMessage()).append('\n').append('\n');
      ex.printStackTrace(new PrintWriter(stringWriter));
    }
    errorDescription.setText(stringWriter.toString());
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
private void setErrorDetails(Throwable e){
  Throwable ex=getRealException(e);
  errorDialogLabel.setText(ex.getClass().getSimpleName());
  try (StringWriter stringWriter=new StringWriter()){
    AndroidScreenCastRuntimeException realCause=getCause(ex);
    if (realCause != null) {
      errorDialogLabel.setText(realCause.getClass().getSimpleName());
      stringWriter.append(realCause.getMessage()).append('\n').append('\n');
      stringWriter.append(realCause.getAdditionalInformation());
    }
 else {
      stringWriter.append(ex.getMessage()).append('\n').append('\n');
      ex.printStackTrace(new PrintWriter(stringWriter));
    }
    errorDescription.setText(stringWriter.toString());
  }
 catch (  IOException ioe) {
    throw new IORuntimeException(ioe);
  }
}
Program: 4375
Project: 4375
Buggy source:
private void initComponents(Throwable ex){
  errorDialogLabel=new JLabel();
  scrollPane=new JScrollPane();
  errorDescription=new JTextArea();
  errorDescription.setLineWrap(true);
  errorDescription.setWrapStyleWord(true);
  Container contentPane=getContentPane();
  contentPane.setLayout(new BorderLayout(5,5));
  errorDialogLabel.setText(ex.getClass().getSimpleName());
  errorDialogLabel.setLabelFor(errorDescription);
  errorDialogLabel.setHorizontalAlignment(SwingConstants.CENTER);
  contentPane.add(errorDialogLabel,BorderLayout.NORTH);
  setErrorDetails(ex);
  scrollPane.setViewportView(errorDescription);
  contentPane.add(scrollPane,BorderLayout.CENTER);
  pack();
  Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize();
  setSize((int)screenSize.getWidth() >> 1,(int)screenSize.getHeight() >> 1);
  setLocationRelativeTo(null);
  setAlwaysOnTop(true);
}

Fixed version (ground truth):
private void initComponents(Throwable ex){
  errorDialogLabel=new JLabel();
  JScrollPane scrollPane=new JScrollPane();
  errorDescription=new JTextArea();
  errorDescription.setLineWrap(true);
  errorDescription.setWrapStyleWord(true);
  Container contentPane=getContentPane();
  contentPane.setLayout(new BorderLayout(5,5));
  errorDialogLabel.setText(ex.getClass().getSimpleName());
  errorDialogLabel.setLabelFor(errorDescription);
  errorDialogLabel.setHorizontalAlignment(SwingConstants.CENTER);
  contentPane.add(errorDialogLabel,BorderLayout.NORTH);
  setErrorDetails(ex);
  scrollPane.setViewportView(errorDescription);
  contentPane.add(scrollPane,BorderLayout.CENTER);
  pack();
  Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize();
  setSize((int)screenSize.getWidth() >> 1,(int)screenSize.getHeight() >> 1);
  setLocationRelativeTo(null);
  setAlwaysOnTop(true);
}
Program: 4376
Project: 4376
Buggy source:
private void launchFile(FileInfo node){
  try {
    File tempFile=node.downloadTemporary();
    Desktop.getDesktop().open(tempFile);
  }
 catch (  Exception ex) {
    throw new RuntimeException(ex);
  }
}

Fixed version (ground truth):
private void launchFile(FileInfo node){
  try {
    File tempFile=node.downloadTemporary();
    Desktop.getDesktop().open(tempFile);
  }
 catch (  Exception ex) {
    throw new AndroidScreenCastRuntimeException(ex);
  }
}
Program: 4377
Project: 4377
Buggy source:
public void launch(){
  jt.setModel(new DefaultTreeModel(new FolderTreeNode("String_Node_Str","String_Node_Str")));
  jt.setRootVisible(true);
  jt.addTreeSelectionListener(treeSelectionEvent -> {
    TreePath tp=treeSelectionEvent.getPath();
    if (tp == null)     return;
    if (!(tp.getLastPathComponent() instanceof FolderTreeNode))     return;
    FolderTreeNode node=(FolderTreeNode)tp.getLastPathComponent();
    displayFolder(node.path);
  }
);
  JScrollPane jsp=new JScrollPane(jt);
  jListFichiers=new JList<>();
  jListFichiers.setListData(new Object[]{});
  jSplitPane=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,jsp,new JScrollPane(jListFichiers));
  add(jSplitPane,BorderLayout.CENTER);
  setSize(640,480);
  setLocationRelativeTo(null);
  jListFichiers.addMouseListener(new MouseAdapter(){
    @Override public void mouseClicked(    MouseEvent e){
      if (e.getClickCount() == 2) {
        int index=jListFichiers.locationToIndex(e.getPoint());
        ListModel<Object> dlm=jListFichiers.getModel();
        FileInfo item=(FileInfo)dlm.getElementAt(index);
        launchFile(item);
      }
    }
  }
);
}

Fixed version (ground truth):
public void launch(){
  jt.setModel(new DefaultTreeModel(new FolderTreeNode("String_Node_Str","String_Node_Str")));
  jt.setRootVisible(true);
  jt.addTreeSelectionListener(treeSelectionEvent -> {
    TreePath tp=treeSelectionEvent.getPath();
    if (tp == null)     return;
    if (!(tp.getLastPathComponent() instanceof FolderTreeNode))     return;
    FolderTreeNode node=(FolderTreeNode)tp.getLastPathComponent();
    displayFolder(node.path);
  }
);
  JScrollPane jsp=new JScrollPane(jt);
  jListFichiers=new JList<>();
  jListFichiers.setListData(new Object[]{});
  JSplitPane jSplitPane=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,jsp,new JScrollPane(jListFichiers));
  add(jSplitPane,BorderLayout.CENTER);
  setSize(640,480);
  setLocationRelativeTo(null);
  jListFichiers.addMouseListener(new MouseAdapter(){
    @Override public void mouseClicked(    MouseEvent e){
      if (e.getClickCount() == 2) {
        int index=jListFichiers.locationToIndex(e.getPoint());
        ListModel<Object> dlm=jListFichiers.getModel();
        FileInfo item=(FileInfo)dlm.getElementAt(index);
        launchFile(item);
      }
    }
  }
);
}
Program: 4378
Project: 4378
Buggy source:
@PreDestroy private void cleanUp(){
  AndroidDebugBridge.disconnectBridge();
  AndroidDebugBridge.terminate();
}

Fixed version (ground truth):
@PreDestroy void cleanUp(){
  AndroidDebugBridge.disconnectBridge();
  AndroidDebugBridge.terminate();
}
Program: 4379
Project: 4379
Buggy source:
@Override public void stop(){
}

Fixed version (ground truth):
@Override public void stop(){
  bridge.stop();
}
Program: 4380
Project: 4380
Buggy source:
@Override public void start(){
  LOGGER.info("String_Node_Str");
  try {
    waitDeviceList(bridge);
    final IDevice devices[]=bridge.getDevices();
    if (devices.length == 1) {
      device=devices[0];
      LOGGER.info("String_Node_Str");
    }
 else {
      final JDialogDeviceList jd=new JDialogDeviceList(devices);
      jd.setVisible(true);
      device=jd.getDevice();
      LOGGER.info("String_Node_Str",devices.length);
    }
    if (device == null) {
      throw new NoDeviceChosenException();
    }
  }
 catch (  final Throwable e) {
    bridge.stop();
    throw e;
  }
  LOGGER.info("String_Node_Str",device.getName());
}

Fixed version (ground truth):
@Override public void start(){
  LOGGER.info("String_Node_Str");
  waitDeviceList(bridge);
  final IDevice devices[]=bridge.getDevices();
  if (devices.length == 1) {
    device=devices[0];
    LOGGER.info("String_Node_Str");
  }
 else {
    final JDialogDeviceList jd=new JDialogDeviceList(devices);
    jd.setVisible(true);
    device=jd.getDevice();
    LOGGER.info("String_Node_Str",devices.length);
  }
  if (device == null) {
    throw new NoDeviceChosenException();
  }
  LOGGER.info("String_Node_Str",device.getName());
}
Program: 4381
Project: 4381
Buggy source:
GUIApplication(){
  Runtime.getRuntime().addShutdownHook(new Thread(GUIApplication.this::stop));
  Thread.setDefaultUncaughtExceptionHandler((thread,ex) -> {
    try {
      handleException(thread,ex);
    }
 catch (    final Exception ex2) {
      LOGGER.error("String_Node_Str",ex2);
    }
  }
);
}

Fixed version (ground truth):
GUIApplication(){
  Runtime.getRuntime().addShutdownHook(new Thread(this::stop));
  Thread.setDefaultUncaughtExceptionHandler((thread,ex) -> {
    try {
      handleException(thread,ex);
    }
 catch (    final Exception ex2) {
      LOGGER.error("String_Node_Str",ex2);
    }
  }
);
}
Program: 4382
Project: 4382
Buggy source:
@Singleton @Provides public static IDevice iDevice(final DeviceChooserApplication application){
  application.init();
  application.start();
  application.stop();
  IDevice device=application.getDevice();
  return device;
}

Fixed version (ground truth):
@Singleton @Provides public static IDevice iDevice(final DeviceChooserApplication application){
  try {
    application.init();
    application.start();
    IDevice device=application.getDevice();
    return device;
  }
 catch (  Throwable e) {
    application.stop();
    throw e;
  }
}
Program: 4384
Project: 4384
Buggy source:
@Override protected void paintComponent(final Graphics g){
  if (isNotInitialized())   return;
  Graphics2D g2=(Graphics2D)g;
  g2.clearRect(0,0,getWidth(),getHeight());
  double width=Math.min(getWidth(),size.width * getHeight() / size.height);
  coef=(float)width / size.width;
  double height=width * size.height / size.width;
  origX=(getWidth() - width) / 2;
  origY=(getHeight() - height) / 2;
  g2.drawImage(image,(int)origX,(int)origY,(int)width,(int)height,this);
}

Fixed version (ground truth):
@Override protected void paintComponent(final Graphics g){
  if (isNotInitialized())   return;
  final Graphics2D g2=(Graphics2D)g;
  g2.clearRect(0,0,getWidth(),getHeight());
  final double width=Math.min(getWidth(),size.width * getHeight() / size.height);
  coef=(float)width / size.width;
  final double height=width * size.height / size.width;
  origX=(getWidth() - width) / 2;
  origY=(getHeight() - height) / 2;
  g2.drawImage(image,(int)origX,(int)origY,(int)width,(int)height,this);
}
Program: 4385
Project: 4385
Buggy source:
@Inject public JPanelScreen(){
  this.setFocusable(true);
}

Fixed version (ground truth):
@Inject public JPanelScreen(){
  setFocusable(true);
}
Program: 4386
Project: 4386
Buggy source:
public static <T>Observable<ObservableSet<T>> fromObservableSet(final ObservableSet<T> source){
  return Observable.create((Observable.OnSubscribe<ObservableSet<T>>)subscriber -> {
    SetChangeListener<T> listener=c -> subscriber.onNext(source);
    subscriber.add(JavaFxSubscriptions.unsubscribeInEventDispatchThread(() -> source.removeListener(listener)));
  }
).startWith(source).subscribeOn(JavaFxScheduler.getInstance());
}

Fixed version (ground truth):
public static <T>Observable<ObservableSet<T>> fromObservableSet(final ObservableSet<T> source){
  return Observable.create((Observable.OnSubscribe<ObservableSet<T>>)subscriber -> {
    SetChangeListener<T> listener=c -> subscriber.onNext(source);
    source.addListener(listener);
    subscriber.add(JavaFxSubscriptions.unsubscribeInEventDispatchThread(() -> source.removeListener(listener)));
  }
).startWith(source).subscribeOn(JavaFxScheduler.getInstance());
}
Program: 4387
Project: 4387
Buggy source:
@BeforeClass public static void initJFX(){
  Thread t=new Thread("String_Node_Str"){
    public void run(){
      Application.launch(AsNonApp.class,new String[0]);
    }
  }
;
  t.setDaemon(true);
  t.start();
}

Fixed version (ground truth):
@BeforeClass public static void initJFX(){
  JFXPanel panel=new JFXPanel();
}
Program: 4389
Project: 4389
Buggy source:
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  View v=inflater.inflate(R.layout.fragment_general_annotation,container,false);
  Injector.injectInto(this,v);
  permissionGuard=new PermissionGuard(mContext,this);
  initData();
  return v;
}

Fixed version (ground truth):
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  View v=inflater.inflate(R.layout.fragment_general_annotation,container,false);
  Injector.injectInto(this,v);
  initData();
  return v;
}
Program: 4390
Project: 4390
Buggy source:
private void initViews(){
  initFab();
  initToolbar();
  navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener(){
    @Override public boolean onNavigationItemSelected(    MenuItem menuItem){
      showMenu(menuItem);
      Snackbar.make(content,menuItem.getTitle() + "String_Node_Str",Snackbar.LENGTH_LONG).show();
      menuItem.setChecked(true);
      drawerLayout.closeDrawers();
      return true;
    }
  }
);
}

Fixed version (ground truth):
private void initViews(){
  initFab();
  initToolbar();
  navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener(){
    @Override public boolean onNavigationItemSelected(    MenuItem menuItem){
      showMenu(menuItem);
      toolbar.setTitle(menuItem.getTitle());
      Snackbar.make(content,menuItem.getTitle() + "String_Node_Str",Snackbar.LENGTH_LONG).show();
      menuItem.setChecked(true);
      drawerLayout.closeDrawers();
      return true;
    }
  }
);
}
Program: 4391
Project: 4391
Buggy source:
@Override public boolean onNavigationItemSelected(MenuItem menuItem){
  showMenu(menuItem);
  Snackbar.make(content,menuItem.getTitle() + "String_Node_Str",Snackbar.LENGTH_LONG).show();
  menuItem.setChecked(true);
  drawerLayout.closeDrawers();
  return true;
}

Fixed version (ground truth):
@Override public boolean onNavigationItemSelected(MenuItem menuItem){
  showMenu(menuItem);
  toolbar.setTitle(menuItem.getTitle());
  Snackbar.make(content,menuItem.getTitle() + "String_Node_Str",Snackbar.LENGTH_LONG).show();
  menuItem.setChecked(true);
  drawerLayout.closeDrawers();
  return true;
}
Program: 4392
Project: 4392
Buggy source:
private void initData(){
  data=new ArrayList<String>();
  data.add("String_Node_Str");
  data.add("String_Node_Str");
  data.add("String_Node_Str");
  data.add("String_Node_Str");
  data.add("String_Node_Str");
  data.add("String_Node_Str");
  adapter=new AnnoAdapter(mContext,data);
  listview.setAdapter(adapter);
  listview.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View v){
    }
  }
);
}

Fixed version (ground truth):
private void initData(){
  data=new ArrayList<String>();
  data.add("String_Node_Str");
  data.add("String_Node_Str");
  data.add("String_Node_Str");
  data.add("String_Node_Str");
  data.add("String_Node_Str");
  data.add("String_Node_Str");
  adapter=new AnnoAdapter(mContext,data);
  listview.setAdapter(adapter);
}
Program: 4393
Project: 4393
Buggy source:
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) private boolean putDiskCache(String key,Bitmap bitmap){
  if (bitmap == null)   return false;
  OutputStream out=null;
  String ekey=toMD5(key);
  DiskLruCache.Snapshot snapshot=null;
  try {
    snapshot=mCache.get(ekey);
    if (snapshot == null) {
      DiskLruCache.Editor editor=mCache.edit(ekey);
      if (editor == null)       return false;
      out=new BufferedOutputStream(editor.newOutputStream(0),IO_BUFFER_SIZE);
      Bitmap.CompressFormat format;
      if (key.equals("String_Node_Str") || key.endsWith("String_Node_Str")) {
        format=Bitmap.CompressFormat.PNG;
      }
 else       if (SAFUtils.isICSOrHigher() && key.equals("String_Node_Str")) {
        format=Bitmap.CompressFormat.WEBP;
      }
 else {
        format=Bitmap.CompressFormat.JPEG;
      }
      bitmap.compress(format,IMAGE_QUANLITY,out);
      editor.commit();
      mCache.flush();
      out.close();
    }
 else {
      snapshot.getInputStream(0).close();
    }
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
 finally {
    IOUtils.closeQuietly(out);
  }
  return true;
}

Fixed version (ground truth):
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) private boolean putDiskCache(String key,Bitmap bitmap){
  if (bitmap == null)   return false;
  OutputStream out=null;
  String ekey=toMD5(key);
  DiskLruCache.Snapshot snapshot=null;
  try {
    snapshot=mCache.get(ekey);
    if (snapshot == null) {
      DiskLruCache.Editor editor=mCache.edit(ekey);
      if (editor == null)       return false;
      out=new BufferedOutputStream(editor.newOutputStream(0),IO_BUFFER_SIZE);
      Bitmap.CompressFormat format;
      if (key.endsWith("String_Node_Str") || key.endsWith("String_Node_Str")) {
        format=Bitmap.CompressFormat.PNG;
      }
 else       if (SAFUtils.isICSOrHigher() && key.endsWith("String_Node_Str")) {
        format=Bitmap.CompressFormat.WEBP;
      }
 else {
        format=Bitmap.CompressFormat.JPEG;
      }
      bitmap.compress(format,IMAGE_QUANLITY,out);
      editor.commit();
      mCache.flush();
      out.close();
    }
 else {
      snapshot.getInputStream(0).close();
    }
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
 finally {
    IOUtils.closeQuietly(out);
  }
  return true;
}
Program: 4395
Project: 4395
Buggy source:
/** 
 * TODO frankswu : 对activity和fragment增加缓存
 * @param source
 * @param id
 * @return
 */
protected View findViewById(Object source,int id){
  View view=viewHandlerMap.get(source.getClass());
  if (view == null) {
    if (source instanceof Activity) {
      return ((Activity)source).findViewById(id);
    }
 else {
      return ((View)source).findViewById(id);
    }
  }
  return view;
}

Fixed version (ground truth):
/** 
 * TODO frankswu : 对activity和fragment增加缓存
 * @param source
 * @param id
 * @return
 */
protected View findViewById(Object source,int id){
  String key=source.getClass() + "String_Node_Str" + id;
  View view=viewHandlerMap.get(key);
  if (view == null) {
    if (source instanceof Activity) {
      view=((Activity)source).findViewById(id);
    }
 else {
      view=((View)source).findViewById(id);
    }
    viewHandlerMap.put(key,view);
  }
  return view;
}
Program: 4396
Project: 4396
Buggy source:
private boolean bindOnClickListener(final Method method,OnClick onClick,Set<View> modifiedViews,Finder finder){
  boolean invokeWithView=checkInvokeWithView(method,new Class[]{View.class});
  method.setAccessible(true);
  InjectedOnClickListener listener=new InjectedOnClickListener(target,method,invokeWithView);
  int[] ids=onClick.id();
  for (  int id : ids) {
    if (id != 0) {
      View view=findView(method,id,finder);
      view.setOnClickListener(listener);
    }
  }
  return invokeWithView;
}

Fixed version (ground truth):
private boolean bindOnClickListener(final Method method,OnClick onClick,Set<View> modifiedViews,Finder finder){
  boolean invokeWithView=checkInvokeWithView(method,new Class[]{View.class});
  method.setAccessible(true);
  InjectedOnClickListener listener=new InjectedOnClickListener(target,method,invokeWithView);
  int[] ids=onClick.id();
  for (  int id : ids) {
    if (id != 0) {
      View view=findView(method,id,finder);
      if (view != null) {
        view.setOnClickListener(listener);
      }
    }
  }
  return invokeWithView;
}
Program: 4398
Project: 4398
Buggy source:
/** 
 * @param method
 * @param annotation
 * @param modifiedViews
 * @param finder
 */
private boolean bindOnItemClickListener(Method method,OnItemClick onItemClick,Set<View> modifiedViews,Finder finder){
  boolean invokeWithView=checkInvokeWithView(method,new Class[]{AdapterView.class,View.class,int.class,long.class});
  method.setAccessible(true);
  InjectedOnItemClickListener listener=new InjectedOnItemClickListener(target,method,invokeWithView);
  int[] ids=onItemClick.id();
  for (  int id : ids) {
    if (id != 0) {
      AdapterView<?> view=null;
      try {
        view=(AdapterView<?>)findView(method,id,finder);
      }
 catch (      Exception e) {
        throw new InjectException("String_Node_Str");
      }
      view.setOnItemClickListener(listener);
    }
  }
  return invokeWithView;
}

Fixed version (ground truth):
/** 
 * @param method
 * @param annotation
 * @param modifiedViews
 * @param finder
 */
private boolean bindOnItemClickListener(Method method,OnItemClick onItemClick,Set<View> modifiedViews,Finder finder){
  boolean invokeWithView=checkInvokeWithView(method,new Class[]{AdapterView.class,View.class,int.class,long.class});
  method.setAccessible(true);
  InjectedOnItemClickListener listener=new InjectedOnItemClickListener(target,method,invokeWithView);
  int[] ids=onItemClick.id();
  for (  int id : ids) {
    if (id != 0) {
      AdapterView<?> view=null;
      try {
        view=(AdapterView<?>)findView(method,id,finder);
        if (view != null) {
          view.setOnItemClickListener(listener);
        }
      }
 catch (      Exception e) {
        throw new InjectException("String_Node_Str");
      }
    }
  }
  return invokeWithView;
}
Program: 4399
Project: 4399
Buggy source:
private boolean bindOnLongClickListener(Method method,OnLongClick onLongClick,Set<View> modifiedViews,Finder finder){
  boolean invokeWithView=checkInvokeWithView(method,new Class[]{View.class});
  method.setAccessible(true);
  InjectedOnLongClickListener listener=new InjectedOnLongClickListener(target,method,invokeWithView);
  int[] ids=onLongClick.id();
  for (  int id : ids) {
    if (id != 0) {
      View view=findView(method,id,finder);
      view.setOnLongClickListener(listener);
    }
  }
  return invokeWithView;
}

Fixed version (ground truth):
private boolean bindOnLongClickListener(Method method,OnLongClick onLongClick,Set<View> modifiedViews,Finder finder){
  boolean invokeWithView=checkInvokeWithView(method,new Class[]{View.class});
  method.setAccessible(true);
  InjectedOnLongClickListener listener=new InjectedOnLongClickListener(target,method,invokeWithView);
  int[] ids=onLongClick.id();
  for (  int id : ids) {
    if (id != 0) {
      View view=findView(method,id,finder);
      if (view != null) {
        view.setOnLongClickListener(listener);
      }
    }
  }
  return invokeWithView;
}
Program: 4400
Project: 4400
Buggy source:
@Override public void onItemClick(AdapterView<?> parentView,View view,int position,long id){
  if (enabled) {
    enabled=false;
    view.post(ENABLE_AGAIN);
    handleOnListener(view,position,id);
  }
}

Fixed version (ground truth):
@Override public void onItemClick(AdapterView<?> parentView,View view,int position,long id){
  if (enabled) {
    enabled=false;
    view.post(ENABLE_AGAIN);
    handleOnListener(parentView,view,position,id);
  }
}
Program: 4401
Project: 4401
Buggy source:
private void bindMethods(Finder finder){
  Method[] methods=clazz.getDeclaredMethods();
  Set<View> modifiedViews=new HashSet<View>();
  for (  final Method method : methods) {
    Annotation[] annotations=method.getAnnotations();
    for (    Annotation annotation : annotations) {
      if (annotation.annotationType() == OnClick.class) {
        bindOnClickListener(method,(OnClick)annotation,modifiedViews,finder);
      }
      if (annotation.annotationType() == OnItemClick.class) {
        bindOnItemClickListener(method,(OnItemClick)annotation,modifiedViews,finder);
      }
    }
  }
}

Fixed version (ground truth):
private void bindMethods(Finder finder){
  Method[] methods=clazz.getDeclaredMethods();
  Set<View> modifiedViews=new HashSet<View>();
  for (  final Method method : methods) {
    Annotation[] annotations=method.getAnnotations();
    for (    Annotation annotation : annotations) {
      if (annotation.annotationType() == OnClick.class) {
        bindOnClickListener(method,(OnClick)annotation,modifiedViews,finder);
      }
 else       if (annotation.annotationType() == OnItemClick.class) {
        bindOnItemClickListener(method,(OnItemClick)annotation,modifiedViews,finder);
      }
    }
  }
}
Program: 4402
Project: 4402
Buggy source:
/** 
 * 增加OnClick事件的绑定
 * @param method
 * @param onClick
 * @param modifiedViews
 * @param finder
 * @return
 */
private boolean bindOnClickListener(final Method method,OnClick onClick,Set<View> modifiedViews,Finder finder){
  boolean invokeWithView=checkInvokeWithView(method);
  method.setAccessible(true);
  InjectedOnClickListener listener=new InjectedOnClickListener(target,method,invokeWithView);
  int[] ids=onClick.id();
  for (  int id : ids) {
    if (id != 0) {
      View view=findView(method,id,finder);
      boolean modified=modifiedViews.add(view);
      if (!modified) {
        throw new InjectException("String_Node_Str" + method.getName());
      }
      view.setOnClickListener(listener);
    }
  }
  return invokeWithView;
}

Fixed version (ground truth):
private boolean bindOnClickListener(final Method method,OnClick onClick,Set<View> modifiedViews,Finder finder){
  boolean invokeWithView=checkInvokeWithView(method,new Class[]{View.class});
  method.setAccessible(true);
  InjectedOnClickListener listener=new InjectedOnClickListener(target,method,invokeWithView);
  int[] ids=onClick.id();
  for (  int id : ids) {
    if (id != 0) {
      View view=findView(method,id,finder);
      boolean modified=modifiedViews.add(view);
      if (!modified) {
        throw new InjectException("String_Node_Str" + method.getName());
      }
      view.setOnClickListener(listener);
    }
  }
  return invokeWithView;
}
Program: 4403
Project: 4403
Buggy source:
private boolean checkInvokeWithView(Method method){
  Class<?>[] parameterTypes=method.getParameterTypes();
  if (parameterTypes.length == 0) {
    return false;
  }
 else   if (parameterTypes.length == 1) {
    if (parameterTypes[0] == View.class) {
      return true;
    }
 else {
      throw new InjectException("String_Node_Str" + method.getName() + "String_Node_Str"+ parameterTypes[0]);
    }
  }
 else {
    throw new InjectException("String_Node_Str" + method.getName());
  }
}

Fixed version (ground truth):
private boolean checkInvokeWithView(Method method,Class[] paramterClass){
  Class<?>[] parameterTypes=method.getParameterTypes();
  int paramterNum=paramterClass.length;
  if (parameterTypes.length == 0) {
    return false;
  }
 else   if (parameterTypes.length == paramterNum) {
    if (paramterClass.length == parameterTypes.length) {
      for (int i=0; i < parameterTypes.length; i++) {
        if (parameterTypes[i] == paramterClass[i]) {
          return true;
        }
 else {
          throw new InjectException("String_Node_Str" + method.getName() + "String_Node_Str"+ paramterClass[i]+ "String_Node_Str"+ parameterTypes[i]+ "String_Node_Str");
        }
      }
    }
 else {
      return false;
    }
  }
 else {
    throw new InjectException("String_Node_Str" + method.getName() + "String_Node_Str"+ paramterNum+ "String_Node_Str"+ parameterTypes.length);
  }
  return false;
}
Program: 4404
Project: 4404
Buggy source:
/** 
 * frankswu add OnItemClick，增加OnItemClick事件的绑定
 * @param method
 * @param annotation
 * @param modifiedViews
 * @param finder
 */
private boolean bindOnItemClickListener(Method method,OnItemClick onItemClick,Set<View> modifiedViews,Finder finder){
  boolean invokeWithView=checkInvokeWithView(method);
  method.setAccessible(true);
  InjectedOnItemClickListener listener=new InjectedOnItemClickListener(target,method,invokeWithView);
  int[] ids=onItemClick.id();
  for (  int id : ids) {
    if (id != 0) {
      AdapterView<?> view=null;
      try {
        view=(AdapterView<?>)findView(method,id,finder);
      }
 catch (      Exception e) {
        throw new InjectException("String_Node_Str");
      }
      boolean modified=modifiedViews.add(view);
      if (!modified) {
        throw new InjectException("String_Node_Str" + method.getName());
      }
      view.setOnItemClickListener(listener);
    }
  }
  return invokeWithView;
}

Fixed version (ground truth):
/** 
 * @param method
 * @param annotation
 * @param modifiedViews
 * @param finder
 */
private boolean bindOnItemClickListener(Method method,OnItemClick onItemClick,Set<View> modifiedViews,Finder finder){
  boolean invokeWithView=checkInvokeWithView(method,new Class[]{AdapterView.class,View.class,int.class,long.class});
  method.setAccessible(true);
  InjectedOnItemClickListener listener=new InjectedOnItemClickListener(target,method,invokeWithView);
  int[] ids=onItemClick.id();
  for (  int id : ids) {
    if (id != 0) {
      AdapterView<?> view=null;
      try {
        view=(AdapterView<?>)findView(method,id,finder);
      }
 catch (      Exception e) {
        throw new InjectException("String_Node_Str");
      }
      boolean modified=modifiedViews.add(view);
      if (!modified) {
        throw new InjectException("String_Node_Str" + method.getName());
      }
      view.setOnItemClickListener(listener);
    }
  }
  return invokeWithView;
}
Program: 4405
Project: 4405
Buggy source:
private View findView(Member field,int viewId,Finder finder){
  View view=null;
switch (finder) {
case DIALOG:
    return Finder.DIALOG.findById(target,viewId);
case ACTIVITY:
  if (activity == null) {
    throw new InjectException("String_Node_Str" + field.getName() + "String_Node_Str"+ context.getClass());
  }
view=finder.findById(activity,viewId);
if (view == null) {
throw new InjectException("String_Node_Str" + field.getName());
}
break;
case FRAGMENT:
return Finder.FRAGMENT.findById(fragmentView,viewId);
case VIEW:
view=Finder.VIEW.findById(target,viewId);
break;
default :
break;
}
return view;
}

Fixed version (ground truth):
private View findView(Member field,int viewId,Finder finder){
  View view=null;
switch (finder) {
case DIALOG:
    view=Finder.DIALOG.findById(target,viewId);
  break;
case ACTIVITY:
if (activity == null) {
  throw new InjectException("String_Node_Str" + field.getName() + "String_Node_Str"+ context.getClass());
}
view=finder.findById(activity,viewId);
if (view == null) {
throw new InjectException("String_Node_Str" + field.getName());
}
break;
case FRAGMENT:
view=Finder.FRAGMENT.findById(fragmentView,viewId);
break;
case VIEW:
view=Finder.VIEW.findById(target,viewId);
break;
default :
break;
}
return view;
}
Program: 4406
Project: 4406
Buggy source:
/** 
 * 查找supprot fragment
 * @param field
 * @param fragmentId
 * @return
 */
private Fragment findSupportFragment(Field field,int fragmentId){
  if (activity == null) {
    throw new InjectException("String_Node_Str" + field.getName() + "String_Node_Str"+ context.getClass());
  }
  Fragment fragment=null;
  if (activity instanceof FragmentActivity) {
    fragment=((FragmentActivity)activity).getSupportFragmentManager().findFragmentById(fragmentId);
  }
  if (fragment == null) {
    throw new InjectException("String_Node_Str" + field.getName());
  }
  return fragment;
}

Fixed version (ground truth):
/** 
 * 查找fragment
 * @param field
 * @param fragmentId
 * @return
 */
private Fragment findSupportFragment(Field field,int fragmentId){
  if (activity == null) {
    throw new InjectException("String_Node_Str" + field.getName() + "String_Node_Str"+ context.getClass());
  }
  Fragment fragment=null;
  if (activity instanceof FragmentActivity) {
    fragment=((FragmentActivity)activity).getSupportFragmentManager().findFragmentById(fragmentId);
  }
  if (fragment == null) {
    throw new InjectException("String_Node_Str" + field.getName());
  }
  return fragment;
}
Program: 4407
Project: 4407
Buggy source:
public MySSLSocketFactory(KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException {
  super(null);
  try {
    SSLContext context=SSLContext.getInstance("String_Node_Str");
    TrustManager[] trustAllCerts=new TrustManager[]{new X509TrustManager(){
      public java.security.cert.X509Certificate[] getAcceptedIssuers(){
        return new java.security.cert.X509Certificate[]{};
      }
      public void checkClientTrusted(      X509Certificate[] chain,      String authType) throws CertificateException {
      }
      public void checkServerTrusted(      X509Certificate[] chain,      String authType) throws CertificateException {
      }
    }
};
    context.init(null,trustAllCerts,new SecureRandom());
    sslFactory=context.getSocketFactory();
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
public MySSLSocketFactory(KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException {
  super(truststore);
  try {
    SSLContext context=SSLContext.getInstance("String_Node_Str");
    TrustManager[] trustAllCerts=new TrustManager[]{new X509TrustManager(){
      public java.security.cert.X509Certificate[] getAcceptedIssuers(){
        return new java.security.cert.X509Certificate[]{};
      }
      public void checkClientTrusted(      X509Certificate[] chain,      String authType) throws CertificateException {
      }
      public void checkServerTrusted(      X509Certificate[] chain,      String authType) throws CertificateException {
      }
    }
};
    context.init(null,trustAllCerts,new SecureRandom());
    sslFactory=context.getSocketFactory();
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}
Program: 4409
Project: 4409
Buggy source:
@Override public void run(){
  final int buf_sz=AudioRecord.getMinBufferSize(SAMPLE_RATE,AudioFormat.CHANNEL_IN_MONO,AudioFormat.ENCODING_PCM_16BIT) * 4;
  final AudioRecord audioRecord=new AudioRecord(MediaRecorder.AudioSource.MIC,SAMPLE_RATE,AudioFormat.CHANNEL_IN_MONO,AudioFormat.ENCODING_PCM_16BIT,buf_sz);
  try {
    if (mIsCapturing) {
      if (DEBUG)       Log.v(TAG,"String_Node_Str");
      final byte[] buf=new byte[buf_sz];
      int readBytes;
      audioRecord.startRecording();
      try {
        while (mIsCapturing && !mRequestStop && !mIsEOS) {
          readBytes=audioRecord.read(buf,0,buf_sz);
          if (readBytes > 0) {
            encode(buf,readBytes,getPTSUs());
            frameAvailableSoon();
          }
        }
        frameAvailableSoon();
      }
  finally {
        audioRecord.stop();
      }
    }
  }
  finally {
    audioRecord.release();
  }
  if (DEBUG)   Log.v(TAG,"String_Node_Str");
}

Fixed version (ground truth):
@Override public void run(){
  try {
    final int buf_sz=AudioRecord.getMinBufferSize(SAMPLE_RATE,AudioFormat.CHANNEL_IN_MONO,AudioFormat.ENCODING_PCM_16BIT) * 4;
    final AudioRecord audioRecord=new AudioRecord(MediaRecorder.AudioSource.MIC,SAMPLE_RATE,AudioFormat.CHANNEL_IN_MONO,AudioFormat.ENCODING_PCM_16BIT,buf_sz);
    try {
      if (mIsCapturing) {
        if (DEBUG)         Log.v(TAG,"String_Node_Str");
        final byte[] buf=new byte[buf_sz];
        int readBytes;
        audioRecord.startRecording();
        try {
          while (mIsCapturing && !mRequestStop && !mIsEOS) {
            readBytes=audioRecord.read(buf,0,buf_sz);
            if (readBytes > 0) {
              encode(buf,readBytes,getPTSUs());
              frameAvailableSoon();
            }
          }
          frameAvailableSoon();
        }
  finally {
          audioRecord.stop();
        }
      }
    }
  finally {
      audioRecord.release();
    }
  }
 catch (  Exception e) {
    Log.e(TAG,"String_Node_Str",e);
  }
  if (DEBUG)   Log.v(TAG,"String_Node_Str");
}
Program: 4410
Project: 4410
Buggy source:
/** 
 * generate output file
 * @param type Environment.DIRECTORY_MOVIES / Environment.DIRECTORY_DCIM etc.
 * @param ext .mp4(.m4a for audio) or .png
 * @return return null when this app has no writing permission to external storage.
 */
private static final File getCaptureFile(String type,String ext){
  final File dir=new File(Environment.getExternalStoragePublicDirectory(type),DIR_NAME);
  Log.d(TAG,"String_Node_Str" + dir.toString());
  dir.mkdirs();
  if (dir.canWrite()) {
    return new File(dir,getDateTimeString() + ext);
  }
  return null;
}

Fixed version (ground truth):
/** 
 * generate output file
 * @param type Environment.DIRECTORY_MOVIES / Environment.DIRECTORY_DCIM etc.
 * @param ext .mp4(.m4a for audio) or .png
 * @return return null when this app has no writing permission to external storage.
 */
public static final File getCaptureFile(String type,String ext){
  final File dir=new File(Environment.getExternalStoragePublicDirectory(type),DIR_NAME);
  Log.d(TAG,"String_Node_Str" + dir.toString());
  dir.mkdirs();
  if (dir.canWrite()) {
    return new File(dir,getDateTimeString() + ext);
  }
  return null;
}
Program: 4411
Project: 4411
Buggy source:
public void setEglContext(EGLContext shared_context,int tex_id){
  mRenderHandler.setEglContext(shared_context,tex_id,mSurface);
}

Fixed version (ground truth):
public void setEglContext(EGLContext shared_context,int tex_id){
  mRenderHandler.setEglContext(shared_context,tex_id,mSurface,true);
}
Program: 4412
Project: 4412
Buggy source:
private void init(EGLContext shared_context,boolean with_depth_buffer){
  if (DEBUG)   Log.v(TAG,"String_Node_Str");
  if (mEglDisplay != EGL14.EGL_NO_DISPLAY) {
    throw new RuntimeException("String_Node_Str");
  }
  mEglDisplay=EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY);
  if (mEglDisplay == EGL14.EGL_NO_DISPLAY) {
    throw new RuntimeException("String_Node_Str");
  }
  final int[] version=new int[2];
  if (!EGL14.eglInitialize(mEglDisplay,version,0,version,1)) {
    mEglDisplay=null;
    throw new RuntimeException("String_Node_Str");
  }
  shared_context=shared_context != null ? shared_context : EGL14.EGL_NO_CONTEXT;
  if (mEglContext == EGL14.EGL_NO_CONTEXT) {
    mEglConfig=getConfig(with_depth_buffer);
    if (mEglConfig == null) {
      throw new RuntimeException("String_Node_Str");
    }
    mEglContext=createContext(shared_context);
  }
  final int[] values=new int[1];
  EGL14.eglQueryContext(mEglDisplay,mEglContext,EGL14.EGL_CONTEXT_CLIENT_VERSION,values,0);
  if (DEBUG)   Log.d(TAG,"String_Node_Str" + values[0]);
}

Fixed version (ground truth):
private void init(EGLContext shared_context,boolean with_depth_buffer,boolean isRecordable){
  if (DEBUG)   Log.v(TAG,"String_Node_Str");
  if (mEglDisplay != EGL14.EGL_NO_DISPLAY) {
    throw new RuntimeException("String_Node_Str");
  }
  mEglDisplay=EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY);
  if (mEglDisplay == EGL14.EGL_NO_DISPLAY) {
    throw new RuntimeException("String_Node_Str");
  }
  final int[] version=new int[2];
  if (!EGL14.eglInitialize(mEglDisplay,version,0,version,1)) {
    mEglDisplay=null;
    throw new RuntimeException("String_Node_Str");
  }
  shared_context=shared_context != null ? shared_context : EGL14.EGL_NO_CONTEXT;
  if (mEglContext == EGL14.EGL_NO_CONTEXT) {
    mEglConfig=getConfig(with_depth_buffer,isRecordable);
    if (mEglConfig == null) {
      throw new RuntimeException("String_Node_Str");
    }
    mEglContext=createContext(shared_context);
  }
  final int[] values=new int[1];
  EGL14.eglQueryContext(mEglDisplay,mEglContext,EGL14.EGL_CONTEXT_CLIENT_VERSION,values,0);
  if (DEBUG)   Log.d(TAG,"String_Node_Str" + values[0]);
  makeDefault();
}
Program: 4413
Project: 4413
Buggy source:
/** 
 * change context to draw this window surface
 * @return
 */
private boolean makeCurrent(EGLSurface surface){
  if (DEBUG)   Log.v(TAG,"String_Node_Str");
  if (mEglDisplay == null) {
    if (DEBUG)     Log.d(TAG,"String_Node_Str");
  }
  if (surface == null || surface == EGL14.EGL_NO_SURFACE) {
    int error=EGL14.eglGetError();
    if (error == EGL14.EGL_BAD_NATIVE_WINDOW) {
      Log.e(TAG,"String_Node_Str");
    }
    return false;
  }
  if (!EGL14.eglMakeCurrent(mEglDisplay,surface,surface,mEglContext)) {
    Log.w("String_Node_Str","String_Node_Str" + EGL14.eglGetError());
    return false;
  }
  return true;
}

Fixed version (ground truth):
/** 
 * change context to draw this window surface
 * @return
 */
private boolean makeCurrent(EGLSurface surface){
  if (mEglDisplay == null) {
    if (DEBUG)     Log.d(TAG,"String_Node_Str");
  }
  if (surface == null || surface == EGL14.EGL_NO_SURFACE) {
    int error=EGL14.eglGetError();
    if (error == EGL14.EGL_BAD_NATIVE_WINDOW) {
      Log.e(TAG,"String_Node_Str");
    }
    return false;
  }
  if (!EGL14.eglMakeCurrent(mEglDisplay,surface,surface,mEglContext)) {
    Log.w(TAG,"String_Node_Str" + EGL14.eglGetError());
    return false;
  }
  return true;
}
Program: 4414
Project: 4414
Buggy source:
private int swap(EGLSurface surface){
  if (DEBUG)   Log.v(TAG,"String_Node_Str");
  if (!EGL14.eglSwapBuffers(mEglDisplay,surface)) {
    final int err=EGL14.eglGetError();
    if (DEBUG)     Log.w(TAG,"String_Node_Str" + err);
    return err;
  }
  return EGL14.EGL_SUCCESS;
}

Fixed version (ground truth):
private int swap(EGLSurface surface){
  if (!EGL14.eglSwapBuffers(mEglDisplay,surface)) {
    final int err=EGL14.eglGetError();
    if (DEBUG)     Log.w(TAG,"String_Node_Str" + err);
    return err;
  }
  return EGL14.EGL_SUCCESS;
}
Program: 4415
Project: 4415
Buggy source:
private EGLSurface createWindowSurface(Object nativeWindow){
  if (DEBUG)   Log.v(TAG,"String_Node_Str");
  final int[] surfaceAttribs={EGL14.EGL_NONE};
  EGLSurface result=null;
  try {
    result=EGL14.eglCreateWindowSurface(mEglDisplay,mEglConfig,nativeWindow,surfaceAttribs,0);
  }
 catch (  IllegalArgumentException e) {
    Log.e(TAG,"String_Node_Str",e);
  }
  return result;
}

Fixed version (ground truth):
private EGLSurface createWindowSurface(Object nativeWindow){
  if (DEBUG)   Log.v(TAG,"String_Node_Str" + nativeWindow);
  final int[] surfaceAttribs={EGL14.EGL_NONE};
  EGLSurface result=null;
  try {
    result=EGL14.eglCreateWindowSurface(mEglDisplay,mEglConfig,nativeWindow,surfaceAttribs,0);
  }
 catch (  IllegalArgumentException e) {
    Log.e(TAG,"String_Node_Str",e);
  }
  return result;
}
Program: 4416
Project: 4416
Buggy source:
public EglSurface createFromSurface(Surface surface){
  if (DEBUG)   Log.i(TAG,"String_Node_Str");
  final EglSurface eglSurface=new EglSurface(this,surface);
  return eglSurface;
}

Fixed version (ground truth):
public EglSurface createFromSurface(Object surface){
  if (DEBUG)   Log.v(TAG,"String_Node_Str");
  final EglSurface eglSurface=new EglSurface(this,surface);
  eglSurface.makeCurrent();
  return eglSurface;
}