nus-yam/ex-repair huggingface dataset:
Program: 98455
Project: 98455
Buggy source:
/** 
 * Inserts a product into the appropriate DB table.
 * @param className
 * @param product
 * @return Whether or not the insert was successful.
 */
private boolean insertIntoTable(String className,Product product){
  try {
    int originalCount=getRecordCount(className);
    Class<?> c=product.getClass();
    Field[] fields=c.getFields();
    fields=sortFields(fields);
    String sql="String_Node_Str" + className + "String_Node_Str";
    for (int i=0; i < fields.length; i++) {
      sql+=fields[i].getName();
      if (i < fields.length - 1) {
        sql+="String_Node_Str";
      }
    }
    sql+="String_Node_Str";
    for (int i=0; i < fields.length; i++) {
      sql+="String_Node_Str";
      if (i < fields.length - 1) {
        sql+="String_Node_Str";
      }
    }
    sql+="String_Node_Str";
    PreparedStatement preparedStatement=conn.prepareStatement(sql);
    for (int i=0; i < fields.length; i++) {
      if (!fields[i].getName().equals("String_Node_Str")) {
        Object obj=fields[i].get(product);
        if (obj != null) {
          setPreparedStatementValues(preparedStatement,fields[i],i + 1,product);
        }
      }
    }
    preparedStatement.addBatch();
    preparedStatement.executeBatch();
    if (getRecordCount(className) == originalCount + 1) {
      return true;
    }
 else {
      return false;
    }
  }
 catch (  Exception e) {
    System.err.println("String_Node_Str");
    e.printStackTrace();
    return false;
  }
}

Fixed version (ground truth):
private boolean insertIntoTable(String className,Product product){
  try {
    int originalCount=getRecordCount(className);
    Class<?> c=product.getClass();
    Field[] fields=c.getFields();
    fields=sortFields(fields);
    String sql="String_Node_Str" + className + "String_Node_Str";
    for (int i=0; i < fields.length; i++) {
      sql+=fields[i].getName();
      if (i < fields.length - 1) {
        sql+="String_Node_Str";
      }
    }
    sql+="String_Node_Str";
    for (int i=0; i < fields.length; i++) {
      sql+="String_Node_Str";
      if (i < fields.length - 1) {
        sql+="String_Node_Str";
      }
    }
    sql+="String_Node_Str";
    PreparedStatement preparedStatement=conn.prepareStatement(sql);
    for (int i=0; i < fields.length; i++) {
      if (!fields[i].getName().equals("String_Node_Str")) {
        Object obj=fields[i].get(product);
        if (obj != null) {
          setPreparedStatementValues(preparedStatement,fields[i],i + 1,product);
        }
      }
    }
    preparedStatement.addBatch();
    preparedStatement.executeBatch();
    if (getRecordCount(className) == originalCount + 1) {
      return true;
    }
 else {
      return false;
    }
  }
 catch (  Exception e) {
    System.err.println("String_Node_Str");
    e.printStackTrace();
    return false;
  }
}
Program: 98456
Project: 98456
Buggy source:
/** 
 * Loads a particular instance of a product from the database.
 * @param id The id of the desired product
 * @param className The name of the product that we are interested in's class.
 */
@Override protected Product loadProductFromId(int id,String className){
  String tableName=extractTableName(className);
  Product newProduct=null;
  try {
    Statement statement=conn.createStatement();
    ResultSet rs=statement.executeQuery("String_Node_Str" + "String_Node_Str" + tableName + "String_Node_Str"+ id+ "String_Node_Str");
    if (rs.next()) {
      newProduct=createProductFromResultSet(rs,tableName);
    }
  }
 catch (  Exception e) {
    System.err.println("String_Node_Str");
    e.printStackTrace();
  }
  return newProduct;
}

Fixed version (ground truth):
@Override protected Product loadProductFromId(int id,String className){
  String tableName=extractTableName(className);
  Product newProduct=null;
  try {
    Statement statement=conn.createStatement();
    ResultSet rs=statement.executeQuery("String_Node_Str" + "String_Node_Str" + tableName + "String_Node_Str"+ id+ "String_Node_Str");
    if (rs.next()) {
      newProduct=createProductFromResultSet(rs,tableName);
    }
  }
 catch (  Exception e) {
    System.err.println("String_Node_Str");
    e.printStackTrace();
  }
  return newProduct;
}
Program: 98457
Project: 98457
Buggy source:
private LinkedHashSet<Field> getFieldsInOrder(Class c,Class upperClass){
  LinkedHashSet<Field> fields=new LinkedHashSet<Field>();
  if (c.equals(upperClass)) {
    fields.addAll(Arrays.asList(c.getFields()));
  }
 else {
    fields.addAll(getFieldsInOrder(c.getSuperclass(),upperClass));
    fields.addAll(Arrays.asList(c.getFields()));
  }
  return fields;
}

Fixed version (ground truth):
/** 
 * Get the fields in order so the highest parents fields a are first in the list and so on till the current class, if a subclass overrides a parents field then the parents field is overriden
 * @param c
 * @param upperClass
 * @return
 */
private LinkedHashSet<Field> getFieldsInOrder(Class c,Class upperClass){
  LinkedHashSet<Field> parentFields=new LinkedHashSet<Field>();
  LinkedHashSet<Field> newFields=new LinkedHashSet<Field>();
  if (c.equals(upperClass)) {
    parentFields.addAll(Arrays.asList(c.getFields()));
  }
 else {
    parentFields.addAll(getFieldsInOrder(c.getSuperclass(),upperClass));
    List<Field> currentClassFields=new ArrayList<Field>();
    for (    Field f : c.getFields()) {
      System.out.println(f.getDeclaringClass());
      if (f.getDeclaringClass().equals(c)) {
        currentClassFields.add(f);
      }
    }
    for (    Field f : currentClassFields) {
      for (Iterator<Field> it=parentFields.iterator(); it.hasNext(); ) {
        if (f.getName().equals(it.next().getName())) {
          it.remove();
        }
      }
    }
    parentFields.addAll(currentClassFields);
  }
  return parentFields;
}
Program: 98458
Project: 98458
Buggy source:
public void commitCache(){
  Map<Product,Status> list=cache.getCache();
  for (  Map.Entry<Product,Status> entry : list.entrySet()) {
    Product p=entry.getKey();
    Status s=entry.getValue();
    if (s == Status.DELETED) {
    }
 else     if (s == Status.UPDATED) {
    }
 else     if (s == Status.NEW) {
      System.out.println("String_Node_Str" + p.toString());
      DataAccessor.save(p);
    }
  }
}

