nus-yam/ex-repair huggingface dataset:
Program: 10609
Project: 10609
Buggy source:
public void updateFiltersFromUIDL(UIDL uidl,ApplicationConnection client){
  if (uidl == null) {
    return;
  }
  getWidget().filters.filtersVisible=uidl.hasAttribute("String_Node_Str") ? uidl.getBooleanAttribute("String_Node_Str") : false;
  getWidget().filters.setVisible(getWidget().filters.filtersVisible);
  getWidget().setContainerHeight();
  Widget toFocus=null;
  if (!getWidget().filters.filtersVisible) {
    getWidget().filters.container.clear();
    getWidget().filters.filters.clear();
  }
 else {
    getWidget().filters.filters.clear();
    for (final Iterator<Object> it=uidl.getChildIterator(); it.hasNext(); ) {
      final UIDL cc=(UIDL)it.next();
      if (cc.getTag().startsWith("String_Node_Str")) {
        String cid=cc.getStringAttribute("String_Node_Str");
        UIDL uidld=cc.getChildUIDL(0);
        ComponentConnector connector=client.getPaintable(uidld);
        getWidget().filters.filters.put(cid,connector.getWidget());
      }
    }
    getWidget().filters.reRenderFilterComponents();
  }
}

Fixed version (ground truth):
public void updateFiltersFromUIDL(UIDL uidl,ApplicationConnection client){
  if (uidl == null) {
    return;
  }
  getWidget().filters.filtersVisible=uidl.hasAttribute("String_Node_Str") ? uidl.getBooleanAttribute("String_Node_Str") : false;
  getWidget().filters.setVisible(getWidget().filters.filtersVisible);
  getWidget().setContainerHeight();
  boolean forceRender=uidl.getBooleanAttribute("String_Node_Str");
  if (!getWidget().filters.filtersVisible) {
    getWidget().filters.container.clear();
    getWidget().filters.filters.clear();
  }
 else {
    Map<String,Widget> newWidgets=new HashMap<String,Widget>();
    boolean allCached=true;
    for (final Iterator<Object> it=uidl.getChildIterator(); it.hasNext(); ) {
      final UIDL cc=(UIDL)it.next();
      if (cc.getTag().startsWith("String_Node_Str")) {
        String cid=cc.getStringAttribute("String_Node_Str");
        UIDL uidld=cc.getChildUIDL(0);
        if (uidld == null) {
          newWidgets.put(cid,null);
        }
 else {
          ComponentConnector connector=client.getPaintable(uidld);
          newWidgets.put(cid,connector.getWidget());
          if (!uidld.hasAttribute("String_Node_Str") || !uidld.getBooleanAttribute("String_Node_Str")) {
            allCached=false;
          }
        }
      }
    }
    if (forceRender || !allCached || getWidget().filters.filters.isEmpty()) {
      getWidget().filters.filters.clear();
      for (      String cid : newWidgets.keySet()) {
        getWidget().filters.filters.put(cid,newWidgets.get(cid));
      }
      getWidget().filters.reRenderFilterComponents();
    }
 else {
      getWidget().filters.resetFilterWidths();
    }
  }
}
Program: 10610
Project: 10610
Buggy source:
@Override public List<?> getItemIds(int startIndex,int numberOfItems){
  return container.getItemIds(startIndex,numberOfItems);
}

Fixed version (ground truth):
@Override public List<?> getItemIds(int startIndex,int numberOfItems){
  return container.getItemIds(this.startIndex + startIndex,numberOfItems);
}
Program: 10611
Project: 10611
Buggy source:
@Override public void paintContent(PaintTarget target) throws PaintException {
  super.paintContent(target);
  target.startTag("String_Node_Str");
  target.addAttribute("String_Node_Str",filtersVisible);
  target.addAttribute("String_Node_Str",reRenderFilterFields);
  reRenderFilterFields=false;
  if (filtersVisible) {
    for (    Object key : getColumnIdToFilterMap().keySet()) {
      if (collapsedColumnIds.contains(key) || !getContainerDataSource().getContainerPropertyIds().contains(key) || !visibleColumns.contains(key)) {
        System.err.println("String_Node_Str" + key);
        continue;
      }
      System.err.println("String_Node_Str" + key);
      target.startTag("String_Node_Str" + columnIdMap.key(key));
      target.addAttribute("String_Node_Str",columnIdMap.key(key));
      Component c=getColumnIdToFilterMap().get(key);
      LegacyPaint.paint(c,target);
      target.endTag("String_Node_Str" + columnIdMap.key(key));
    }
  }
  target.endTag("String_Node_Str");
}

Fixed version (ground truth):
@Override public void paintContent(PaintTarget target) throws PaintException {
  super.paintContent(target);
  target.startTag("String_Node_Str");
  target.addAttribute("String_Node_Str",filtersVisible);
  target.addAttribute("String_Node_Str",reRenderFilterFields);
  reRenderFilterFields=false;
  if (filtersVisible) {
    for (    Object key : getColumnIdToFilterMap().keySet()) {
      if (columnIdToFilterMap.get(key) != null && columnIdToFilterMap.get(key).getParent() == null) {
        continue;
      }
      target.startTag("String_Node_Str" + columnIdMap.key(key));
      target.addAttribute("String_Node_Str",columnIdMap.key(key));
      Component c=getColumnIdToFilterMap().get(key);
      LegacyPaint.paint(c,target);
      target.endTag("String_Node_Str" + columnIdMap.key(key));
    }
  }
  target.endTag("String_Node_Str");
}
Program: 10612
Project: 10612
Buggy source:
@Override public void setVisibleColumns(Object[] visibleColumns){
  reRenderFilterFields=true;
  super.setVisibleColumns(visibleColumns);
}

