nus-yam/ex-repair huggingface dataset:
Program: 25934
Project: 25934
Buggy source:
protected static Status send(Transport transport,Object data){
  String json=transport.send(data);
  Status status=buildStatusObject(json);
  if (!status.isSuccess()) {
switch (status.advicedReconnectApproach()) {
case unknown:
      break;
case handshake:
    open(transport).validate();
case retry:
  connect(transport).validate();
default :
json=transport.send(data);
status=buildStatusObject(json);
}
}
status.validate();
return status;
}

Fixed version (ground truth):
protected static Status send(Transport transport,Object data){
  if (state == Machine.created || state == Machine.error) {
    state=open(transport).isSuccess() ? Machine.handshaken : Machine.error;
  }
  if (state == Machine.handshaken) {
    state=connect(transport).isSuccess() ? Machine.connected : Machine.error;
  }
  String json=transport.send(data);
  Status status=buildStatusObject(json);
  if (!status.isSuccess()) {
    state=Machine.error;
switch (status.advicedReconnectApproach()) {
case unknown:
      break;
case handshake:
    open(transport).validate();
  state=Machine.handshaken;
case retry:
connect(transport).validate();
state=Machine.connected;
default :
json=transport.send(data);
status=buildStatusObject(json);
}
}
status.validate();
state=Machine.success;
return status;
}
Program: 25935
Project: 25935
Buggy source:
@Override public void run(){
  listener.onRequestPerformed(result);
}

Fixed version (ground truth):
@Override public void run(){
  for (  final ResultListener<T> listener : resultListeners) {
    if (listener != null) {
      if (listener.onRequestPerformed(result)) {
        return;
      }
    }
  }
}
Program: 25936
Project: 25936
Buggy source:
/** 
 * Reports a delivered error to all error listeners. The callback implementations will be called on the Main thread.
 */
private void notifyErrorListeners(){
  Handler handler=new Handler(Looper.getMainLooper());
  for (  final ErrorListener listener : errorListeners) {
    if (listener != null) {
      handler.post(new Runnable(){
        @Override public void run(){
          listener.onErrorOccured(error);
        }
      }
);
    }
  }
}

Fixed version (ground truth):
/** 
 * Reports a delivered error to all error listeners. The callback implementations will be called on the Main thread.
 */
private void notifyErrorListeners(){
  Handler handler=new Handler(Looper.getMainLooper());
  handler.post(new Runnable(){
    @Override public void run(){
      for (      final ErrorListener listener : errorListeners) {
        if (listener != null) {
          if (listener.onErrorOccured(error)) {
            return;
          }
        }
      }
    }
  }
);
}
Program: 25937
Project: 25937
Buggy source:
/** 
 * Reports a delivered result to all result listeners. The callback implementations will be called on the Main thread.
 */
private void notifyResultListeners(){
  Handler handler=new Handler(Looper.getMainLooper());
  for (  final ResultListener<T> listener : resultListeners) {
    if (listener != null) {
      handler.post(new Runnable(){
        @Override public void run(){
          listener.onRequestPerformed(result);
        }
      }
);
    }
  }
}

Fixed version (ground truth):
/** 
 * Reports a delivered result to all result listeners. The callback implementations will be called on the Main thread.
 */
private void notifyResultListeners(){
  Handler handler=new Handler(Looper.getMainLooper());
  handler.post(new Runnable(){
    @Override public void run(){
      for (      final ResultListener<T> listener : resultListeners) {
        if (listener != null) {
          if (listener.onRequestPerformed(result)) {
            return;
          }
        }
      }
    }
  }
);
}
Program: 25938
Project: 25938
Buggy source:
/** 
 * Initializes the Podio SDK with the given client credentials. This method MUST be called before any other request is made.
 * @param context The context to initialize the cache database and network clients in.
 * @param authority The host the SDK will target with its requests.
 * @param clientId The pre-shared Podio client id.
 * @param clientSecret The corresponding Podio client secret.
 * @param sslSocketFactory Optional custom SSL socket factory to use in the HTTP requests.
 */
public static void setup(Context context,String scheme,String authority,String clientId,String clientSecret,SSLSocketFactory sslSocketFactory){
  restClient.setup(context,scheme,authority,clientId,clientSecret,sslSocketFactory);
  application.setClient(restClient);
  calendar.setClient(restClient);
  client.setClient(restClient);
  item.setClient(restClient);
  organization.setClient(restClient);
  user.setClient(restClient);
  view.setClient(restClient);
}

Fixed version (ground truth):
/** 
 * Initializes the Podio SDK with the given client credentials. This method MUST be called before any other request is made.
 * @param context The context to initialize the cache database and network clients in.
 * @param authority The host the SDK will target with its requests.
 * @param clientId The pre-shared Podio client id.
 * @param clientSecret The corresponding Podio client secret.
 * @param sslSocketFactory Optional custom SSL socket factory to use in the HTTP requests.
 */
public static void setup(Context context,String scheme,String authority,String clientId,String clientSecret,SSLSocketFactory sslSocketFactory){
  restClient.setup(context,scheme,authority,clientId,clientSecret,sslSocketFactory);
  application.setClient(restClient);
  calendar.setClient(restClient);
  client.setClient(restClient);
  item.setClient(restClient);
  organization.setClient(restClient);
  user.setClient(restClient);
  view.setClient(restClient);
  task.setClient(restClient);
}
Program: 25939
Project: 25939
Buggy source:
public GetTaskFilter(){
  this.fullView();
}

Fixed version (ground truth):
public GetTaskFilter(){
  addPathSegment("String_Node_Str");
  this.fullView();
}
Program: 25940
Project: 25940
Buggy source:
public Request<Task[]> getTasks(TaskFilter filter){
  return get(filter,Task[].class);
}