Fixed version (ground truth):
public void commitCache(){
  Map<Product,Status> list=cache.getCache();
  for (  Map.Entry<Product,Status> entry : list.entrySet()) {
    Product p=entry.getKey();
    Status s=entry.getValue();
    System.out.println(s.toString() + "String_Node_Str" + p.toString());
    if (s == Status.DELETED) {
    }
 else     if (s == Status.UPDATED) {
    }
 else     if (s == Status.NEW) {
      System.out.println("String_Node_Str" + p.toString());
      DataAccessor.save(p);
    }
  }
}
Program: 98459
Project: 98459
Buggy source:
/** 
 * The treeExpanded method is similar to valueChanged - it fires the same classSelected event but seeing as products can't have children it doesn't need to worry about updating the form. The main purpose in this existing is for when products are added and automatically scrolled to. This doesn't could as a valueChanged event, but a treeExpanded event, and it needs to react accordingly.
 */
@Override public void treeExpanded(TreeExpansionEvent event){
  TreePath path=(TreePath)event.getPath();
  if (!(path == null)) {
    NodeItem selectedNode=(NodeItem)path.getLastPathComponent();
    Object o=selectedNode.getStoredObject();
    if (o.getClass().equals(Class.class)) {
      String s=o.toString();
      ActionEvent i=new ActionEvent(model,0,s.substring(s.lastIndexOf(' ') + 1));
      classSelectListener.actionPerformed(i);
    }
  }
}

Fixed version (ground truth):
/** 
 * The treeExpanded method is similar to valueChanged - it fires the same classSelected event but seeing as products can't have children it doesn't need to worry about updating the form. The main purpose in this existing is for when products are added and automatically scrolled to. This doesn't could as a valueChanged event, but a treeExpanded event, and it needs to react accordingly.
 */
@Override public void treeExpanded(TreeExpansionEvent event){
  TreePath path=(TreePath)event.getPath();
  if (!(path == null)) {
    NodeItem selectedNode=getSelectedNode();
    Object o=selectedNode.getStoredObject();
    if (o.getClass().equals(Class.class)) {
      String s=o.toString();
      ActionEvent i=new ActionEvent(model,0,s);
    }
  }
}
Program: 98460
Project: 98460
Buggy source:
/** 
 * The valueChanged listener is called all the time. The most crucial part is that it accurately distinguishes between class and product selection. If it's a class selection, it fires a classSelectionEvent which is either handled as a DB or cache query. A product selection results in a productSelection event firing which ends up filling in the form in the GUI.
 */
@Override public void valueChanged(TreeSelectionEvent event){
  if (event.isAddedPath()) {
    if (productEditedListener != null && lastSelectedNode != null && (!lastSelectedNode.getClass().equals(Class.class))) {
      System.out.println("String_Node_Str");
      ActionEvent edited=new ActionEvent((Product)lastSelectedNode.getStoredObject(),0,"String_Node_Str");
      productEditedListener.actionPerformed(edited);
    }
    TreePath path=event.getNewLeadSelectionPath();
    NodeItem selectedNode=(NodeItem)path.getLastPathComponent();
    Object o=selectedNode.getStoredObject();
    if (o.getClass().equals(Class.class)) {
      String s=o.toString();
      ActionEvent i=new ActionEvent(model,0,s);
      classSelectListener.actionPerformed(i);
    }
 else {
      ActionEvent s=new ActionEvent((Product)selectedNode.getStoredObject(),0,"String_Node_Str");
      productSelectedListener.actionPerformed(s);
      lastSelectedNode=selectedNode;
      System.out.println(lastSelectedNode.toString());
    }
  }
}

Fixed version (ground truth):
/** 
 * The valueChanged listener is called all the time. The most crucial part is that it accurately distinguishes between class and product selection. If it's a class selection, it fires a classSelectionEvent which is either handled as a DB or cache query. A product selection results in a productSelection event firing which ends up filling in the form in the GUI.
 */
@Override public void valueChanged(TreeSelectionEvent event){
  if (event.isAddedPath()) {
    if (productEditedListener != null && lastSelectedNode != null && (!lastSelectedNode.getClass().equals(Class.class))) {
      ActionEvent edited=new ActionEvent((Product)lastSelectedNode.getStoredObject(),0,"String_Node_Str");
      productEditedListener.actionPerformed(edited);
    }
    TreePath path=event.getNewLeadSelectionPath();
    NodeItem selectedNode=(NodeItem)path.getLastPathComponent();
    Object o=selectedNode.getStoredObject();
    if (o.getClass().equals(Class.class)) {
      String s=o.toString();
      ActionEvent i=new ActionEvent(model,0,s);
      classSelectListener.actionPerformed(i);
    }
 else {
      ActionEvent s=new ActionEvent((Product)selectedNode.getStoredObject(),0,"String_Node_Str");
      productSelectedListener.actionPerformed(s);
      lastSelectedNode=selectedNode;
    }
  }
}
Program: 98462
Project: 98462
Buggy source:
public Product(String name,int quantity,Class<?> companionFormClass,int id){
  this.name=name;
  this.quantity=quantity;
  this.companionFormClass=companionFormClass;
  this.id=id;
}

Fixed version (ground truth):
public Product(String name,int quantity,Class<?> companionFormClass){
  this.name=name;
  this.quantity=quantity;
  this.companionFormClass=companionFormClass;
}
Program: 98463
Project: 98463
Buggy source:
/** 
 * Adds a single product to the list. This will only get called when a brand new product is created via the NEW PRODUCT button on the gui. Thus, only one is created at a time. It marks it with the flag Status.NEW to indicate that it doesn't exist in the database. It makes it into a list that the productAddedListener can pass on. Normally there are multiple products added at a time (say, from the database) so the listener prefers to handle lists.
 * @param p the product to add
 */
public void add(Product p){
  ArrayList<Product> l=new ArrayList<Product>();
  l.add(p);
  list.put(p,Status.NEW);
  if (productsAddedListener != null) {
    productsAddedListener.actionPerformed(new ActionEvent(l,0,null));
  }
}

Fixed version (ground truth):
/** 
 * Adds a single product to the list. This will only get called when a brand new product is created via the NEW PRODUCT button on the gui. Thus, only one is created at a time. It marks it with the flag Status.NEW to indicate that it doesn't exist in the database. It makes it into a list that the productAddedListener (which talks to the view) can pass on. Normally there are multiple products added at a time (say, from the database) so the listener prefers to handle lists.
 * @param p the product to add
 */