Fixed version (ground truth):
@Override public void setVisibleColumns(Object[] visibleColumns){
  reRenderFilterFields=true;
  if (visibleColumns != null && columnIdToFilterMap != null) {
    for (    Object key : columnIdToFilterMap.keySet()) {
      columnIdToFilterMap.get(key).setParent(null);
    }
    for (    Object key : visibleColumns) {
      Component filter=columnIdToFilterMap.get(key);
      if (filter != null) {
        filter.setParent(this);
      }
    }
  }
  super.setVisibleColumns(visibleColumns);
}
Program: 10613
Project: 10613
Buggy source:
/** 
 * Toggles the visibility of the filter field defined for the give column ID.
 * @param columnId Column/Property ID of the filter to toggle
 * @param visible true to set visible, false to set hidden
 */
public void setFilterFieldVisible(Object columnId,boolean visible){
  Component component=columnIdToFilterMap.get(columnId);
  if (component != null) {
    component.setVisible(visible);
    reRenderFilterFields=true;
  }
}

Fixed version (ground truth):
/** 
 * Toggles the visibility of the filter field defined for the give column ID.
 * @param columnId Column/Property ID of the filter to toggle
 * @param visible true to set visible, false to set hidden
 */
public void setFilterFieldVisible(Object columnId,boolean visible){
  Component component=columnIdToFilterMap.get(columnId);
  if (component != null) {
    component.setVisible(visible);
    reRenderFilterFields=true;
    markAsDirty();
  }
}
Program: 10614
Project: 10614
Buggy source:
@Override public Iterator<Component> iterator(){
  Set<Component> children=new HashSet<Component>();
  if (visibleComponents != null) {
    children.addAll(visibleComponents);
  }
  if (initDone) {
    for (    Object key : columnIdToFilterMap.keySet()) {
      if (collapsedColumnIds.contains(key) || !getContainerDataSource().getContainerPropertyIds().contains(key) || !visibleColumns.contains(key)) {
        continue;
      }
      children.add(columnIdToFilterMap.get(key));
    }
  }
  return children.iterator();
}

Fixed version (ground truth):
@Override public Iterator<Component> iterator(){
  Set<Component> children=new HashSet<Component>();
  if (visibleComponents != null) {
    children.addAll(visibleComponents);
  }
  if (initDone) {
    for (    Object key : columnIdToFilterMap.keySet()) {
      Component filter=columnIdToFilterMap.get(key);
      if (equals(filter.getParent())) {
        children.add(filter);
      }
    }
  }
  return children.iterator();
}
Program: 10615
Project: 10615
Buggy source:
@Override public void setColumnCollapsed(Object propertyId,boolean collapsed) throws IllegalStateException {
  super.setColumnCollapsed(propertyId,collapsed);
  Component c=getColumnIdToFilterMap().get(propertyId);
  if (collapsed) {
    collapsedColumnIds.add(propertyId);
    if (c != null) {
      if (c instanceof TextField) {
        ((TextField)c).setValue("String_Node_Str");
      }
 else       if (c instanceof AbstractField<?>) {
        ((AbstractField<?>)c).setValue(null);
      }
    }
  }
 else {
    collapsedColumnIds.remove(propertyId);
  }
  reRenderFilterFields=true;
  markAsDirty();
}

Fixed version (ground truth):
@Override public void setColumnCollapsed(Object propertyId,boolean collapsed) throws IllegalStateException {
  super.setColumnCollapsed(propertyId,collapsed);
  Component c=getColumnIdToFilterMap().get(propertyId);
  if (collapsed) {
    collapsedColumnIds.add(propertyId);
    if (c != null) {
      c.setParent(null);
      if (c instanceof TextField) {
        ((TextField)c).setValue("String_Node_Str");
      }
 else       if (c instanceof AbstractField<?>) {
        ((AbstractField<?>)c).setValue(null);
      }
    }
  }
 else {
    if (c != null) {
      c.setParent(this);
    }
    collapsedColumnIds.remove(propertyId);
  }
  reRenderFilterFields=true;
  markAsDirty();
}
Program: 10616
Project: 10616
Buggy source:
private FilterTable buildFilterTable(){
  FilterTable filterTable=new FilterTable();
  filterTable.setSizeFull();
  filterTable.setFilterDecorator(new DemoFilterDecorator());
  filterTable.setFilterGenerator(new DemoFilterGenerator());
  filterTable.setFilterBarVisible(true);
  filterTable.setSelectable(true);
  filterTable.setImmediate(true);
  filterTable.setMultiSelect(true);
  filterTable.setRowHeaderMode(RowHeaderMode.INDEX);
  filterTable.setColumnCollapsingAllowed(true);
  filterTable.setColumnCollapsed("String_Node_Str",true);
  filterTable.setColumnReorderingAllowed(true);
  filterTable.setContainerDataSource(buildContainer());
  return filterTable;
}