Fixed version (ground truth):
public Request<Task[]> getTasks(GetTaskFilter filter){
  return get(filter,Task[].class);
}
Program: 25941
Project: 25941
Buggy source:
Path withWorkspaceId(int spaceId){
  addPathSegment("String_Node_Str");
  addPathSegment(Long.toString(spaceId,10));
  return this;
}

Fixed version (ground truth):
Path withWorkspaceId(long spaceId){
  addPathSegment("String_Node_Str");
  addPathSegment(Long.toString(spaceId,10));
  return this;
}
Program: 25942
Project: 25942
Buggy source:
/** 
 * Fetches all space calendar events.
 * @param spaceId The id of the workspace from which to fetch the calendar events.
 * @param from The Date from which the result should start from.
 * @param to The Date from which the result should end at.
 * @param priority The priority level of the results.
 * @param includeTasks Boolean true to include tasks in the calendar. Boolean false otherwise.
 * @return
 */
public Request<CalendarEvent[]> getSpaceCalendar(int spaceId,Date from,Date to,int priority,boolean includeTasks){
  Path filter=new Path().withWorkspaceId(spaceId).withDate(from,to).withPriority(priority).withTasks(includeTasks).withWorkspaceNameField();
  return get(filter,CalendarEvent[].class);
}

Fixed version (ground truth):
/** 
 * Fetches all space calendar events.
 * @param spaceId The id of the workspace from which to fetch the calendar events.
 * @param from The Date from which the result should start from.
 * @param to The Date from which the result should end at.
 * @param priority The priority level of the results.
 * @param includeTasks Boolean true to include tasks in the calendar. Boolean false otherwise.
 * @return
 */
public Request<CalendarEvent[]> getSpaceCalendar(long spaceId,Date from,Date to,int priority,boolean includeTasks){
  Path filter=new Path().withWorkspaceId(spaceId).withDate(from,to).withPriority(priority).withTasks(includeTasks).withWorkspaceNameField();
  return get(filter,CalendarEvent[].class);
}
Program: 25943
Project: 25943
Buggy source:
@Override public Field deserialize(JsonElement element,Type type,JsonDeserializationContext gsonContext) throws JsonParseException {
  if (element == null || element.isJsonNull()) {
    return null;
  }
  JsonObject jsonObject=element.getAsJsonObject();
  if (!jsonObject.has("String_Node_Str")) {
    jsonObject.add("String_Node_Str",new JsonArray());
  }
  Field.Type typeEnum=Field.Type.undefined;
  JsonElement fieldType=jsonObject.get("String_Node_Str");
  if (fieldType != null && !fieldType.isJsonNull()) {
    try {
      typeEnum=Enum.valueOf(Field.Type.class,fieldType.getAsString());
    }
 catch (    IllegalArgumentException e) {
    }
  }
  if (typeEnum == Field.Type.undefined) {
    jsonObject.addProperty("String_Node_Str",Field.Type.undefined.name());
  }
  return gsonContext.deserialize(jsonObject,typeEnum.getFieldClass());
}

Fixed version (ground truth):
@Override public Field deserialize(JsonElement element,Type type,JsonDeserializationContext gsonContext) throws JsonParseException {
  if (element == null || element.isJsonNull()) {
    return null;
  }
  JsonObject jsonObject=element.getAsJsonObject();
  if (!jsonObject.has("String_Node_Str")) {
    jsonObject.add("String_Node_Str",new JsonArray());
  }
  Field.Type typeEnum=Field.Type.undefined;
  JsonElement fieldType=jsonObject.get("String_Node_Str");
  if (fieldType != null && !fieldType.isJsonNull()) {
    try {
      typeEnum=Field.Type.valueOf(fieldType.getAsString());
    }
 catch (    IllegalArgumentException e) {
    }
  }
  if (typeEnum == Field.Type.undefined) {
    jsonObject.addProperty("String_Node_Str",Field.Type.undefined.name());
  }
  return gsonContext.deserialize(jsonObject,typeEnum.getFieldClass());
}
Program: 25944
Project: 25944
Buggy source:
/** 
 * Determines whether the given object can be used as value for this field or not.
 * @param value The object to use as value.
 * @return A type specific value representation of the given object.
 * @throws FieldTypeMismatchException If the given object can't be used as value for this field.
 */
private MapValue validateValue(Object value) throws FieldTypeMismatchException {
  if (value instanceof MapValue) {
    return (MapValue)value;
  }
 else   if (value instanceof MapValue.Data) {
    return new MapValue((MapValue.Data)value);
  }
 else   if (value instanceof String) {
    return new MapValue(value.toString());
  }
 else {
    throw new FieldTypeMismatchException();
  }
}

Fixed version (ground truth):
/** 
 * Determines whether the given object can be used as value for this field or not.
 * @param value The object to use as value.
 * @return A type specific value representation of the given object.
 * @throws FieldTypeMismatchException If the given object can't be used as value for this field.
 */
private MapValue validateValue(Object value) throws FieldTypeMismatchException {
  if (value instanceof MapValue) {
    return (MapValue)value;
  }
 else   if (value instanceof String) {
    return new MapValue(value.toString());
  }
 else {
    throw new FieldTypeMismatchException();
  }
}
Program: 25945
Project: 25945
Buggy source:
/** 
 * Determines whether the given object can be used as value for this field or not.
 * @param value The object to use as value.
 * @return A type specific value representation of the given object.
 * @throws FieldTypeMismatchException If the given object can't be used as value for this field.
 */