public void add(Product p){
  ArrayList<Product> l=new ArrayList<Product>();
  l.add(p);
  list.put(p,Status.NEW);
  if (productsAddedListener != null) {
    productsAddedListener.actionPerformed(new ActionEvent(l,0,null));
  }
}
Program: 98464
Project: 98464
Buggy source:
/** 
 * This method takes a pointer to a product and updates it so it's state matches that of the updatedProduct. A productUpdatedListen is fired to indicate the product that has been updated. It cannot simply replace the product as our whole framework relies on the  assumption that there is a central model and everything else is just a pointer to that. 
 * @param product the product to be updated.
 * @param updatedProduct the target product.
 */
public void update(Product product,Product updatedProduct){
  Field[] fields=product.getClass().getFields();
  for (  Field f : fields) {
    try {
      f.set(product,f.get(updatedProduct));
    }
 catch (    SecurityException e) {
      e.printStackTrace();
    }
catch (    IllegalArgumentException e) {
      e.printStackTrace();
    }
catch (    IllegalAccessException e) {
      e.printStackTrace();
    }
  }
  if (list.get(product) == Status.FRESH) {
  }
  if (productUpdatedListener != null) {
    productUpdatedListener.actionPerformed(new ActionEvent(product,0,null));
  }
  System.out.println("String_Node_Str" + product);
}

Fixed version (ground truth):
/** 
 * This method takes a pointer to a product and updates it so it's state matches that of the updatedProduct. A productUpdatedListen is fired to indicate the product that has been updated. It cannot simply replace the product as our whole framework relies on the  assumption that there is a central model and everything else is just a pointer to that. 
 * @param product the product to be updated.
 * @param updatedProduct the target product.
 */
public void update(Product product,Product updatedProduct){
  Field[] fields=product.getClass().getFields();
  for (  Field f : fields) {
    try {
      f.set(product,f.get(updatedProduct));
    }
 catch (    SecurityException e) {
      e.printStackTrace();
    }
catch (    IllegalArgumentException e) {
      e.printStackTrace();
    }
catch (    IllegalAccessException e) {
      e.printStackTrace();
    }
  }
  if (list.get(product) == Status.FRESH) {
    list.put(product,Status.UPDATED);
  }
  if (productUpdatedListener != null) {
    productUpdatedListener.actionPerformed(new ActionEvent(product,0,null));
  }
}
Program: 98465
Project: 98465
Buggy source:
/** 
 * Identify that a class's products have been loaded from the persistence layer.
 * @param s
 */
public void addToClassesLoaded(String s){
  classesLoaded.add(s);
}

Fixed version (ground truth):
/** 
 * Identify that a class's products have been loaded from the persistence layer.
 * @param s
 */
public void addToClassesLoaded(String s){
  classesLoaded.add(s);
  System.out.println(s);
}
Program: 98466
Project: 98466
Buggy source:
/** 
 * Get the fields in order so the highest parents fields a are first in the list and so on till the current class, if a subclass overrides a parents field then the parents field is overriden
 * @param c
 * @param upperClass
 * @return
 */
private LinkedHashSet<Field> getFieldsInOrder(Class c,Class upperClass){
  LinkedHashSet<Field> parentFields=new LinkedHashSet<Field>();
  LinkedHashSet<Field> newFields=new LinkedHashSet<Field>();
  if (c.equals(upperClass)) {
    parentFields.addAll(Arrays.asList(c.getFields()));
  }
 else {
    parentFields.addAll(getFieldsInOrder(c.getSuperclass(),upperClass));
    List<Field> currentClassFields=new ArrayList<Field>();
    for (    Field f : c.getFields()) {
      System.out.println(f.getDeclaringClass());
      if (f.getDeclaringClass().equals(c)) {
        currentClassFields.add(f);
      }
    }
    for (    Field f : currentClassFields) {
      for (Iterator<Field> it=parentFields.iterator(); it.hasNext(); ) {
        if (f.getName().equals(it.next().getName())) {
          it.remove();
        }
      }
    }
    parentFields.addAll(currentClassFields);
  }
  return parentFields;
}

Fixed version (ground truth):
/** 
 * Get the fields in order so the highest parents fields a are first in the list and so on till the current class, if a subclass overrides a parents field then the parents field is overriden
 * @param c
 * @param upperClass
 * @return
 */
private LinkedHashSet<Field> getFieldsInOrder(Class c,Class upperClass){
  LinkedHashSet<Field> fields=new LinkedHashSet<Field>();
  if (c.equals(upperClass)) {
    fields.addAll(Arrays.asList(c.getFields()));
  }
 else {
    fields.addAll(getFieldsInOrder(c.getSuperclass(),upperClass));
    fields.addAll(Arrays.asList(c.getFields()));
  }
  return fields;
}
Program: 98467
Project: 98467
Buggy source:
private boolean insertIntoTable(String className,Product product){
  try {
    int originalCount=getRecordCount(className);
    Class<?> c=product.getClass();
    Field[] fields=c.getFields();
    fields=sortFields(fields);
    String sql="String_Node_Str" + className + "String_Node_Str";
    for (int i=0; i < fields.length; i++) {
      sql+=fields[i].getName();
      if (i < fields.length - 1) {
        sql+="String_Node_Str";
      }
    }
    sql+="String_Node_Str";
    for (int i=0; i < fields.length; i++) {
      sql+="String_Node_Str";
      if (i < fields.length - 1) {
        sql+="String_Node_Str";
      }
    }
    sql+="String_Node_Str";
    PreparedStatement preparedStatement=conn.prepareStatement(sql);
    preparedStatement.setInt(1,1);
    for (int i=0; i < fields.length; i++) {
      String data=fields[i].get(product).toString();
      setPreparedStatementValues(preparedStatement,fields[i],i + 1,product);
    }
    preparedStatement.addBatch();
    preparedStatement.executeBatch();
    if (getRecordCount(className) == originalCount + 1) {
      return true;
    }
 else {
      return false;
    }
  }
 catch (  Exception e) {
    System.err.println("String_Node_Str");
    e.printStackTrace();
    return false;
  }
}