Fixed version (ground truth):
private FilterTable buildFilterTable(){
  FilterTable filterTable=new FilterTable();
  filterTable.setSizeFull();
  filterTable.setFilterDecorator(new DemoFilterDecorator());
  filterTable.setFilterGenerator(new DemoFilterGenerator());
  filterTable.setFilterBarVisible(true);
  filterTable.setSelectable(true);
  filterTable.setImmediate(true);
  filterTable.setMultiSelect(true);
  filterTable.setRowHeaderMode(RowHeaderMode.INDEX);
  filterTable.setColumnCollapsingAllowed(true);
  filterTable.setColumnReorderingAllowed(true);
  filterTable.setContainerDataSource(buildContainer());
  filterTable.setColumnCollapsed("String_Node_Str",true);
  filterTable.setVisibleColumns(new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"});
  return filterTable;
}
Program: 10619
Project: 10619
Buggy source:
public void updateFromUIDL(UIDL uidl,ApplicationConnection client){
  if (uidl == null) {
    return;
  }
  this.client=client;
  filtersVisible=uidl.hasAttribute("String_Node_Str") ? uidl.getBooleanAttribute("String_Node_Str") : false;
  setVisible(filtersVisible);
  Collection<Widget> oldFilters=filters.values();
  if (!filtersVisible) {
    container.clear();
    filters.clear();
  }
 else {
    uidls.clear();
    for (final Iterator<Object> it=uidl.getChildIterator(); it.hasNext(); ) {
      final UIDL cc=(UIDL)it.next();
      if (cc.getTag().equals("String_Node_Str")) {
        String cid=cc.getStringAttribute("String_Node_Str");
        uidls.put(cid,cc.getChildUIDL(0));
      }
    }
    reRenderFilterComponents();
  }
  Collection<Widget> newFilters=filters.values();
  for (  Widget filter : oldFilters) {
    if (!newFilters.contains(filter)) {
      client.unregisterPaintable((Paintable)filter);
    }
  }
}

Fixed version (ground truth):
public void updateFromUIDL(UIDL uidl,ApplicationConnection client){
  if (uidl == null) {
    return;
  }
  this.client=client;
  filtersVisible=uidl.hasAttribute("String_Node_Str") ? uidl.getBooleanAttribute("String_Node_Str") : false;
  setVisible(filtersVisible);
  setContainerHeight();
  Collection<Widget> oldFilters=filters.values();
  if (!filtersVisible) {
    container.clear();
    filters.clear();
  }
 else {
    uidls.clear();
    for (final Iterator<Object> it=uidl.getChildIterator(); it.hasNext(); ) {
      final UIDL cc=(UIDL)it.next();
      if (cc.getTag().equals("String_Node_Str")) {
        String cid=cc.getStringAttribute("String_Node_Str");
        uidls.put(cid,cc.getChildUIDL(0));
      }
    }
    reRenderFilterComponents();
  }
  Collection<Widget> newFilters=filters.values();
  for (  Widget filter : oldFilters) {
    if (!newFilters.contains(filter)) {
      client.unregisterPaintable((Paintable)filter);
    }
  }
}
Program: 10620
Project: 10620
Buggy source:
void clearFilterData(){
  for (  Object propertyId : filters.keySet()) {
    owner.getFilterable().removeContainerFilter(filters.get(propertyId));
    if (owner.getFilterGenerator() != null) {
      owner.getFilterGenerator().filterRemoved(propertyId);
    }
  }
  for (  AbstractField<?> af : customFields.keySet()) {
    af.removeValueChangeListener(listener);
  }
  for (  TextField tf : texts.keySet()) {
    tf.removeValueChangeListener(listener);
  }
  for (  ComboBox cb : enums.keySet()) {
    cb.removeValueChangeListener(listener);
  }
  for (  ComboBox cb : booleans.keySet()) {
    cb.removeValueChangeListener(listener);
  }
  customFields.clear();
  filters.clear();
  texts.clear();
  enums.clear();
  booleans.clear();
}

Fixed version (ground truth):
void clearFilterData(){
  for (  Object propertyId : filters.keySet()) {
    owner.getFilterable().removeContainerFilter(filters.get(propertyId));
    if (owner.getFilterGenerator() != null) {
      owner.getFilterGenerator().filterRemoved(propertyId);
    }
  }
  for (  AbstractField<?> af : customFields.keySet()) {
    af.removeValueChangeListener(listener);
  }
  for (  TextField tf : texts.keySet()) {
    tf.removeValueChangeListener(listener);
  }
  for (  ComboBox cb : enums.keySet()) {
    cb.removeValueChangeListener(listener);
  }
  for (  ComboBox cb : booleans.keySet()) {
    cb.removeValueChangeListener(listener);
  }
  for (  DateFilterPopup dfp : dates.keySet()) {
    dfp.removeValueChangeListener(listener);
  }
  customFields.clear();
  filters.clear();
  texts.clear();
  enums.clear();
  booleans.clear();
  dates.clear();
}
Program: 10621
Project: 10621
Buggy source:
public void valueChange(Property.ValueChangeEvent event){
  if (owner.getFilterable() == null) {
    return;
  }
  Property<?> field=event.getProperty();
  Object value=field.getValue();
  Object propertyId=null;
  if (customFields.containsKey(field)) {
    propertyId=customFields.get(field);
  }
 else   if (texts.containsKey(field)) {
    propertyId=texts.get(field);
  }
 else   if (enums.containsKey(field)) {
    propertyId=enums.get(field);
  }
 else   if (booleans.containsKey(field)) {
    propertyId=booleans.get(field);
  }
  removeFilter(propertyId);
  Filter newFilter=generateFilter(field,propertyId,value);
  if (newFilter != null) {
    setFilter(newFilter,propertyId);
    if (owner.getFilterGenerator() != null) {
      owner.getFilterGenerator().filterAdded(propertyId,newFilter.getClass(),value);
    }
  }
 else {
    if (owner.getFilterGenerator() != null) {
      owner.getFilterGenerator().filterRemoved(propertyId);
    }
  }
  if (owner instanceof PagedFilterTable<?>) {
    ((PagedFilterTable<?>)owner).setCurrentPage(1);
  }
}

Fixed version (ground truth):
public void valueChange(Property.ValueChangeEvent event){
  if (owner.getFilterable() == null) {
    return;
  }
  Property<?> field=event.getProperty();
  Object value=field.getValue();
  Object propertyId=null;
  if (customFields.containsKey(field)) {
    propertyId=customFields.get(field);
  }
 else   if (texts.containsKey(field)) {
    propertyId=texts.get(field);
  }
 else   if (dates.containsKey(field)) {
    propertyId=dates.get(field);
  }
 else   if (enums.containsKey(field)) {
    propertyId=enums.get(field);
  }
 else   if (booleans.containsKey(field)) {
    propertyId=booleans.get(field);
  }
  removeFilter(propertyId);
  Filter newFilter=generateFilter(field,propertyId,value);
  if (newFilter != null) {
    setFilter(newFilter,propertyId);
    if (owner.getFilterGenerator() != null) {
      owner.getFilterGenerator().filterAdded(propertyId,newFilter.getClass(),value);
    }
  }
 else {
    if (owner.getFilterGenerator() != null) {
      owner.getFilterGenerator().filterRemoved(propertyId);
    }
  }
  if (owner instanceof PagedFilterTable<?>) {
    ((PagedFilterTable<?>)owner).setCurrentPage(1);
  }
  owner.requestRepaint();
}
Program: 10622
Project: 10622
Buggy source:
private ValueChangeListener initializeListener(){
  return new Property.ValueChangeListener(){
    public void valueChange(    Property.ValueChangeEvent event){
      if (owner.getFilterable() == null) {
        return;
      }
      Property<?> field=event.getProperty();
      Object value=field.getValue();
      Object propertyId=null;
      if (customFields.containsKey(field)) {
        propertyId=customFields.get(field);
      }
 else       if (texts.containsKey(field)) {
        propertyId=texts.get(field);
      }
 else       if (enums.containsKey(field)) {
        propertyId=enums.get(field);
      }
 else       if (booleans.containsKey(field)) {
        propertyId=booleans.get(field);
      }
      removeFilter(propertyId);
      Filter newFilter=generateFilter(field,propertyId,value);
      if (newFilter != null) {
        setFilter(newFilter,propertyId);
        if (owner.getFilterGenerator() != null) {
          owner.getFilterGenerator().filterAdded(propertyId,newFilter.getClass(),value);
        }
      }
 else {
        if (owner.getFilterGenerator() != null) {
          owner.getFilterGenerator().filterRemoved(propertyId);
        }
      }
      if (owner instanceof PagedFilterTable<?>) {
        ((PagedFilterTable<?>)owner).setCurrentPage(1);
      }
    }
  }
;
}

Fixed version (ground truth):
private ValueChangeListener initializeListener(){
  return new Property.ValueChangeListener(){
    public void valueChange(    Property.ValueChangeEvent event){
      if (owner.getFilterable() == null) {
        return;
      }
      Property<?> field=event.getProperty();
      Object value=field.getValue();
      Object propertyId=null;
      if (customFields.containsKey(field)) {
        propertyId=customFields.get(field);
      }
 else       if (texts.containsKey(field)) {
        propertyId=texts.get(field);
      }
 else       if (dates.containsKey(field)) {
        propertyId=dates.get(field);
      }
 else       if (enums.containsKey(field)) {
        propertyId=enums.get(field);
      }
 else       if (booleans.containsKey(field)) {
        propertyId=booleans.get(field);
      }
      removeFilter(propertyId);
      Filter newFilter=generateFilter(field,propertyId,value);
      if (newFilter != null) {
        setFilter(newFilter,propertyId);
        if (owner.getFilterGenerator() != null) {
          owner.getFilterGenerator().filterAdded(propertyId,newFilter.getClass(),value);
        }
      }
 else {
        if (owner.getFilterGenerator() != null) {
          owner.getFilterGenerator().filterRemoved(propertyId);
        }
      }
      if (owner instanceof PagedFilterTable<?>) {
        ((PagedFilterTable<?>)owner).setCurrentPage(1);
      }
      owner.requestRepaint();
    }
  }
;
}
Program: 10623
Project: 10623
Buggy source:
private Filter generateFilter(Property<?> field,Object propertyId,Object value){
  if (value != null && !value.equals("String_Node_Str")) {
    return generateGenericFilter(field,propertyId,value);
  }
  return null;
}

Fixed version (ground truth):
private Filter generateFilter(Property<?> field,Object propertyId,Object value){
  if (field instanceof DateFilterPopup) {
    return generateDateFilter(field,propertyId,value);
  }
 else   if (value != null && !value.equals("String_Node_Str")) {
    return generateGenericFilter(field,propertyId,value);
  }
  return null;
}
Program: 10624
Project: 10624
Buggy source:
private Component createField(Object property,Class<?> type){
  AbstractField<?> component=null;
  if (owner.getFilterGenerator() != null) {
    component=owner.getFilterGenerator().getCustomFilterComponent(property);
  }
  if (component != null) {
    customFields.put(component,property);
  }
 else   if (type == null) {
    component=new TextField();
    component.setWidth("String_Node_Str");
    return component;
  }
 else   if (type == boolean.class || type == Boolean.class) {
    component=createBooleanField(property);
  }
  if (type.isEnum()) {
    component=createEnumField(type,property);
  }
 else {
    component=createTextField(property);
  }
  component.setWidth("String_Node_Str");
  component.setImmediate(true);
  component.addValueChangeListener(listener);
  return component;
}

Fixed version (ground truth):
private Component createField(Object property,Class<?> type){
  AbstractField<?> component=null;
  if (owner.getFilterGenerator() != null) {
    component=owner.getFilterGenerator().getCustomFilterComponent(property);
  }
  if (component != null) {
    customFields.put(component,property);
  }
 else   if (type == null) {
    component=new TextField();
    component.setWidth(100,Unit.PERCENTAGE);
    return component;
  }
 else   if (type == boolean.class || type == Boolean.class) {
    component=createBooleanField(property);
  }
 else   if (type.isEnum()) {
    component=createEnumField(type,property);
  }
 else   if (type == Date.class || type == Timestamp.class || type == java.sql.Date.class) {
    DateFilterPopup dfp=createDateField(property);
    dfp.setWidth(100,Unit.PERCENTAGE);
    dfp.setImmediate(true);
    dfp.addValueChangeListener(listener);
    return dfp;
  }
 else {
    component=createTextField(property);
  }
  component.setWidth(null);
  component.setImmediate(true);
  component.addValueChangeListener(listener);
  return component;
}
Program: 10625
Project: 10625
Buggy source:
public void setFilterWidth(int index,int width){
  int realWidth=width + 13;
  Widget p=filters.get(getColKeyByIndex(index));
  if (p != null) {
    p.setWidth(realWidth + "String_Node_Str");
  }
}

Fixed version (ground truth):
public void setFilterWidth(int index,int width){
  Widget p=filters.get(getColKeyByIndex(index));
  if (p != null) {
    p.setWidth(Util.getRequiredWidth(tHead.getHeaderCell(index)) + "String_Node_Str");
  }
}
Program: 10626
Project: 10626
Buggy source:
@Override public void onEnabled(Context context){
  super.onEnabled(context);
  startTicking(context);
  clock=new Analog24HClock(context);
}

Fixed version (ground truth):
@Override public void onEnabled(Context context){
  super.onEnabled(context);
  startTicking(context);
}
Program: 10627
Project: 10627
Buggy source:
@Override public void onUpdate(Context context,AppWidgetManager appWidgetManager,int[] appWidgetIds){
  final RemoteViews rv=new RemoteViews(context.getPackageName(),R.layout.widget);
  if (clock == null) {
    clock=new Analog24HClock(context);
    clock.setShowSeconds(false);
    clock.addDialOverlay(new SunPositionOverlay(context));
    final int s=(int)getSize(context);
    clock.onSizeChanged(s,s,0,0);
    clock.measure(s,s);
    clock.layout(0,0,s,s);
    Log.d(TAG,"String_Node_Str" + s);
    clock.setDrawingCacheEnabled(true);
    final PendingIntent intent=ClockUtil.getClockIntent(context);
    if (intent != null) {
      rv.setOnClickPendingIntent(R.id.clock,intent);
    }
  }
  final Bitmap cached=clock.getDrawingCache(true);
  if (cached != null) {
    rv.setImageViewBitmap(R.id.clock,cached);
  }
  appWidgetManager.updateAppWidget(appWidgetIds,rv);
}

Fixed version (ground truth):
@Override public void onUpdate(Context context,AppWidgetManager appWidgetManager,int[] appWidgetIds){
  final RemoteViews rv=new RemoteViews(context.getPackageName(),R.layout.widget);
  if (clock == null) {
    clock=new Analog24HClock(context);
    clock.setShowSeconds(false);
    clock.addDialOverlay(new SunPositionOverlay(context));
    final int s=(int)getSize(context);
    clock.onSizeChanged(s,s,0,0);
    clock.measure(s,s);
    clock.layout(0,0,s,s);
    Log.d(TAG,"String_Node_Str" + s);
    clock.setDrawingCacheEnabled(true);
    final PendingIntent intent=ClockUtil.getClockIntent(context);
    if (intent != null) {
      rv.setOnClickPendingIntent(R.id.clock,intent);
    }
  }
  Bitmap cached=null;
  cached=clock.getDrawingCache(true);
  boolean shouldRecycle=false;
  if (cached == null) {
    final int s=(int)getSize(context);
    cached=Bitmap.createBitmap(s,s,Bitmap.Config.ARGB_8888);
    final Canvas c=new Canvas(cached);
    clock.draw(c);
    cached=Bitmap.createBitmap(cached);
    shouldRecycle=true;
  }
  if (cached != null) {
    rv.setImageViewBitmap(R.id.clock,cached);
  }
 else {
    Log.e(TAG,"String_Node_Str");
  }
  if (!mFirst && Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
    appWidgetManager.partiallyUpdateAppWidget(appWidgetIds,rv);
  }
 else {
    appWidgetManager.updateAppWidget(appWidgetIds,rv);
    mFirst=false;
  }
  if (shouldRecycle) {
    cached.recycle();
  }
}
Program: 10630
Project: 10630
Buggy source:
protected IFile getFile(IResource resource,String containingFolderName,String fileName) throws CoreException {
  if (resource instanceof IFile && resource.getName().equals(fileName) && resource.getParent() != null && resource.getParent().getName().equals(containingFolderName)) {
    return (IFile)resource;
  }
 else   if (resource instanceof IContainer) {
    IContainer container=(IContainer)resource;
    IResource[] children=container.members();
    if (children != null) {
      for (      IResource child : children) {
        IFile file=getFile(child,containingFolderName,fileName);
        if (file != null) {
          return file;
        }
      }
    }
  }
  return null;
}

Fixed version (ground truth):
protected IFile getFile(IResource resource,String containingFolderName,String fileName) throws CoreException {
  if (resource == null || !resource.exists()) {
    return null;
  }
  if (resource instanceof IFile && resource.getName().equals(fileName) && resource.getParent() != null && resource.getParent().getName().equals(containingFolderName)) {
    return (IFile)resource;
  }
 else   if (resource instanceof IContainer) {
    IContainer container=(IContainer)resource;
    IResource[] children=container.members();
    if (children != null) {
      for (      IResource child : children) {
        IFile file=getFile(child,containingFolderName,fileName);
        if (file != null) {
          return file;
        }
      }
    }
  }
  return null;
}
Program: 10631
Project: 10631
Buggy source:
public static String getDescriptorID(String userName,String password,String actualURL){
  if (userName == null || password == null || actualURL == null) {
    return null;
  }
  return userName + password + actualURL;
}

Fixed version (ground truth):
public static String getDescriptorID(String userName,String password,String actualURL,boolean selfSigned){
  if (userName == null || password == null || actualURL == null) {
    return null;
  }
  return userName + password + actualURL+ selfSigned;
}
Program: 10632
Project: 10632
Buggy source:
public CloudSpacesDescriptor(CloudOrgsAndSpaces spaces,String userName,String password,String actualServerURL){
  this.spaces=spaces;
  descriptorID=getDescriptorID(userName,password,actualServerURL);
}

Fixed version (ground truth):
public CloudSpacesDescriptor(CloudOrgsAndSpaces spaces,String userName,String password,String actualServerURL,boolean selfSigned){
  this.spaces=spaces;
  descriptorID=getDescriptorID(userName,password,actualServerURL,selfSigned);
}
Program: 10633
Project: 10633
Buggy source:
protected CloudSpacesDescriptor internalUpdateDescriptor(String urlText,String userName,String password,boolean selfSigned,IRunnableContext context) throws CoreException {
  String actualURL=CloudUiUtil.getUrlFromDisplayText(urlText);
  validateCredentialsLocally(actualURL,userName,password);
  String cachedDescriptorID=CloudSpacesDescriptor.getDescriptorID(userName,password,actualURL);
  spacesDescriptor=cachedDescriptors.get(cachedDescriptorID);
  if (spacesDescriptor == null) {
    CloudOrgsAndSpaces orgsAndSpaces=CloudUiUtil.getCloudSpaces(userName,password,actualURL,true,selfSigned,context);
    if (orgsAndSpaces != null) {
      spacesDescriptor=new CloudSpacesDescriptor(orgsAndSpaces,userName,password,actualURL);
      cachedDescriptors.put(cachedDescriptorID,spacesDescriptor);
    }
  }
  return spacesDescriptor;
}

Fixed version (ground truth):
protected CloudSpacesDescriptor internalUpdateDescriptor(String urlText,String userName,String password,boolean selfSigned,IRunnableContext context) throws CoreException {
  String actualURL=CloudUiUtil.getUrlFromDisplayText(urlText);
  validateCredentialsLocally(actualURL,userName,password);
  if (spacesDescriptor == null) {
    CloudOrgsAndSpaces orgsAndSpaces=CloudUiUtil.getCloudSpaces(userName,password,actualURL,true,selfSigned,context);
    if (orgsAndSpaces != null) {
      spacesDescriptor=new CloudSpacesDescriptor(orgsAndSpaces,userName,password,actualURL,selfSigned);
    }
  }
  return spacesDescriptor;
}
Program: 10634
Project: 10634
Buggy source:
/** 
 * True if there is already a descriptor set for the given set of credentials that contains a list of orgs and spaces. False otherwise
 * @param urlText
 * @param userName
 * @param password
 * @return
 */
public boolean matchesCurrentDescriptor(String urlText,String userName,String password){
  String actualURL=CloudUiUtil.getUrlFromDisplayText(urlText);
  String cachedDescriptorID=CloudSpacesDescriptor.getDescriptorID(userName,password,actualURL);
  return getCurrentSpacesDescriptor() != null && getCurrentSpacesDescriptor().getID() != null && getCurrentSpacesDescriptor().getID().equals(cachedDescriptorID);
}

Fixed version (ground truth):
/** 
 * True if there is already a descriptor set for the given set of credentials that contains a list of orgs and spaces. False otherwise
 * @param urlText
 * @param userName
 * @param password
 * @return
 */
public boolean matchesCurrentDescriptor(String urlText,String userName,String password,boolean selfSigned){
  String actualURL=CloudUiUtil.getUrlFromDisplayText(urlText);
  String cachedDescriptorID=CloudSpacesDescriptor.getDescriptorID(userName,password,actualURL,selfSigned);
  return getCurrentSpacesDescriptor() != null && getCurrentSpacesDescriptor().getID() != null && getCurrentSpacesDescriptor().getID().equals(cachedDescriptorID);
}
Program: 10636
Project: 10636
Buggy source:
/** 
 * Prompts user to define a value for the wildcard in the cloud URL, then return the new URL
 * @param cloudUrl
 * @param allCloudUrls
 * @param shell
 * @return new URL, null if no wildcard appears in cloudUrl or if usercancels out of defining a new value
 */
public static CloudServerURL getWildcardUrl(CloudServerURL cloudUrl,List<CloudServerURL> allCloudUrls,Shell shell){
  String url=cloudUrl.getUrl();
  if (url.contains("String_Node_Str")) {
    int startIndex=url.indexOf("String_Node_Str");
    int endIndex=url.indexOf("String_Node_Str");
    String wildcard=url.substring(startIndex + 1,endIndex);
    TargetURLDialog dialog=new TargetURLDialog(shell,cloudUrl,wildcard,allCloudUrls);
    if (dialog.open() == IDialogConstants.OK_ID) {
      url=dialog.getUrl();
      String name=dialog.getName();
      return new CloudServerURL(name,url,true);
    }
 else {
      return null;
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Prompts user to define a value for the wildcard in the cloud URL, then return the new URL
 * @param cloudUrl
 * @param allCloudUrls
 * @param shell
 * @return new URL, null if no wildcard appears in cloudUrl or if usercancels out of defining a new value
 */
public static CloudServerURL getWildcardUrl(CloudServerURL cloudUrl,List<CloudServerURL> allCloudUrls,Shell shell){
  String url=cloudUrl.getUrl();
  if (url.contains("String_Node_Str")) {
    int startIndex=url.indexOf("String_Node_Str");
    int endIndex=url.indexOf("String_Node_Str");
    String wildcard=url.substring(startIndex + 1,endIndex);
    TargetURLDialog dialog=new TargetURLDialog(shell,cloudUrl,wildcard,allCloudUrls);
    if (dialog.open() == IDialogConstants.OK_ID) {
      url=dialog.getUrl();
      String name=dialog.getName();
      boolean selfSigned=url != null && CloudFoundryServer.getSelfSignedCertificate(url);
      return new CloudServerURL(name,url,true,selfSigned);
    }
 else {
      return null;
    }
  }
  return null;
}
Program: 10637
Project: 10637
Buggy source:
public static List<CloudServerURL> getUserDefinedUrls(String serverTypeId){
  List<CloudServerURL> urls=new ArrayList<CloudServerURL>();
  IPreferenceStore prefStore=CloudFoundryServerUiPlugin.getDefault().getPreferenceStore();
  String urlString=prefStore.getString(ATTR_USER_DEFINED_URLS + "String_Node_Str" + serverTypeId);
  if (urlString != null && urlString.length() > 0) {
    String[] urlEntries=urlString.split("String_Node_Str");
    if (urlEntries != null) {
      for (      String entry : urlEntries) {
        if (entry.length() > 0) {
          String[] values=entry.split("String_Node_Str");
          if (values != null) {
            String name=null;
            String url=null;
            if (values.length >= 2) {
              name=values[0];
              url=values[1];
            }
            urls.add(new CloudServerURL(name,url,true));
          }
        }
      }
    }
  }
  return urls;
}

Fixed version (ground truth):
public static List<CloudServerURL> getUserDefinedUrls(String serverTypeId){
  List<CloudServerURL> urls=new ArrayList<CloudServerURL>();
  IPreferenceStore prefStore=CloudFoundryServerUiPlugin.getDefault().getPreferenceStore();
  String urlString=prefStore.getString(ATTR_USER_DEFINED_URLS + "String_Node_Str" + serverTypeId);
  if (urlString != null && urlString.length() > 0) {
    String[] urlEntries=urlString.split("String_Node_Str");
    if (urlEntries != null) {
      for (      String entry : urlEntries) {
        if (entry.length() > 0) {
          String[] values=entry.split("String_Node_Str");
          if (values != null) {
            String name=null;
            String url=null;
            if (values.length >= 2) {
              name=values[0];
              url=values[1];
            }
            boolean selfSigned=url != null && CloudFoundryServer.getSelfSignedCertificate(url);
            urls.add(new CloudServerURL(name,url,true,selfSigned));
          }
        }
      }
    }
  }
  return urls;
}
Program: 10638
Project: 10638
Buggy source:
public IPackageFragmentRoot[] getPackageFragmentRoots(IProgressMonitor monitor) throws CoreException {
  IType type=getMainType(monitor);
  ILaunchConfiguration configuration=createConfiguration(type);
  IPath[] classpathEntries=getRuntimeClasspaths(configuration);
  List<IPackageFragmentRoot> pckRoots=new ArrayList<IPackageFragmentRoot>();
  List<IJavaProject> javaProjectsToSearch=getOrderedJavaProjects(javaProject);
  for (  IPath path : classpathEntries) {
    for (    IJavaProject javaProject : javaProjectsToSearch) {
      try {
        IPackageFragmentRoot[] roots=javaProject.getPackageFragmentRoots();
        if (roots != null) {
          List<IPackageFragmentRoot> foundRoots=new ArrayList<IPackageFragmentRoot>();
          for (          IPackageFragmentRoot packageFragmentRoot : roots) {
            if (isRootAtEntry(packageFragmentRoot,path)) {
              foundRoots.add(packageFragmentRoot);
            }
          }
          if (!foundRoots.isEmpty()) {
            pckRoots.addAll(foundRoots);
            break;
          }
        }
      }
 catch (      Exception e) {
        throw CloudErrorUtil.toCoreException(e);
      }
    }
  }
  return pckRoots.toArray(new IPackageFragmentRoot[pckRoots.size()]);
}

Fixed version (ground truth):
public IPackageFragmentRoot[] getPackageFragmentRoots(IProgressMonitor monitor) throws CoreException {
  IType type=getMainType(monitor);
  IPath[] classpathEntries=null;
  ILaunchConfiguration configuration=null;
  try {
    configuration=createConfiguration(type);
    classpathEntries=getRuntimeClasspaths(configuration);
  }
  finally {
    if (configuration != null) {
      configuration.delete();
    }
  }
  List<IPackageFragmentRoot> pckRoots=new ArrayList<IPackageFragmentRoot>();
  List<IJavaProject> javaProjectsToSearch=getOrderedJavaProjects(javaProject);
  for (  IPath path : classpathEntries) {
    for (    IJavaProject javaProject : javaProjectsToSearch) {
      try {
        IPackageFragmentRoot[] roots=javaProject.getPackageFragmentRoots();
        if (roots != null) {
          List<IPackageFragmentRoot> foundRoots=new ArrayList<IPackageFragmentRoot>();
          for (          IPackageFragmentRoot packageFragmentRoot : roots) {
            if (isRootAtEntry(packageFragmentRoot,path)) {
              foundRoots.add(packageFragmentRoot);
            }
          }
          if (!foundRoots.isEmpty()) {
            pckRoots.addAll(foundRoots);
            break;
          }
        }
      }
 catch (      Exception e) {
        throw CloudErrorUtil.toCoreException(e);
      }
    }
  }
  return pckRoots.toArray(new IPackageFragmentRoot[pckRoots.size()]);
}
Program: 10639
Project: 10639
Buggy source:
protected boolean hasSpaceChanged(CloudSpace selectedCloudSpace){
  CloudFoundrySpace existingSpace=getCloudServer().getCloudFoundrySpace();
  return !matchesExisting(selectedCloudSpace,existingSpace);
}

Fixed version (ground truth):
protected boolean hasSpaceChanged(CloudSpace selectedCloudSpace){
  CloudFoundrySpace existingSpace=getCloudServer().getCloudFoundrySpace();
  return !matchesSpace(selectedCloudSpace,existingSpace);
}
Program: 10640
Project: 10640
Buggy source:
/** 
 * @return the first space available that has no corresponding serverinstance. If null, no space found that is not already associated with a server instance.
 */
public CloudSpace getSpaceWithNoServerInstance(){
  CloudSpacesDescriptor descriptor=getCurrentSpacesDescriptor();
  CloudOrgsAndSpaces orgsSpaces=descriptor != null ? descriptor.getOrgsAndSpaces() : null;
  if (orgsSpaces != null) {
    List<CloudFoundryServer> cloudServers=CloudServerUtil.getCloudServers();
    if (cloudServers == null || cloudServers.isEmpty()) {
      return orgsSpaces.getDefaultCloudSpace();
    }
 else {
      List<CloudSpace> spaces=orgsSpaces.getAllSpaces();
      if (spaces != null) {
        for (        CloudSpace space : spaces) {
          CloudFoundryServer existingServer=null;
          for (          CloudFoundryServer cloudServer : cloudServers) {
            if (matchesExisting(space,cloudServer.getCloudFoundrySpace())) {
              existingServer=cloudServer;
              break;
            }
          }
          if (existingServer == null) {
            return space;
          }
        }
      }
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * @return the first space available that has no corresponding serverinstance. If null, no space found that is not already associated with a server instance.
 */
public CloudSpace getSpaceWithNoServerInstance(){
  CloudSpacesDescriptor descriptor=getCurrentSpacesDescriptor();
  CloudOrgsAndSpaces orgsSpaces=descriptor != null ? descriptor.getOrgsAndSpaces() : null;
  if (orgsSpaces != null) {
    List<CloudFoundryServer> cloudServers=CloudServerUtil.getCloudServers();
    if (cloudServers == null || cloudServers.isEmpty()) {
      return orgsSpaces.getDefaultCloudSpace();
    }
 else {
      List<CloudSpace> spaces=orgsSpaces.getAllSpaces();
      if (spaces != null) {
        String url=cloudServer.getUrl();
        for (        CloudSpace space : spaces) {
          CloudFoundryServer foundServer=null;
          for (          CloudFoundryServer existingServer : cloudServers) {
            if (existingServer.getUrl().equals(url) && matchesSpace(space,existingServer.getCloudFoundrySpace())) {
              foundServer=cloudServer;
              break;
            }
          }
          if (foundServer == null) {
            return space;
          }
        }
      }
    }
  }
  return null;
}
Program: 10643
Project: 10643
Buggy source:
/** 
 * Error due to invalid credentials, typically 401 or 403 HTTP errors. Returns null if the error is NOT an invalid credentials error.
 * @param t error to parse
 * @return Error message if invalid credentials error (401 or 403), or null.
 */
public static String getInvalidCredentialsError(Throwable t){
  if (isUnauthorisedException(t)) {
    return Messages.ERROR_WRONG_EMAIL_OR_PASSWORD_UNAUTHORISED;
  }
 else   if (isForbiddenException(t)) {
    return Messages.ERROR_WRONG_EMAIL_OR_PASSWORD_FORBIDDEN;
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Error due to invalid credentials, typically 401 or 403 HTTP errors. Returns null if the error is NOT an invalid credentials error.
 * @param error error to parse
 * @return Error message if invalid credentials error (401 or 403), or null.
 */
public static String getInvalidCredentialsError(Throwable error){
  if (isUnauthorisedException(error)) {
    return Messages.ERROR_WRONG_EMAIL_OR_PASSWORD_UNAUTHORISED;
  }
 else   if (isForbiddenException(error)) {
    return Messages.ERROR_WRONG_EMAIL_OR_PASSWORD_FORBIDDEN;
  }
 else {
    OAuth2AccessDeniedException oauthException=null;
    if (error instanceof OAuth2AccessDeniedException) {
      oauthException=(OAuth2AccessDeniedException)error;
    }
 else     if (error.getCause() instanceof OAuth2AccessDeniedException) {
      oauthException=(OAuth2AccessDeniedException)error.getCause();
    }
    if (oauthException != null && oauthException.getHttpErrorCode() == 403) {
      return NLS.bind(Messages.ERROR_ACCESS_TOKEN,oauthException.getOAuth2ErrorCode());
    }
  }
  return null;
}
Program: 10644
Project: 10644
Buggy source:
/** 
 * Allow UI Control to react based on a property change and change the UI control.
 * @param event property change event that describes the change.
 */
public void handlePropertyChanged(PropertyChangeEvent event){
  if (event != null && AbstractUIControl.PROP_SERVER_TYPE.equals(event.getPropertyName())) {
    Object curNewValue=event.getNewValue();
    if (curNewValue instanceof IServerType && isSupportedServerType((IServerType)curNewValue)) {
      if (controlListener != null) {
        controlMap.put(PROP_HOSTNAME,new UIControlEntry(false,null));
        fireUIControlChangedEvent();
      }
    }
 else {
      if (controlListener != null) {
        controlMap.put(PROP_HOSTNAME,new UIControlEntry(true,null));
        fireUIControlChangedEvent();
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Allow UI Control to react based on a property change and change the UI control.
 * @param event property change event that describes the change.
 */
public void handlePropertyChanged(PropertyChangeEvent event){
  if (event != null && AbstractUIControl.PROP_SERVER_TYPE.equals(event.getPropertyName())) {
    Object curNewValue=event.getNewValue();
    if (curNewValue == null || curNewValue instanceof IServerType && isSupportedServerType((IServerType)curNewValue)) {
      if (controlListener != null) {
        controlMap.put(PROP_HOSTNAME,new UIControlEntry(false,null));
        fireUIControlChangedEvent();
      }
    }
 else {
      if (controlListener != null) {
        controlMap.put(PROP_HOSTNAME,new UIControlEntry(true,null));
        fireUIControlChangedEvent();
      }
    }
  }
}
Program: 10645
Project: 10645
Buggy source:
/** 
 * Allow UI Control to react based on a property change and change the UI control.
 * @param event property change event that describes the change.
 */
public void handlePropertyChanged(PropertyChangeEvent event){
  if (event != null && AbstractUIControl.PROP_SERVER_TYPE.equals(event.getPropertyName())) {
    Object curNewValue=event.getNewValue();
    Object curOldValue=event.getOldValue();
    if (curOldValue != curNewValue) {
      if (curNewValue instanceof IServerType) {
        if (isSupportedServerType((IServerType)curNewValue)) {
          if (controlListener != null) {
            controlMap.put(PROP_HOSTNAME,new UIControlEntry(false,null));
            previousHostname=controlListener.getControlStringValue(PROP_HOSTNAME);
            fireUIControlChangedEvent();
          }
        }
 else         if (isSupportedServerType((IServerType)curOldValue)) {
          if (controlListener != null) {
            controlMap.put(PROP_HOSTNAME,new UIControlEntry(true,previousHostname));
            previousHostname=null;
            fireUIControlChangedEvent();
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Allow UI Control to react based on a property change and change the UI control.
 * @param event property change event that describes the change.
 */
public void handlePropertyChanged(PropertyChangeEvent event){
  if (event != null && AbstractUIControl.PROP_SERVER_TYPE.equals(event.getPropertyName())) {
    Object curNewValue=event.getNewValue();
    Object curOldValue=event.getOldValue();
    if (curOldValue != curNewValue) {
      if (curNewValue == null || curNewValue instanceof IServerType) {
        if (isSupportedServerType((IServerType)curNewValue)) {
          if (controlListener != null) {
            controlMap.put(PROP_HOSTNAME,new UIControlEntry(false,null));
            previousHostname=controlListener.getControlStringValue(PROP_HOSTNAME);
            fireUIControlChangedEvent();
          }
        }
 else         if (isSupportedServerType((IServerType)curOldValue)) {
          if (controlListener != null) {
            controlMap.put(PROP_HOSTNAME,new UIControlEntry(true,previousHostname));
            previousHostname=null;
            fireUIControlChangedEvent();
          }
        }
      }
    }
  }
}