private MoneyValue validateValue(Object value) throws FieldTypeMismatchException {
  if (value instanceof MoneyValue) {
    return (MoneyValue)value;
  }
 else   if (value instanceof MoneyValue.Data) {
    return new MoneyValue((MoneyValue.Data)value);
  }
 else   if (value instanceof String[]) {
    String[] v=(String[])value;
    if (v.length == 2) {
      return new MoneyValue(v[0],v[1]);
    }
 else {
      throw new FieldTypeMismatchException();
    }
  }
 else {
    throw new FieldTypeMismatchException();
  }
}

Fixed version (ground truth):
/** 
 * Determines whether the given object can be used as value for this field or not.
 * @param value The object to use as value.
 * @return A type specific value representation of the given object.
 * @throws FieldTypeMismatchException If the given object can't be used as value for this field.
 */
private MoneyValue validateValue(Object value) throws FieldTypeMismatchException {
  if (value instanceof MoneyValue) {
    return (MoneyValue)value;
  }
 else   if (value instanceof String[]) {
    String[] v=(String[])value;
    if (v.length == 2) {
      return new MoneyValue(v[0],v[1]);
    }
 else {
      throw new FieldTypeMismatchException();
    }
  }
 else {
    throw new FieldTypeMismatchException();
  }
}
Program: 25946
Project: 25946
Buggy source:
public double getLongitude(){
  return value != null ? value.getLongitude() : 0.0D;
}

Fixed version (ground truth):
public double getLongitude(){
  return Utils.getNative(lng,0.0D);
}
Program: 25947
Project: 25947
Buggy source:
public String getCountry(){
  return value != null ? value.getCountry() : null;
}

Fixed version (ground truth):
public String getCountry(){
  return country;
}
Program: 25948
Project: 25948
Buggy source:
public double getLatitude(){
  return value != null ? value.getLatitude() : 0.0D;
}

Fixed version (ground truth):
public double getLatitude(){
  return Utils.getNative(lat,0.0D);
}
Program: 25949
Project: 25949
Buggy source:
public MapValue(String value){
  this.value=new Data(value);
}

Fixed version (ground truth):
public MapValue(String value){
  this.value=value;
}
Program: 25950
Project: 25950
Buggy source:
public String getPostalCode(){
  return value != null ? value.getPostalCode() : null;
}

Fixed version (ground truth):
public String getPostalCode(){
  return postal_code;
}
Program: 25951
Project: 25951
Buggy source:
public String getFormattedLocation(){
  return value != null ? value.getFormattedLocation() : null;
}

Fixed version (ground truth):
public String getFormattedLocation(){
  return formatted;
}
Program: 25952
Project: 25952
Buggy source:
public String getValue(){
  return value != null ? value.getValue() : null;
}

Fixed version (ground truth):
public String getValue(){
  return value;
}
Program: 25953
Project: 25953
Buggy source:
public String getState(){
  return value != null ? value.getState() : null;
}

Fixed version (ground truth):
public String getState(){
  return state;
}
Program: 25954
Project: 25954
Buggy source:
@Override public Object getPushData(){
  HashMap<String,String> data=null;
  if (value != null && value.value != null) {
    data=new HashMap<String,String>();
    data.put("String_Node_Str",value.value);
  }
  return data;
}

Fixed version (ground truth):
@Override public Object getPushData(){
  HashMap<String,String> data=null;
  if (value != null && value != null) {
    data=new HashMap<String,String>();
    data.put("String_Node_Str",value);
  }
  return data;
}
Program: 25955
Project: 25955
Buggy source:
@Override public int hashCode(){
  return this.value != null && this.value.value != null ? this.value.value.hashCode() : 0;
}