Fixed version (ground truth):
private boolean insertIntoTable(String className,Product product){
  try {
    int originalCount=getRecordCount(className);
    Class<?> c=product.getClass();
    Field[] fields=c.getFields();
    fields=sortFields(fields);
    String sql="String_Node_Str" + className + "String_Node_Str";
    for (int i=0; i < fields.length; i++) {
      sql+=fields[i].getName();
      if (i < fields.length - 1) {
        sql+="String_Node_Str";
      }
    }
    sql+="String_Node_Str";
    for (int i=0; i < fields.length; i++) {
      sql+="String_Node_Str";
      if (i < fields.length - 1) {
        sql+="String_Node_Str";
      }
    }
    sql+="String_Node_Str";
    PreparedStatement preparedStatement=conn.prepareStatement(sql);
    preparedStatement.setInt(1,1);
    for (int i=0; i < fields.length; i++) {
      Object obj=fields[i].get(product);
      String data="String_Node_Str";
      if (obj != null) {
        data=fields[i].get(product).toString();
      }
      setPreparedStatementValues(preparedStatement,fields[i],i + 1,product);
    }
    preparedStatement.addBatch();
    preparedStatement.executeBatch();
    if (getRecordCount(className) == originalCount + 1) {
      return true;
    }
 else {
      return false;
    }
  }
 catch (  Exception e) {
    System.err.println("String_Node_Str");
    e.printStackTrace();
    return false;
  }
}
Program: 98468
Project: 98468
Buggy source:
public static List<Product> load(){
  if (!initialized)   return null;
  List<Product> productList=new ArrayList();
  Jacket purpleJacket=new Jacket();
  purpleJacket.brand="String_Node_Str";
  purpleJacket.colour="String_Node_Str";
  purpleJacket.isWaterproof=false;
  purpleJacket.name="String_Node_Str";
  purpleJacket.size="String_Node_Str";
  purpleJacket.quantity=9;
  productList.add(purpleJacket);
  Drink liftPlus=new Drink();
  liftPlus.name="String_Node_Str";
  liftPlus.capacity="String_Node_Str";
  liftPlus.flavour="String_Node_Str";
  liftPlus.quantity=4;
  liftPlus.name="String_Node_Str";
  productList.add(liftPlus);
  return productList;
}

Fixed version (ground truth):
public static List<Product> load(){
  if (!initialized)   return null;
  List<Product> productList=new ArrayList();
  Jacket purpleJacket=new Jacket();
  purpleJacket.brand="String_Node_Str";
  purpleJacket.colour="String_Node_Str";
  purpleJacket.isWaterproof=false;
  purpleJacket.name="String_Node_Str";
  purpleJacket.size="String_Node_Str";
  purpleJacket.quantity=9;
  productList.add(purpleJacket);
  Drink liftPlus=new Drink();
  liftPlus.name="String_Node_Str";
  liftPlus.capacity="String_Node_Str";
  liftPlus.flavour="String_Node_Str";
  liftPlus.quantity=4;
  productList.add(liftPlus);
  return productList;
}
Program: 98469
Project: 98469
Buggy source:
/** 
 * Returns the class selected by the user, or null if no class was selected (i.e. the user clicked cancel).
 * @return the selected class.
 */
public Class<? extends Product> getSelectedClass(){
  System.out.println("String_Node_Str" + list.getSelectedValue().toString());
  System.out.println("String_Node_Str" + list.getSelectedValue().getClass().getName());
  Object selection=list.getSelectedValue();
  if (selection == null) {
    return null;
  }
  return (Class<? extends Product>)list.getSelectedValue().getClass();
}

Fixed version (ground truth):
/** 
 * Returns the class selected by the user, or null if no class was selected (i.e. the user clicked cancel).
 * @return the selected class.
 */
public Class<? extends Product> getSelectedClass(){
  Object selection=list.getSelectedValue();
  if (selection == null) {
    return null;
  }
  return (Class<? extends Product>)selection;
}
Program: 98470
Project: 98470
Buggy source:
/** 
 * The desirable size is mmaximum screen height with minimal width
 */
protected void calculateOptimalScreenSize(){
  DisplayMetrics metrics=new DisplayMetrics();
  activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
  int screenHeight=metrics.heightPixels;
  int screenWidth=metrics.widthPixels;
  List<Size> supportedSizes=camera.getParameters().getSupportedPreviewSizes();
  Iterator<Size> it=supportedSizes.iterator();
  while (it.hasNext()) {
    Size size=it.next();
    Log.v(AndroidRestClientActivity.APP_NAME,"String_Node_Str" + size.width + "String_Node_Str"+ size.height);
    if (size.height == screenHeight && size.width < screenWidth) {
      Log.i(AndroidRestClientActivity.APP_NAME,"String_Node_Str" + size.width + "String_Node_Str"+ size.height);
      height=size.height;
      width=size.width;
    }
  }
}

Fixed version (ground truth):
/** 
 * The desirable size is mmaximum screen height with minimal width
 */
protected void calculateOptimalScreenSize(){
  DisplayMetrics metrics=new DisplayMetrics();
  activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
  int screenHeight=metrics.heightPixels;
  int screenWidth=metrics.widthPixels;
  List<Size> supportedSizes=camera.getParameters().getSupportedPreviewSizes();
  Iterator<Size> it=supportedSizes.iterator();
  while (it.hasNext()) {
    Size size=it.next();
    Log.v(AndroidRestClientActivity.APP_NAME,"String_Node_Str" + size.width + "String_Node_Str"+ size.height);
    if (screenHeight == size.height && screenWidth > size.width) {
      Log.i(AndroidRestClientActivity.APP_NAME,"String_Node_Str" + size.width + "String_Node_Str"+ size.height);
      height=size.height;
      width=size.width;
    }
 else     if (screenHeight < size.height && screenWidth > size.width && height == 0 && width == 0) {
      height=size.height;
      width=size.width;
    }
  }
}
Program: 98471
Project: 98471
Buggy source:
/** 
 * The desirable size is mmaximum screen height with minimal width
 */
protected void calculateOptimalScreenSize(){
  DisplayMetrics metrics=new DisplayMetrics();
  activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
  int screenHeight=metrics.heightPixels;
  int screenWidth=metrics.widthPixels;
  List<Size> supportedSizes=camera.getParameters().getSupportedPreviewSizes();
  Iterator<Size> it=supportedSizes.iterator();
  while (it.hasNext()) {
    Size size=it.next();
    Log.v(AndroidRestClientActivity.APP_NAME,"String_Node_Str" + size.width + "String_Node_Str"+ size.height);
    if (screenHeight == size.height && screenWidth > size.width) {
      Log.i(AndroidRestClientActivity.APP_NAME,"String_Node_Str" + size.width + "String_Node_Str"+ size.height);
      height=size.height;
      width=size.width;
    }
 else     if (screenHeight < size.height && screenWidth > size.width && height == 0 && width == 0) {
      height=size.height;
      width=size.width;
    }
  }
}

Fixed version (ground truth):
/** 
 * The desirable size is mmaximum screen height with minimal width
 */
protected void calculateOptimalScreenSize(){
  DisplayMetrics metrics=new DisplayMetrics();
  activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
  int screenHeight=metrics.heightPixels;
  int screenWidth=metrics.widthPixels;
  List<Size> supportedSizes=camera.getParameters().getSupportedPreviewSizes();
  Iterator<Size> it=supportedSizes.iterator();
  while (it.hasNext()) {
    Size size=it.next();
    Log.v(AndroidRestClientActivity.APP_NAME,"String_Node_Str" + size.width + "String_Node_Str"+ size.height);
    if (screenHeight == size.height && screenWidth > size.width) {
      Log.i(AndroidRestClientActivity.APP_NAME,"String_Node_Str" + size.width + "String_Node_Str"+ size.height);
      height=size.height;
      width=size.width;
    }
 else     if (screenHeight > size.height && screenWidth > size.width && height == 0 && width == 0) {
      height=size.height;
      width=size.width;
    }
  }
}
Program: 98472
Project: 98472
Buggy source:
/** 
 * Boris algorithm for implementing the electric and magnetic field. The damping is implemented with an linear error O(dt). Warning: the velocity is stored half a time step before of the position.
 * @param p before the update: x(t), v(t-dt/2);after the update: x(t+dt), v(t+dt/2)
 */
public void step(Particle2D p,Force f,double step){
  p.ax=f.getForceX(p) / p.mass;
  p.ay=f.getForceY(p) / p.mass;
  double vxminus=p.vx + f.getPositionComponentofForceX(p) * step / (2.0 * p.mass);
  double vxplus;
  double vxprime;
  double vyminus=p.vy + f.getPositionComponentofForceY(p) * step / (2.0 * p.mass);
  double vyplus;
  double vyprime;
  double t_z=p.charge * f.getBz(p) * step / (2.0 * p.mass);
  double s_z=2 * t_z / (1 + t_z * t_z);
  vxprime=vxminus + vyminus * t_z;
  vyprime=vyminus - vxminus * t_z;
  vxplus=vxminus + vyprime * s_z;
  vyplus=vyminus - vxprime * s_z;
  p.vx=vxplus + f.getPositionComponentofForceX(p) * step / (2.0 * p.mass) + f.getTangentVelocityComponentOfForceX(p) / p.mass;
  p.vy=vyplus + f.getPositionComponentofForceY(p) * step / (2.0 * p.mass) + f.getTangentVelocityComponentOfForceY(p) / p.mass;
  p.x+=p.vx * step;
  p.y+=p.vy * step;
}

Fixed version (ground truth):
/** 
 * Boris algorithm for implementing the electric and magnetic field. The damping is implemented with an linear error O(dt). Warning: the velocity is stored half a time step before of the position.
 * @param p before the update: x(t), v(t-dt/2);after the update: x(t+dt), v(t+dt/2)
 */
public void step(Particle2D p,Force f,double step){
  p.ax=f.getForceX(p) / p.mass;
  p.ay=f.getForceY(p) / p.mass;
  double vxminus=p.vx + f.getPositionComponentofForceX(p) * step / (2.0 * p.mass);
  double vxplus;
  double vxprime;
  double vyminus=p.vy + f.getPositionComponentofForceY(p) * step / (2.0 * p.mass);
  double vyplus;
  double vyprime;
  double t_z=p.charge * f.getBz(p) * step / (2.0 * p.mass);
  double s_z=2 * t_z / (1 + t_z * t_z);
  vxprime=vxminus + vyminus * t_z;
  vyprime=vyminus - vxminus * t_z;
  vxplus=vxminus + vyprime * s_z;
  vyplus=vyminus - vxprime * s_z;
  p.vx=vxplus + f.getPositionComponentofForceX(p) * step / (2.0 * p.mass) + f.getTangentVelocityComponentOfForceX(p) * step / p.mass;
  p.vy=vyplus + f.getPositionComponentofForceY(p) * step / (2.0 * p.mass) + f.getTangentVelocityComponentOfForceY(p) * step / p.mass;
  p.x+=p.vx * step;
  p.y+=p.vy * step;
}
Program: 98473
Project: 98473
Buggy source:
public void check(ArrayList<Particle2D> parlist,Force f,Solver s,double step){
  for (int i=0; i < (parlist.size() - 1); i++) {
    Particle2D p1=(Particle2D)parlist.get(i);
    double x1=Math.sqrt(p1.x * p1.x + p1.y * p1.y);
    for (int k=(i + 1); k < parlist.size(); k++) {
      Particle2D p2=(Particle2D)parlist.get(k);
      double x2=Math.sqrt(p2.x * p2.x + p2.y * p2.y);
      if ((Math.abs(x1 - x2)) <= (p1.radius + p2.radius))       s.complete(p1,f,step);
      s.complete(p2,f,step);
      doCollision(p1,p2);
      s.prepare(p1,f,step);
      s.prepare(p2,f,step);
    }
  }
}

Fixed version (ground truth):
public void check(ArrayList<Particle2D> parlist,Force f,Solver s,double step){
  for (int i=0; i < (parlist.size() - 1); i++) {
    Particle2D p1=(Particle2D)parlist.get(i);
    for (int k=(i + 1); k < parlist.size(); k++) {
      Particle2D p2=(Particle2D)parlist.get(k);
      double distance=Math.sqrt((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y));
      if (distance <= (p1.radius + p2.radius))       s.complete(p1,f,step);
      s.complete(p2,f,step);
      doCollision(p1,p2);
      s.prepare(p1,f,step);
      s.prepare(p2,f,step);
    }
  }
}
Program: 98474
Project: 98474
Buggy source:
/** 
 * Reflect a particle off the boundaries.
 */
public void check(Particle2D particle){
  if (particle.x < xmin) {
    particle.x+=xmax - xmin;
  }
 else   if (particle.x > xmax) {
    particle.x-=xmax - xmin;
  }
  if (particle.y < ymin) {
    particle.y=ymax - ymin;
  }
 else   if (particle.y > ymax) {
    particle.y-=ymax - ymin;
  }
}

Fixed version (ground truth):
/** 
 * Reflect a particle off the boundaries.
 */
public void check(Particle2D particle){
  if (particle.x < xmin) {
    particle.x+=xmax - xmin;
  }
 else   if (particle.x > xmax) {
    particle.x-=xmax - xmin;
  }
  if (particle.y < ymin) {
    particle.y+=ymax - ymin;
  }
 else   if (particle.y > ymax) {
    particle.y-=ymax - ymin;
  }
}
Program: 98475
Project: 98475
Buggy source:
/** 
 * Display the particles 
 */