Fixed version (ground truth):
@Override public int hashCode(){
  return this.value != null && this.value != null ? this.value.hashCode() : 0;
}
Program: 25956
Project: 25956
Buggy source:
@Override public boolean equals(Object o){
  if (o instanceof MapValue) {
    MapValue other=(MapValue)o;
    if (other.value != null && other.value.value != null && this.value != null) {
      return other.value.equals(this.value.value);
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean equals(Object o){
  if (o instanceof MapValue) {
    MapValue other=(MapValue)o;
    if (other.value != null && other.value != null && this.value != null) {
      return other.value.equals(this.value);
    }
  }
  return false;
}
Program: 25957
Project: 25957
Buggy source:
public String getStreetName(){
  return value != null ? value.getStreetName() : null;
}

Fixed version (ground truth):
public String getStreetName(){
  return street_name;
}
Program: 25958
Project: 25958
Buggy source:
public String getStreetNumber(){
  return value != null ? value.getStreetNumber() : null;
}

Fixed version (ground truth):
public String getStreetNumber(){
  return street_number;
}
Program: 25959
Project: 25959
Buggy source:
public String getCity(){
  return value != null ? value.getCity() : null;
}

Fixed version (ground truth):
public String getCity(){
  return city;
}
Program: 25960
Project: 25960
Buggy source:
public String getCurrency(){
  return value != null ? value.getCurrency() : null;
}

Fixed version (ground truth):
public String getCurrency(){
  return currency;
}
Program: 25961
Project: 25961
Buggy source:
public String getValue(){
  return value != null ? value.getValue() : null;
}

Fixed version (ground truth):
public String getValue(){
  return value;
}
Program: 25962
Project: 25962
Buggy source:
@Override public Object getPushData(){
  HashMap<String,String> data=null;
  if (value != null && value.currency != null && value.value != null) {
    data=new HashMap<String,String>();
    data.put("String_Node_Str",value.currency);
    data.put("String_Node_Str",value.value);
  }
  return data;
}

Fixed version (ground truth):
@Override public Object getPushData(){
  HashMap<String,String> data=null;
  if (value != null && currency != null && value != null) {
    data=new HashMap<String,String>();
    data.put("String_Node_Str",currency);
    data.put("String_Node_Str",value);
  }
  return data;
}
Program: 25963
Project: 25963
Buggy source:
@Override public int hashCode(){
  String c=this.value.currency;
  String v=this.value.value;
  return c != null && v != null ? (c + v).hashCode() : 0;
}

Fixed version (ground truth):
@Override public int hashCode(){
  String c=currency;
  String v=value;
  return c != null && v != null ? (c + v).hashCode() : 0;
}
Program: 25964
Project: 25964
Buggy source:
@Override public boolean equals(Object o){
  if (o instanceof MoneyValue) {
    MoneyValue other=(MoneyValue)o;
    if (other.value != null && other.value.currency != null && other.value.value != null && this.value != null) {
      return other.value.currency.equals(this.value.currency) && other.value.value.equals(this.value.value);
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean equals(Object o){
  if (o instanceof MoneyValue) {
    MoneyValue other=(MoneyValue)o;
    if (other.value != null && other.currency != null && other.value != null && this.value != null) {
      return other.currency.equals(this.currency) && other.value.equals(this.value);
    }
  }
  return false;
}
Program: 25965
Project: 25965
Buggy source:
public MoneyValue(String currency,String value){
  this.value=new MoneyValue.Data(currency,value);
}

Fixed version (ground truth):
public MoneyValue(String currency,String value){
  this.currency=currency;
  this.value=value;
}
Program: 25966
Project: 25966
Buggy source:
void reportToListeners(final Handler handler,final WeakReference<T> customListener,final List<WeakReference<T>> globalListeners){
  if (handler != null) {
    handler.post(new Runnable(){
      @Override public void run(){
        boolean didConsumeEvent=false;
        if (customListener != null) {
          didConsumeEvent=executeReport(customListener);
        }
        if (!didConsumeEvent && globalListeners != null && !globalListeners.isEmpty()) {
          for (          WeakReference<T> reference : globalListeners) {
            if (reference.get() != null) {
              if (executeReport(reference)) {
                break;
              }
            }
 else {
              reference.clear();
              globalListeners.remove(reference);
            }
          }
        }
      }
    }
);
  }
}

Fixed version (ground truth):
void reportToListeners(final Handler handler,final WeakReference<T> customListener,final List<WeakReference<T>> globalListeners){
  if (handler != null) {
    handler.post(new Runnable(){
      @Override public void run(){
        boolean didConsumeEvent=false;
        if (customListener != null && customListener.get() != null) {
          didConsumeEvent=executeReport(customListener);
        }
        if (!didConsumeEvent && globalListeners != null && !globalListeners.isEmpty()) {
          for (          WeakReference<T> reference : globalListeners) {
            if (reference.get() != null) {
              if (executeReport(reference)) {
                break;
              }
            }
 else {
              reference.clear();
              globalListeners.remove(reference);
            }
          }
        }
      }
    }
);
  }
}
Program: 25967
Project: 25967
Buggy source:
@Override public void run(){
  boolean didConsumeEvent=false;
  if (customListener != null) {
    didConsumeEvent=executeReport(customListener);
  }
  if (!didConsumeEvent && globalListeners != null && !globalListeners.isEmpty()) {
    for (    WeakReference<T> reference : globalListeners) {
      if (reference.get() != null) {
        if (executeReport(reference)) {
          break;
        }
      }
 else {
        reference.clear();
        globalListeners.remove(reference);
      }
    }
  }
}

Fixed version (ground truth):
@Override public void run(){
  boolean didConsumeEvent=false;
  if (customListener != null && customListener.get() != null) {
    didConsumeEvent=executeReport(customListener);
  }
  if (!didConsumeEvent && globalListeners != null && !globalListeners.isEmpty()) {
    for (    WeakReference<T> reference : globalListeners) {
      if (reference.get() != null) {
        if (executeReport(reference)) {
          break;
        }
      }
 else {
        reference.clear();
        globalListeners.remove(reference);
      }
    }
  }
}
Program: 25968
Project: 25968
Buggy source:
private RestResult<T> getResultNow(){
  try {
    return get();
  }
 catch (  InterruptedException e) {
    throw PodioException.fromThrowable(e);
  }
catch (  ExecutionException e) {
    if (e.getCause() instanceof PodioException) {
      throw (PodioException)e.getCause();
    }
 else {
      throw PodioException.fromThrowable(e);
    }
  }
}

Fixed version (ground truth):
private RestResult<T> getResultNow(){
  try {
    return get();
  }
 catch (  InterruptedException e) {
    return null;
  }
catch (  ExecutionException e) {
    return null;
  }
}
Program: 25969
Project: 25969
Buggy source:
public static VolleyRequest newRefreshRequest(Uri uri){
  RequestFuture<String> future=RequestFuture.newFuture();
  String refreshToken=uri.getQueryParameter("String_Node_Str");
  String url=stripQueryParameters(uri);
  VolleyRequest request=new VolleyRequest(Method.POST,url,future);
  request.contentType="String_Node_Str";
  request.params.put("String_Node_Str","String_Node_Str");
  request.params.put("String_Node_Str",refreshToken);
  return request;
}

Fixed version (ground truth):
public static VolleyRequest newRefreshRequest(Uri uri){
  return newAuthRequest(uri);
}
Program: 25970
Project: 25970
Buggy source:
/** 
 * Tries to set the given value to the field with the given name on this item.
 * @param field The external id of the field.
 * @param value The field type specific domain object describing the new value.
 * @return Boolean true. Always.
 * @throws FieldTypeMismatchException If the passed value doesn't match the field with the given name.
 */
public boolean addValue(String field,Object value) throws FieldTypeMismatchException {
  if (field != null && value != null && fields != null) {
    Field f=findField(field,fields);
    if (f != null) {
      f.addValue(value);
    }
 else {
      HashMap<String,Object> newValue=new HashMap<String,Object>();
      newValue.put("String_Node_Str",value);
      List<Object> values=data.get(field);
      if (values == null) {
        values=new ArrayList<Object>();
        data.put(field,values);
      }
      values.add(data);
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Tries to set the given value to the field with the given name on this item.
 * @param field The external id of the field.
 * @param value The field type specific domain object describing the new value.
 * @return Boolean true. Always.
 * @throws FieldTypeMismatchException If the passed value doesn't match the field with the given name.
 */
public boolean addValue(String field,Object value) throws FieldTypeMismatchException {
  if (field != null && value != null && fields != null) {
    Field f=findField(field,fields);
    if (f != null) {
      f.addValue(value);
    }
 else {
      HashMap<String,Object> newValue=new HashMap<String,Object>();
      newValue.put("String_Node_Str",value);
      List<Object> values=data.get(field);
      if (values == null) {
        values=new ArrayList<Object>();
        data.put(field,values);
      }
      values.add(newValue);
    }
  }
  return true;
}
Program: 25971
Project: 25971
Buggy source:
/** 
 * Constructor.
 */
public ItemProvider(){
  filter=new ItemFilterProvider();
}

Fixed version (ground truth):
/** 
 * Constructor.
 */
public ItemProvider(){
}
Program: 25972
Project: 25972
Buggy source:
/** 
 * Initializes the Podio SDK with the given client credentials. This method MUST be called before any other request is made. The caller can then either choose to revoke a previously stored session (the SDK doesn't store or cache the session), or authenticate with user or app credentials. These operations are done in the   {@link ClientAPI} area.
 * @param context The context to initialize the cache database and network clients in.
 * @param clientId The pre-shared Podio client id.
 * @param clientSecret The corresponding Podio client secret.
 * @param behavior The behavior to expect from the  {@link RestClient} implementation.
 */
public static void setup(Context context,String clientId,String clientSecret,RestBehavior behavior){
  RestClientDelegate networkDelegate=new HttpClientDelegate(context);
  client.setup(clientId,clientSecret);
switch (behavior) {
case HTTP_ONLY:
    restClient=new HttpRestClient(context,AUTHORITY,networkDelegate);
  break;
case CACHED_HTTP:
CacheClient cacheClient=new SQLiteCacheClient(context,DATABASE_NAME,DATABASE_VERSION);
restClient=new CachedRestClient(context,AUTHORITY,networkDelegate,cacheClient);
break;
default :
restClient=new HttpRestClient(context,AUTHORITY,networkDelegate);
break;
}
application.setRestClient(restClient);
calendar.setRestClient(restClient);
item.setRestClient(restClient);
organization.setRestClient(restClient);
client.setRestClient(restClient);
user.setRestClient(restClient);
}

Fixed version (ground truth):
/** 
 * Initializes the Podio SDK with the given client credentials. This method MUST be called before any other request is made. The caller can then either choose to revoke a previously stored session (the SDK doesn't store or cache the session), or authenticate with user or app credentials. These operations are done in the   {@link ClientAPI} area.
 * @param context The context to initialize the cache database and network clients in.
 * @param clientId The pre-shared Podio client id.
 * @param clientSecret The corresponding Podio client secret.
 * @param behavior The behavior to expect from the  {@link RestClient} implementation.
 */
public static void setup(Context context,String clientId,String clientSecret,RestBehavior behavior){
  networkDelegate=new HttpClientDelegate(context);
  client.setup(clientId,clientSecret);
switch (behavior) {
case HTTP_ONLY:
    restClient=new HttpRestClient(context,AUTHORITY,networkDelegate);
  break;
case CACHED_HTTP:
CacheClient cacheClient=new SQLiteCacheClient(context,DATABASE_NAME,DATABASE_VERSION);
restClient=new CachedRestClient(context,AUTHORITY,networkDelegate,cacheClient);
break;
default :
restClient=new HttpRestClient(context,AUTHORITY,networkDelegate);
break;
}
application.setRestClient(restClient);
calendar.setRestClient(restClient);
item.setRestClient(restClient);
organization.setRestClient(restClient);
client.setRestClient(restClient);
user.setRestClient(restClient);
}
Program: 25973
Project: 25973
Buggy source:
/** 
 * Initializes the Podio SDK with the given client credentials. This method MUST be called before any other request is made. The caller can then either choose to revoke a previously stored session (the SDK doesn't store or cache the session), or authenticate with user or app credentials. These operations are done in the   {@link ClientAPI} area.
 * @param context The context to initialize the cache database and network clients in.
 * @param clientId The pre-shared Podio client id.
 * @param clientSecret The corresponding Podio client secret.
 * @param behavior The behavior to expect from the  {@link RestClient} implementation.
 */
public static void setup(Context context,String clientId,String clientSecret,RestBehavior behavior){
  RestClientDelegate networkDelegate=new HttpClientDelegate(context);
  client.setup(clientId,clientSecret);
switch (behavior) {
case HTTP_ONLY:
    Podio.restClient=new HttpRestClient(context,AUTHORITY,networkDelegate);
  break;
case CACHED_HTTP:
CacheClient cacheClient=new SQLiteCacheClient(context,DATABASE_NAME,DATABASE_VERSION);
Podio.restClient=new CachedRestClient(context,AUTHORITY,networkDelegate,cacheClient);
break;
default :
Podio.restClient=new HttpRestClient(context,AUTHORITY,networkDelegate);
break;
}
}

Fixed version (ground truth):
/** 
 * Initializes the Podio SDK with the given client credentials. This method MUST be called before any other request is made. The caller can then either choose to revoke a previously stored session (the SDK doesn't store or cache the session), or authenticate with user or app credentials. These operations are done in the   {@link ClientAPI} area.
 * @param context The context to initialize the cache database and network clients in.
 * @param clientId The pre-shared Podio client id.
 * @param clientSecret The corresponding Podio client secret.
 * @param behavior The behavior to expect from the  {@link RestClient} implementation.
 */
public static void setup(Context context,String clientId,String clientSecret,RestBehavior behavior){
  RestClientDelegate networkDelegate=new HttpClientDelegate(context);
  client.setup(clientId,clientSecret);
switch (behavior) {
case HTTP_ONLY:
    restClient=new HttpRestClient(context,AUTHORITY,networkDelegate);
  break;
case CACHED_HTTP:
CacheClient cacheClient=new SQLiteCacheClient(context,DATABASE_NAME,DATABASE_VERSION);
restClient=new CachedRestClient(context,AUTHORITY,networkDelegate,cacheClient);
break;
default :
restClient=new HttpRestClient(context,AUTHORITY,networkDelegate);
break;
}
application.setRestClient(restClient);
calendar.setRestClient(restClient);
item.setRestClient(restClient);
organization.setRestClient(restClient);
client.setRestClient(restClient);
}
Program: 25974
Project: 25974
Buggy source:
/** 
 * Reports a result back to any listeners implementation.
 * @param request The request that we are reporting the result of.
 * @param result The result of the request.
 */
protected <T>void callListener(final RestRequest<T> request,final RestResult<T> result){
  SessionListener sessionListener=request.getSessionListener();
  if (sessionListener != null) {
    Session session=result.getSession();
    sessionListener.onSessionChanged(session);
  }
  ResultListener<? super T> resultListener=request.getResultListener();
  if (resultListener != null) {
    T item=result.getItem();
    resultListener.onRequestPerformed(item);
  }
  if (result.hasException()) {
    ErrorListener errorListener=request.getErrorListener();
    if (errorListener != null) {
      PodioException error=result.getException();
      errorListener.onExceptionOccurred(error);
    }
  }
}

Fixed version (ground truth):
/** 
 * Reports a result back to any listeners implementation.
 * @param request The request that we are reporting the result of.
 * @param result The result of the request.
 */
protected <T>void callListener(final RestRequest<T> request,final RestResult<T> result){
  if (result != null) {
    SessionListener sessionListener=request.getSessionListener();
    if (sessionListener != null) {
      Session session=result.getSession();
      sessionListener.onSessionChanged(session);
    }
    ResultListener<? super T> resultListener=request.getResultListener();
    if (resultListener != null) {
      T item=result.getItem();
      resultListener.onRequestPerformed(item);
    }
    if (result.hasException()) {
      ErrorListener errorListener=request.getErrorListener();
      if (errorListener != null) {
        PodioException error=result.getException();
        errorListener.onExceptionOccurred(error);
      }
    }
  }
}
Program: 25975
Project: 25975
Buggy source:
private void authorizeRequest(String url,Map<String,String> params) throws PodioException {
  RequestFuture<String> future=RequestFuture.newFuture();
  StringRequest request=new RefreshRequest(refreshUrl,params,future);
  requestQueue.add(request);
  String resultJson=getBlockingResponse(future);
  session=new Session(resultJson);
}

Fixed version (ground truth):
private void authorizeRequest(String url,Map<String,String> params) throws PodioException {
  RequestFuture<String> future=RequestFuture.newFuture();
  StringRequest request=new RefreshRequest(url,params,future);
  requestQueue.add(request);
  String resultJson=getBlockingResponse(future);
  session=new Session(resultJson);
}
Program: 25976
Project: 25976
Buggy source:
/** 
 * Constructor.
 * @param client The rest client that will access the data.
 */
public BasicPodioProvider(RestClient client){
  if (client == null) {
    throw new NullPointerException("String_Node_Str");
  }
  this.client=client;
}

Fixed version (ground truth):
/** 
 * Constructor.
 * @param client The rest client that will access the data.
 */
public BasicPodioProvider(){
}
Program: 25977
Project: 25977
Buggy source:
public SessionProvider(RestClient client){
  super(client);
  clientId=clientSecret=null;
}

Fixed version (ground truth):
public SessionProvider(){
  clientId=clientSecret=null;
}
Program: 25978
Project: 25978
Buggy source:
/** 
 * Verifies that the   {@link ItemProvider} calls through to the (mock) restclient with expected uri parameters when trying to fetch all items for a given application. <pre> 1. Create a new ItemProvider. 2. Try to fetch all items for a known application. 3. Verify that the designated rest client is called with a uri that contains the expected parameters. </pre>
 */
public void testFetchItemsForApplication(){
  DummyRestClient mockClient=new DummyRestClient(RestResult.success());
  ItemProvider provider=new ItemProvider(mockClient);
  @SuppressWarnings("String_Node_Str") ResultListener<Item.FilterResult> mockListener=Mockito.mock(ResultListener.class);
  provider.getFiltered(4L,mockListener,null,null);
  Mockito.verify(mockListener).onRequestPerformed(null);
  Mockito.verifyNoMoreInteractions(mockListener);
  Uri uri=mockClient.getMockUri();
  assertEquals(Uri.parse("String_Node_Str"),uri);
}

Fixed version (ground truth):
/** 
 * Verifies that the   {@link ItemProvider} calls through to the (mock) restclient with expected uri parameters when trying to fetch all items for a given application. <pre> 1. Create a new ItemProvider. 2. Try to fetch all items for a known application. 3. Verify that the designated rest client is called with a uri that contains the expected parameters. </pre>
 */
public void testFetchItemsForApplication(){
  DummyRestClient mockClient=new DummyRestClient(RestResult.success());
  ItemProvider provider=new ItemProvider(mockClient);
  @SuppressWarnings("String_Node_Str") ResultListener<Item.FilterResult> mockListener=Mockito.mock(ResultListener.class);
  provider.getAll(4L,mockListener,null,null);
  Mockito.verify(mockListener).onRequestPerformed(null);
  Mockito.verifyNoMoreInteractions(mockListener);
  Uri uri=mockClient.getMockUri();
  assertEquals(Uri.parse("String_Node_Str"),uri);
}
Program: 25979
Project: 25979
Buggy source:
@Override public Object getPushData(){
  HashMap<String,String> data=null;
  if (value != null) {
    data=new HashMap<String,String>();
    data.put("String_Node_Str",value);
  }
  return data;
}

Fixed version (ground truth):
@Override public Object getPushData(){
  HashMap<String,String> data=new HashMap<String,String>();
  data.put("String_Node_Str",value);
  return data;
}
Program: 25980
Project: 25980
Buggy source:
/** 
 * Reports a result back to any listeners implementation.
 * @param request The request that we are reporting the result of.
 * @param result The result of the request.
 */
protected <T>void callListener(final RestRequest<T> request,final RestResult<T> result){
  if (result != null) {
    SessionListener sessionListener=request.getSessionListener();
    if (sessionListener != null) {
      Session session=result.getSession();
      sessionListener.onSessionChanged(session);
    }
    ResultListener<? super T> resultListener=request.getResultListener();
    if (resultListener != null) {
      T item=result.getItem();
      resultListener.onRequestPerformed(item);
    }
    if (result.hasException()) {
      ErrorListener errorListener=request.getErrorListener();
      if (errorListener != null) {
        PodioException error=result.getException();
        errorListener.onExceptionOccurred(error);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Reports a result back to any listeners implementation.
 * @param request The request that we are reporting the result of.
 * @param result The result of the request.
 */
protected <T>void callListener(final RestRequest<T> request,final RestResult<T> result){
  if (result != null) {
    if (result.hasSession()) {
      SessionListener sessionListener=request.getSessionListener();
      if (sessionListener != null) {
        Session session=result.getSession();
        sessionListener.onSessionChanged(session);
      }
    }
    if (result.hasException()) {
      ErrorListener errorListener=request.getErrorListener();
      if (errorListener != null) {
        PodioException error=result.getException();
        errorListener.onExceptionOccurred(error);
      }
    }
 else {
      ResultListener<? super T> resultListener=request.getResultListener();
      if (resultListener != null) {
        T item=result.getItem();
        resultListener.onRequestPerformed(item);
      }
    }
  }
}
Program: 25981
Project: 25981
Buggy source:
@Override public boolean equals(Object o){
  boolean isEqual=o instanceof Session;
  if (isEqual) {
    Session other=(Session)o;
    isEqual=accessToken.equals(other.accessToken) && refreshToken.equals(other.refreshToken) && expiresMillis == other.expiresMillis;
  }
  return isEqual;
}

Fixed version (ground truth):
@Override public boolean equals(Object o){
  boolean isEqual=o instanceof Session;
  if (isEqual) {
    Session other=(Session)o;
    boolean accessTokensEquals=accessToken == null && other.accessToken == null || accessToken.equals(other.accessToken);
    boolean refreshTokensEquals=refreshToken == null && other.refreshToken == null || refreshToken.equals(other.refreshToken);
    boolean timeStampsEquals=expiresMillis == other.expiresMillis;
    isEqual=accessTokensEquals && refreshTokensEquals && timeStampsEquals;
  }
  return isEqual;
}
Program: 25982
Project: 25982
Buggy source:
@Override public Object getPushData(){
  ArrayList<Object> pushData=new ArrayList<Object>();
  for (  Option option : config.settings.options) {
    if (option.isPicked) {
      pushData.add(option.getPushData());
    }
  }
  return pushData;
}

Fixed version (ground truth):
@Override public Object getPushData(){
  ArrayList<Object> pushData=new ArrayList<Object>();
  if (config != null && config.settings != null && config.settings.options != null) {
    for (    Option option : config.settings.options) {
      if (option.isPicked) {
        pushData.add(option.getPushData());
      }
    }
  }
  return pushData;
}
Program: 25983
Project: 25983
Buggy source:
@Override public boolean set(Object value) throws FieldTypeMismatchException {
  Data data=tryCast(value);
  clear(data);
  try {
    values.add(new Value(data));
  }
 catch (  UnsupportedOperationException e) {
    throw new FieldTypeMismatchException(e);
  }
catch (  ClassCastException e) {
    throw new FieldTypeMismatchException(e);
  }
catch (  IllegalArgumentException e) {
    throw new FieldTypeMismatchException(e);
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean set(Object value) throws FieldTypeMismatchException {
  boolean isSuccess=false;
  Data data=tryCast(value);
  clear(data);
  if (values != null) {
    isSuccess=values.add(new Value(data));
  }
  return isSuccess;
}
Program: 25984
Project: 25984
Buggy source:
@Override public boolean clear(Object value) throws FieldTypeMismatchException {
  Data data=tryCast(value);
  Value v=new Value(data);
  try {
    values.remove(v);
  }
 catch (  UnsupportedOperationException e) {
    throw new FieldTypeMismatchException(e);
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean clear(Object value) throws FieldTypeMismatchException {
  boolean isSuccess=false;
  Data data=tryCast(value);
  Value v=new Value(data);
  if (values != null) {
    values.remove(v);
    isSuccess=true;
  }
  return isSuccess;
}
Program: 25985
Project: 25985
Buggy source:
@Override public boolean set(Object value) throws FieldTypeMismatchException {
  Option option=tryCast(value);
  clear(option);
  try {
    values.add(new Value(option));
  }
 catch (  UnsupportedOperationException e) {
    throw new FieldTypeMismatchException(e);
  }
catch (  ClassCastException e) {
    throw new FieldTypeMismatchException(e);
  }
catch (  IllegalArgumentException e) {
    throw new FieldTypeMismatchException(e);
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean set(Object value) throws FieldTypeMismatchException {
  boolean isSuccess=false;
  Option option=tryCast(value);
  clear(option);
  if (values != null) {
    isSuccess=values.add(new Value(option));
  }
  return isSuccess;
}
Program: 25986
Project: 25986
Buggy source:
@Override public boolean clear(Object value) throws FieldTypeMismatchException {
  Option option=tryCast(value);
  Value v=new Value(option);
  try {
    values.remove(v);
  }
 catch (  UnsupportedOperationException e) {
    throw new FieldTypeMismatchException(e);
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean clear(Object value) throws FieldTypeMismatchException {
  boolean isSuccess=false;
  Option option=tryCast(value);
  Value v=new Value(option);
  if (values != null) {
    values.remove(v);
    isSuccess=true;
  }
  return isSuccess;
}
Program: 25987
Project: 25987
Buggy source:
/** 
 * Tries to locally set the given value to the current field. The changes are NOT updated on the servers by this method call.
 * @param value The value domain object to set.
 * @return Always boolean true.
 * @throws FieldTypeMismatchException If the value can't be applied to this field type.
 */
public abstract boolean set(Object value) throws FieldTypeMismatchException ;

Fixed version (ground truth):
/** 
 * Tries to locally set the given value to the current field. The changes are NOT updated on the servers by this method call.
 * @param value The value domain object to set.
 * @return Boolean true if the new value could be set, boolean falseotherwise.
 * @throws FieldTypeMismatchException If the value can't be applied to this field type.
 */
public abstract boolean set(Object value) throws FieldTypeMismatchException ;
Program: 25988
Project: 25988
Buggy source:
/** 
 * Tries to locally clear the given value from the current field. The changes are NOT updated on the servers by this method call.
 * @param value The value domain object to clear.
 * @return Always boolean true.
 * @throws FieldTypeMismatchException If the value can't be applied to this field type.
 */
public abstract boolean clear(Object value) throws FieldTypeMismatchException ;

Fixed version (ground truth):
/** 
 * Tries to locally clear the given value from the current field. The changes are NOT updated on the servers by this method call.
 * @param value The value domain object to clear.
 * @return Boolean true if the value could be cleared, boolean falseotherwise.
 * @throws FieldTypeMismatchException If the value can't be applied to this field type.
 */
public abstract boolean clear(Object value) throws FieldTypeMismatchException ;
Program: 25989
Project: 25989
Buggy source:
@Override public boolean set(Object value) throws FieldTypeMismatchException {
  String text=tryCast(value);
  values.clear();
  values.add(new Value(text));
  return true;
}

Fixed version (ground truth):
@Override public boolean set(Object value) throws FieldTypeMismatchException {
  boolean isSuccess=false;
  String text=tryCast(value);
  clear(value);
  if (values != null) {
    isSuccess=values.add(new Value(text));
  }
  return isSuccess;
}
Program: 25990
Project: 25990
Buggy source:
@Override public Object getPushData(){
  ArrayList<Object> pushData=new ArrayList<Object>();
  for (  Value value : values) {
    pushData.add(value.getPushData());
  }
  return pushData;
}

Fixed version (ground truth):
@Override public Object getPushData(){
  ArrayList<Object> pushData=new ArrayList<Object>();
  if (values != null) {
    for (    Value value : values) {
      pushData.add(value.getPushData());
    }
  }
  return pushData;
}
Program: 25991
Project: 25991
Buggy source:
/** 
 * @see com.podio.sdk.domain.field.Field#clear(java.lang.Object)
 */
@Override public boolean clear(Object value) throws FieldTypeMismatchException {
  values.clear();
  return true;
}

Fixed version (ground truth):
@Override public boolean clear(Object value) throws FieldTypeMismatchException {
  boolean isSuccess=false;
  if (values != null) {
    values.clear();
    isSuccess=true;
  }
  return isSuccess;
}
Program: 25992
Project: 25992
Buggy source:
/** 
 * Performs the parsing of the given domain model object to a json string.
 * @param item The item to parse.
 * @return A json string representation of the given item.
 */
public String parseToJson(Object item){
  String result="String_Node_Str";
  if (item != null) {
    GsonBuilder builder=new GsonBuilder();
    builder.disableHtmlEscaping();
    Gson gson=builder.create();
    result=gson.toJson(item);
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Performs the parsing of the given domain model object to a json string.
 * @param item The item to parse.
 * @return A json string representation of the given item.
 */
public String parseToJson(Object item){
  String result=null;
  if (item != null) {
    GsonBuilder builder=new GsonBuilder();
    builder.disableHtmlEscaping();
    Gson gson=builder.create();
    result=gson.toJson(item);
  }
  return result;
}
Program: 25994
Project: 25994
Buggy source:
/** 
 * Performs the parsing of the given json string to domain model representation.
 * @param json The json string to parse.
 * @return A domain model representation of the given json string.
 */
public T parseToItem(String source){
  T result=null;
  if (Utils.notEmpty(source)) {
    result=new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).registerTypeAdapter(Field.class,new FieldDeserializer()).create().fromJson(source,classOfItem);
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Performs the parsing of the given json string to domain model representation.
 * @param json The json string to parse.
 * @return A domain model representation of the given json string.
 */
public T parseToItem(String source){
  T result=null;
  if (source != null && Utils.notEmpty(source.trim())) {
    result=new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).registerTypeAdapter(Field.class,new FieldDeserializer()).create().fromJson(source,classOfItem);
  }
  return result;
}