public void paintComponent(Graphics graph1){
  Graphics2D graph=(Graphics2D)graph1;
  setBackground(Color.gray);
  graph.translate(0.0,this.getHeight());
  graph.scale(1.0,-1.0);
  if (!paint_trace) {
    super.paintComponent(graph1);
  }
  if (reset_trace) {
    super.paintComponent(graph1);
    reset_trace=false;
  }
  for (int i=0; i < NUM_PARTICLES; i++) {
    Particle2D par=(Particle2D)parlist.get(i);
    if (par.charge > 0) {
      graph.setColor(Color.blue);
    }
 else {
      graph.setColor(Color.red);
    }
    if (paint_trace) {
      int resize_factor=0;
switch ((int)par.radius) {
case 2:
        resize_factor=1;
      break;
case 5:
    resize_factor=2;
  break;
case 10:
resize_factor=3;
break;
case 15:
resize_factor=5;
break;
}
graph.fillOval((int)par.x,(int)par.y,(int)par.radius / resize_factor,(int)par.radius / resize_factor);
}
 else graph.fillOval((int)par.x,(int)par.y,(int)par.radius,(int)par.radius);
}
}

Fixed version (ground truth):
/** 
 * Display the particles 
 */
public void paintComponent(Graphics graph1){
  Graphics2D graph=(Graphics2D)graph1;
  setBackground(Color.gray);
  graph.translate(0.0,this.getHeight());
  graph.scale(1.0,-1.0);
  if (!paint_trace) {
    super.paintComponent(graph1);
  }
  if (reset_trace) {
    super.paintComponent(graph1);
    reset_trace=false;
  }
  for (int i=0; i < NUM_PARTICLES; i++) {
    Particle2D par=(Particle2D)parlist.get(i);
    if (par.charge > 0) {
      graph.setColor(Color.blue);
    }
 else {
      graph.setColor(Color.red);
    }
    if (paint_trace) {
      int resize_factor=0;
switch ((int)par.radius) {
case 2:
        resize_factor=1;
      break;
case 5:
    resize_factor=3;
  break;
case 10:
resize_factor=3;
break;
case 15:
resize_factor=5;
break;
}
graph.fillOval((int)par.x + (int)par.radius / 2,(int)par.y + (int)par.radius / 2,(int)par.radius / resize_factor,(int)par.radius / resize_factor);
}
 else graph.fillOval((int)par.x,(int)par.y,(int)par.radius,(int)par.radius);
}
}
Program: 98476
Project: 98476
Buggy source:
public void checkTrace(){
}

Fixed version (ground truth):
public void checkTrace(){
  paint_trace=!paint_trace;
  startAnimation();
}
Program: 98477
Project: 98477
Buggy source:
/** 
 * Display the particles 
 */
public void paintComponent(Graphics graph1){
  super.paintComponent(graph1);
  Graphics2D graph=(Graphics2D)graph1;
  setBackground(Color.gray);
  graph.translate(0.0,426);
  graph.scale(1.0,-1.0);
  for (int i=0; i < NUM_PARTICLES; i++) {
    Particle2D par=(Particle2D)parlist.get(i);
    if (par.charge > 0) {
      graph.setColor(Color.blue);
    }
 else {
      graph.setColor(Color.red);
    }
    graph.fillOval((int)par.x,(int)par.y,(int)par.radius,(int)par.radius);
  }
}

Fixed version (ground truth):
/** 
 * Display the particles 
 */
public void paintComponent(Graphics graph1){
  Graphics2D graph=(Graphics2D)graph1;
  setBackground(Color.gray);
  graph.translate(0.0,this.getHeight());
  graph.scale(1.0,-1.0);
  if (!paint_trace) {
    super.paintComponent(graph1);
  }
  for (int i=0; i < NUM_PARTICLES; i++) {
    Particle2D par=(Particle2D)parlist.get(i);
    if (par.charge > 0) {
      graph.setColor(Color.blue);
    }
 else {
      graph.setColor(Color.red);
    }
    if (paint_trace)     graph.fillOval((int)par.x,(int)par.y,(int)par.radius / 5,(int)par.radius / 5);
 else     graph.fillOval((int)par.x,(int)par.y,(int)par.radius,(int)par.radius);
  }
}
Program: 98478
Project: 98478
Buggy source:
public void zerarSistema(){
}

Fixed version (ground truth):
public void zerarSistema(){
  usuariosCadastrados.clear();
  caronasCadastradas.clear();
  sessoesExistentes.clear();
}
Program: 98479
Project: 98479
Buggy source:
public String cadastrarCarona(String idSecao,String origem,String destino,String data,String hora,String vagas) throws Exception {
  if (idSecao == null || idSecao.equals("String_Node_Str")) {
    throw new SessaoInvalidaException();
  }
 else   if (!sessoesExistentes.contains(idSecao)) {
    throw new SessaoInexistenteException();
  }
 else   if (origem == null || origem.equals("String_Node_Str")) {
    throw new OrigemInvalidaException();
  }
 else   if (destino == null || destino.equals("String_Node_Str")) {
    throw new DestinoInvalidoException();
  }
 else   if (data == null || data.equals("String_Node_Str") || !dataEhValida(data)) {
    throw new DataInvalidaException();
  }
 else   if (hora == null || hora.equals("String_Node_Str") || !horaEhValida(hora)) {
    throw new HoraInvalidaException();
  }
 else   if (vagas == null || !vagas.matches("String_Node_Str")) {
    throw new VagaInvalidaException();
  }
  String[] conjunto=data.split("String_Node_Str");
  validar.dataValida(conjunto[0],conjunto[1],conjunto[2]);
  String caronaID=geraID();
  caronasCadastradas.add(new Carona(caronaID,origem,destino,data,hora,vagas));
  return caronaID;
}

Fixed version (ground truth):
public String cadastrarCarona(String idSecao,String origem,String destino,String data,String hora,String vagas) throws Exception {
  if (idSecao == null || idSecao.equals("String_Node_Str")) {
    throw new SessaoInvalidaException();
  }
 else   if (!sessoesExistentes.contains(idSecao)) {
    throw new SessaoInexistenteException();
  }
 else   if (origem == null || origem.equals("String_Node_Str")) {
    throw new OrigemInvalidaException();
  }
 else   if (destino == null || destino.equals("String_Node_Str")) {
    throw new DestinoInvalidoException();
  }
 else   if (data == null || data.equals("String_Node_Str") || !validar.estruturaDeData(data)) {
    throw new DataInvalidaException();
  }
 else   if (hora == null || hora.equals("String_Node_Str") || !validar.estruturaDeHora(hora)) {
    throw new HoraInvalidaException();
  }
 else   if (vagas == null || !validar.estruturaDeVagas(vagas)) {
    throw new VagaInvalidaException();
  }
  validar.dataValida(data.split("String_Node_Str"));
  String caronaID=geraID();
  caronasCadastradas.add(new Carona(caronaID,origem,destino,data,hora,vagas));
  return caronaID;
}
Program: 98480
Project: 98480
Buggy source:
public void encerrarSistema(){
}

Fixed version (ground truth):
public void encerrarSistema(String login){
}
Program: 98481
Project: 98481
Buggy source:
public Usuario(String login,String nome,String endereco){
}

Fixed version (ground truth):
public Usuario(String login,String nome,String endereco) throws Exception {
  validador3(login,nome,endereco);
  this.login=login;
  this.nome=nome;
  this.endereco=endereco;
}
Program: 98482
Project: 98482
Buggy source:
public void dataValida(String day,String month,String year) throws Exception {
  Calendar calendarioAtual=new GregorianCalendar();
  this.calendario.set(Calendar.MONTH,Integer.parseInt(month) - 1);
  this.calendario.set(Calendar.YEAR,Integer.parseInt(year));
  if (Integer.parseInt(year) < calendarioAtual.get(Calendar.YEAR)) {
    throw new DataInvalidaException();
  }
  if (Integer.parseInt(year) < this.calendario.get(Calendar.YEAR)) {
    throw new DataInvalidaException();
  }
 else   if (Integer.parseInt(day) > this.calendario.getActualMaximum(Calendar.DAY_OF_MONTH)) {
    throw new DataInvalidaException();
  }
}

Fixed version (ground truth):
public void dataValida(String[] data) throws Exception {
  Calendar calendarioAtual=new GregorianCalendar();
  Integer day=Integer.parseInt(data[0]);
  Integer month=Integer.parseInt(data[1]);
  Integer year=Integer.parseInt(data[2]);
  this.calendario.set(Calendar.MONTH,month - 1);
  this.calendario.set(Calendar.YEAR,year);
  if (year < calendarioAtual.get(Calendar.YEAR)) {
    throw new DataInvalidaException();
  }
  if (day > this.calendario.getActualMaximum(Calendar.DAY_OF_MONTH)) {
    throw new DataInvalidaException();
  }
}
Program: 98483
Project: 98483
Buggy source:
public static void main(String[] args) throws Exception {
  List<String> files=new ArrayList<String>();
  files.add("String_Node_Str");
  MeLeva projeto=new MeLeva();
  EasyAcceptFacade eaFacade=new EasyAcceptFacade(projeto,files);
  eaFacade.executeTests();
  System.out.println(eaFacade.getCompleteResults());
}

Fixed version (ground truth):
public static void main(String[] args) throws Exception {
  List<String> files=new ArrayList<String>();
  files.add("String_Node_Str");
  files.add("String_Node_Str");
  files.add("String_Node_Str");
  files.add("String_Node_Str");
  files.add("String_Node_Str");
  MeLeva projeto=new MeLeva();
  EasyAcceptFacade eaFacade=new EasyAcceptFacade(projeto,files);
  eaFacade.executeTests();
  System.out.println(eaFacade.getCompleteResults());
}
Program: 98484
Project: 98484
Buggy source:
public ViewCourse(){
  id=Long.valueOf(FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("String_Node_Str"));
}

Fixed version (ground truth):
public ViewCourse(){
  String getId=FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("String_Node_Str");
  if (getId == null) {
    id=null;
  }
 else {
    id=Long.valueOf(getId);
    reRenderComments=false;
    latestUserComment=0;
  }
}
Program: 98485
Project: 98485
Buggy source:
public void preRenderView(){
  Config.getInstance().getServiceFactory().getLogService().info("String_Node_Str");
  if (id != null) {
    try {
      if (course == null) {
        course=CourseVoVwBuilder.getInstance().getCourseVoVwFull(id);
        if (course == null) {
          ((ConfigurableNavigationHandler)FacesContext.getCurrentInstance().getApplication().getNavigationHandler()).performNavigation("String_Node_Str");
        }
      }
      if (comments == null) {
        Config.getInstance().getServiceFactory().getLogService().info("String_Node_Str");
        comments=CommentVoVwBuilder.getInstance().getCommentsByCourseId(id);
        Collections.sort(comments,new Comparator<CommentVoVwMedium>(){
          @Override public int compare(          CommentVoVwMedium o1,          CommentVoVwMedium o2){
            int o1Rating=o1.getRating().getPositive() - o1.getRating().getNegative();
            int o2Rating=o2.getRating().getPositive() - o2.getRating().getNegative();
            return (o1Rating > o2Rating ? -1 : (o1Rating == o2Rating ? 0 : 1));
          }
        }
);
      }
    }
 catch (    Exception ex) {
      Config.getInstance().getServiceFactory().getLogService().error(ex.getMessage(),ex);
      ((ConfigurableNavigationHandler)FacesContext.getCurrentInstance().getApplication().getNavigationHandler()).performNavigation("String_Node_Str");
    }
  }
}

Fixed version (ground truth):
public void preRenderView(){
  Config.getInstance().getServiceFactory().getLogService().info("String_Node_Str");
  if (id != null) {
    try {
      course=CourseVoVwBuilder.getInstance().getCourseVoVwFull(id);
      if (course == null) {
        redirectNotFound();
      }
      if (comments == null || isReRenderComments()) {
        comments=CommentVoVwBuilder.getInstance().getCommentsByCourseId(id);
        Collections.sort(comments,new Comparator<CommentVoVwMedium>(){
          @Override public int compare(          CommentVoVwMedium o1,          CommentVoVwMedium o2){
            int o1Rating=o1.getRating().getPositive() - o1.getRating().getNegative();
            int o2Rating=o2.getRating().getPositive() - o2.getRating().getNegative();
            return (o1Rating > o2Rating ? -1 : (o1Rating == o2Rating ? 0 : 1));
          }
        }
);
        setReRenderComments(false);
      }
    }
 catch (    Exception ex) {
      Config.getInstance().getServiceFactory().getLogService().error(ex.getMessage(),ex);
      redirectNotFound();
    }
  }
 else {
    redirectNotFound();
  }
}
Program: 98486
Project: 98486
Buggy source:
private <T extends CommentVoVwMedium>List<T> getListOfCommentVoVwMedium(List<CommentVo> source,List<T> destination){
  HashMap<Long,UserVoVwSmall> users=new HashMap<Long,UserVoVwSmall>();
  UserVoVwSmall anonymousUser=UserVoVwBuilder.ANONYMOUS_USER;
  CommentsFacade commentsFacade=facadeFactory.getCommentsFacade();
  UserVoVwSmall commentUser;
  CommentVo commentVo;
  CommentVoVwMedium commentVoVwMedium;
  int listSize=source.size();
  for (int i=0; i < listSize; i++) {
    commentVo=source.get(i);
    if (commentVo.isAnonymous()) {
      commentUser=anonymousUser;
    }
 else {
      long userId=commentVo.getUserId();
      if (!users.containsKey(userId)) {
        users.put(userId,UserVoVwBuilder.getInstance().getUser(userId));
      }
      commentUser=users.get(userId);
    }
    commentVoVwMedium=destination.get(i);
    SimpleDateFormat dateFormatGmt=new SimpleDateFormat("String_Node_Str");
    dateFormatGmt.setTimeZone(TimeZone.getTimeZone("String_Node_Str"));
    try {
      commentVo.setDate(dateFormatGmt.parse(dateFormatGmt.format(commentVo.getDate())));
    }
 catch (    ParseException ex) {
      Config.getInstance().getServiceFactory().getLogService().error("String_Node_Str",ex);
    }
    commentVoVwMedium.setVo(commentVo);
    commentVoVwMedium.setUser(commentUser);
    commentVoVwMedium.setRating(commentsFacade.getCommentRatingSummary(commentVo.getId()));
  }
  return destination;
}

Fixed version (ground truth):
private <T extends CommentVoVwMedium>List<T> getListOfCommentVoVwMedium(List<CommentVo> source,List<T> destination){
  HashMap<Long,UserVoVwSmall> users=new HashMap<Long,UserVoVwSmall>();
  UserVoVwSmall anonymousUser=UserVoVwBuilder.ANONYMOUS_USER;
  CommentsFacade commentsFacade=facadeFactory.getCommentsFacade();
  UserVoVwSmall commentUser;
  CommentVo commentVo;
  CommentVoVwMedium commentVoVwMedium;
  int listSize=source.size();
  for (int i=0; i < listSize; i++) {
    commentVo=source.get(i);
    if (commentVo.isAnonymous()) {
      anonymousUser.setId(commentVo.getUserId());
      commentUser=anonymousUser;
    }
 else {
      long userId=commentVo.getUserId();
      if (!users.containsKey(userId)) {
        users.put(userId,UserVoVwBuilder.getInstance().getUser(userId));
      }
      commentUser=users.get(userId);
    }
    commentVoVwMedium=destination.get(i);
    SimpleDateFormat dateFormatGmt=new SimpleDateFormat("String_Node_Str");
    dateFormatGmt.setTimeZone(TimeZone.getTimeZone("String_Node_Str"));
    try {
      commentVo.setDate(dateFormatGmt.parse(dateFormatGmt.format(commentVo.getDate())));
    }
 catch (    ParseException ex) {
      Config.getInstance().getServiceFactory().getLogService().error("String_Node_Str",ex);
    }
    commentVoVwMedium.setVo(commentVo);
    commentVoVwMedium.setUser(commentUser);
    commentVoVwMedium.setRating(commentsFacade.getCommentRatingSummary(commentVo.getId()));
  }
  return destination;
}
Program: 98487
Project: 98487
Buggy source:
public void deleteComment(long commentId) throws DataBaseException {
  EntityManager entityManager=null;
  EntityTransaction transaction=null;
  try {
    entityManager=getEntityManagerFactory().createEntityManager();
    transaction=entityManager.getTransaction();
    transaction.begin();
    getServiceFactory().getCommentsService().delete(entityManager,commentId);
    transaction.commit();
  }
 catch (  Exception exception) {
    getServiceFactory().getLogService().error(exception.getMessage(),exception);
    FacadesHelper.checkExceptionAndRollback(entityManager,transaction,exception,DataBaseException.class);
    FacadesHelper.rollbackTransaction(entityManager,transaction,exception);
  }
 finally {
    FacadesHelper.closeEntityManager(entityManager);
  }
}

Fixed version (ground truth):
public void deleteComment(long commentId) throws DataBaseException {
  EntityManager entityManager=null;
  EntityTransaction transaction=null;
  try {
    entityManager=getEntityManagerFactory().createEntityManager();
    transaction=entityManager.getTransaction();
    transaction.begin();
    getServiceFactory().getCommentsService().delete(entityManager,commentId);
    transaction.commit();
  }
 catch (  Exception exception) {
    getServiceFactory().getLogService().error(exception.getMessage(),exception);
    FacadesHelper.checkExceptionAndRollback(entityManager,transaction,exception,DataBaseException.class);
    FacadesHelper.rollbackTransactionAndCloseEntityManager(entityManager,transaction,exception);
  }
 finally {
    FacadesHelper.closeEntityManager(entityManager);
  }
}
Program: 98488
Project: 98488
Buggy source:
public BinaryRatingVo getCommentRatingByUserId(long commentId,long userId){
  EntityManager entityManager=null;
  BinaryRatingVo rating=null;
  try {
    entityManager=getEntityManagerFactory().createEntityManager();
    rating=getServiceFactory().getCommentRatingService().getByEvaluatedObjectAndUserId(entityManager,commentId,userId);
  }
 catch (  Exception exception) {
    getServiceFactory().getLogService().error(exception.getMessage(),exception);
    throw new RuntimeException(exception);
  }
 finally {
    FacadesHelper.closeEntityManager(entityManager);
  }
  return rating;
}

Fixed version (ground truth):
public BinaryRatingVo getCommentRatingByUserId(long commentId,long userId){
  EntityManager entityManager=null;
  BinaryRatingVo rating=null;
  try {
    entityManager=getEntityManagerFactory().createEntityManager();
    rating=getServiceFactory().getCommentRatingService().getByEvaluatedObjectAndUserId(entityManager,commentId,userId);
  }
 catch (  Exception exception) {
    getServiceFactory().getLogService().error(exception.getMessage(),exception);
    FacadesHelper.closeEntityManager(entityManager);
    throw new RuntimeException(exception);
  }
 finally {
    FacadesHelper.closeEntityManager(entityManager);
  }
  return rating;
}