Program: 184358
Project: 184358
Buggy source:
public static DataTask createDataTask(Task task,Context context){
  DataTask dataTask=null;
switch (task.getTaskType()) {
case AccelerometerSensor:
    long frameTime=task.getLong(AccelerometerSensor.ATT_FRAMETIME,1000);
  long duration=task.getLong(AccelerometerSensor.ATT_DURATION,500);
Sensor sensor=AccelerometerSensor.createAccelerometer(context,frameTime,duration);
if (task.getSampleFrequency() > 0) {
sensor.setSampleFrequency(task.getSampleFrequency());
}
 else if (task.getPeriodTime() > 0) {
sensor.setPeriodTime(task.getPeriodTime());
}
dataTask=new DataSource(sensor);
task.setPeriodTime(1000);
task.setSampleFrequency(-1.0f);
break;
case TimerSensor:
long period=task.getLong("String_Node_Str",1000);
TimerSensor ts=new TimerSensor(context,period);
dataTask=new DataSource(ts);
ts.addSourceTask((DataSource)dataTask);
break;
case AudioSensor:
long audioDuration=task.getLong("String_Node_Str",-1);
AudioSensor as=new AudioSensor(context,task.getSampleFrequency());
dataTask=new AudioDataSource(as,audioDuration);
as.addSourceTask((AudioDataSource)dataTask);
break;
case BluetoothSensor:
dataTask=new DataSource(new BluetoothSensor(context));
break;
case BluetoothConnectionSensor:
dataTask=new DataSource(new BluetoothConnectionSensor(context,task.getString("String_Node_Str","String_Node_Str")));
break;
case GpsSensor:
dataTask=new DataSource(new GpsSensor(context));
break;
case GyroscopeSensor:
long frameTime2=task.getLong(AccelerometerSensor.ATT_FRAMETIME,1000);
long duration2=task.getLong(AccelerometerSensor.ATT_DURATION,500);
Sensor sensor2=AccelerometerSensor.createGyroscope(context,frameTime2,duration2);
if (task.getSampleFrequency() > 0) {
sensor2.setSampleFrequency(task.getSampleFrequency());
}
 else if (task.getPeriodTime() > 0) {
sensor2.setPeriodTime(task.getPeriodTime());
}
dataTask=new DataSource(sensor2);
task.setPeriodTime(frameTime2);
task.setSampleFrequency(-1.0f);
break;
case CallSensor:
dataTask=new DataSource(new PhoneCallSensor(context));
break;
case StateSensor:
dataTask=new DataSource(new PhoneStateSensor(context));
break;
case PowerConnectionSensor:
dataTask=new DataSource(new PowerConnectionSensor(context));
break;
case NfcSensor:
dataTask=new DataSource(new NfcSensor(context));
break;
case WifiScanSensor:
dataTask=new DataSource(new WifiScanSensor(context));
break;
case WifiConnectionSensor:
dataTask=new DataSource(new WifiConnectionSensor(context));
break;
case AccelerometerMeanFilter:
dataTask=new AccelerometerMeanFilter();
break;
case DataSink:
dataTask=new DataSink(new JsonSinkWritter(context));
((DataSink)dataTask).setName(task.getName());
break;
case AudioSink:
dataTask=new AudioSink(new RawAudioSinkWritter(context));
((DataSink)dataTask).setName(task.getName());
break;
case ShakeFilter:
dataTask=new ShakeFilter();
break;
case MovementFilter:
double threshold=task.getDouble("String_Node_Str",1000);
dataTask=new MovementFilter();
((MovementFilter)dataTask).setMovementThreshold((float)threshold);
break;
case FalseTimerFilter:
long timeLength=task.getLong("String_Node_Str",1000);
String attributeName=task.getString("String_Node_Str","String_Node_Str");
dataTask=new FalseTimerFilter();
((FalseTimerFilter)dataTask).setTimeLength(timeLength);
((FalseTimerFilter)dataTask).setAttributeName(attributeName);
break;
case WifiTimeConnectedFilter:
dataTask=new WifiTimeConnectedFilter();
break;
case SurveyTrigger:
dataTask=new SurveyTrigger(context);
((SurveyTrigger)dataTask).setSurveyName("String_Node_Str");
break;
case Trigger:
String matches=task.getString(JsonTrigger.MATCHES,null);
JsonTrigger jsonTrigger=new JsonTrigger();
List<Condition> conditionsList=jsonTrigger.toConditions(task.getJsonNode());
dataTask=new GeneralTrigger(context,conditionsList,matches);
break;
case StopTrigger:
String matches2=task.getString(JsonTrigger.MATCHES,null);
JsonTrigger jsonTrigger2=new JsonTrigger();
List<Condition> conditionsList2=jsonTrigger2.toConditions(task.getJsonNode());
dataTask=new StopTrigger(context,conditionsList2,matches2);
break;
default :
return null;
}
if (task.getSampleFrequency() > 0) {
dataTask.setSampleFrequency(task.getSampleFrequency());
}
 else if (task.getPeriodTime() > 0) {
dataTask.setPeriodTime(task.getPeriodTime());
}
dataTask.setTaskType(task.getTaskType());
dataTask.setName(task.getName());
dataTask.setTriggered(task.isTriggered());
return dataTask;
}

Fixed version (ground truth):
public static DataTask createDataTask(Task task,Context context){
  DataTask dataTask=null;
switch (task.getTaskType()) {
case AccelerometerSensor:
    long frameTime=task.getLong(AccelerometerSensor.ATT_FRAMETIME,1000);
  long duration=task.getLong(AccelerometerSensor.ATT_DURATION,500);
Sensor sensor=AccelerometerSensor.createAccelerometer(context,frameTime,duration);
if (task.getSampleFrequency() > 0) {
sensor.setSampleFrequency(task.getSampleFrequency());
}
 else if (task.getPeriodTime() > 0) {
sensor.setPeriodTime(task.getPeriodTime());
}
dataTask=new DataSource(sensor);
task.setPeriodTime(1000);
task.setSampleFrequency(-1.0f);
break;
case TimerSensor:
long period=task.getLong("String_Node_Str",1000);
TimerSensor ts=new TimerSensor(context,period);
dataTask=new DataSource(ts);
ts.addSourceTask((DataSource)dataTask);
break;
case AudioSensor:
long audioDuration=task.getLong("String_Node_Str",-1);
AudioSensor as=new AudioSensor(context,task.getSampleFrequency());
dataTask=new AudioDataSource(as,audioDuration);
as.addSourceTask((AudioDataSource)dataTask);
break;
case BluetoothSensor:
dataTask=new DataSource(new BluetoothSensor(context));
break;
case BluetoothConnectionSensor:
dataTask=new DataSource(new BluetoothConnectionSensor(context,task.getString("String_Node_Str","String_Node_Str")));
break;
case GpsSensor:
dataTask=new DataSource(new GpsSensor(context));
break;
case GyroscopeSensor:
long frameTime2=task.getLong(AccelerometerSensor.ATT_FRAMETIME,1000);
long duration2=task.getLong(AccelerometerSensor.ATT_DURATION,500);
Sensor sensor2=AccelerometerSensor.createGyroscope(context,frameTime2,duration2);
if (task.getSampleFrequency() > 0) {
sensor2.setSampleFrequency(task.getSampleFrequency());
}
 else if (task.getPeriodTime() > 0) {
sensor2.setPeriodTime(task.getPeriodTime());
}
dataTask=new DataSource(sensor2);
task.setPeriodTime(frameTime2);
task.setSampleFrequency(-1.0f);
break;
case CallSensor:
dataTask=new DataSource(new PhoneCallSensor(context));
break;
case StateSensor:
dataTask=new DataSource(new PhoneStateSensor(context));
break;
case PowerConnectionSensor:
dataTask=new DataSource(new PowerConnectionSensor(context));
break;
case NfcSensor:
dataTask=new DataSource(new NfcSensor(context));
break;
case WifiScanSensor:
dataTask=new DataSource(new WifiScanSensor(context));
break;
case WifiConnectionSensor:
dataTask=new DataSource(new WifiConnectionSensor(context));
break;
case AccelerometerMeanFilter:
dataTask=new AccelerometerMeanFilter();
break;
case DataSink:
dataTask=new DataSink(new JsonSinkWritter(context));
((DataSink)dataTask).setName(task.getName());
break;
case AudioSink:
dataTask=new AudioSink(new RawAudioSinkWritter(context));
((DataSink)dataTask).setName(task.getName());
break;
case ShakeFilter:
dataTask=new ShakeFilter();
break;
case MovementFilter:
double threshold=task.getDouble("String_Node_Str",1000);
dataTask=new MovementFilter();
((MovementFilter)dataTask).setMovementThreshold((float)threshold);
break;
case FalseTimerFilter:
long timeLength=task.getLong("String_Node_Str",1000);
String attributeName=task.getString("String_Node_Str","String_Node_Str");
dataTask=new FalseTimerFilter();
((FalseTimerFilter)dataTask).setTimeLength(timeLength);
((FalseTimerFilter)dataTask).setAttributeName(attributeName);
break;
case MovementTimeFilter:
long maxNoInput=task.getLong("String_Node_Str",30000L);
long maxNoMovement=task.getLong("String_Node_Str",5000L);
dataTask=new MovementTimeFilter();
((MovementTimeFilter)dataTask).setMaxNoInput(maxNoInput);
((MovementTimeFilter)dataTask).setMaxNoMovement(maxNoMovement);
break;
case WifiTimeConnectedFilter:
dataTask=new WifiTimeConnectedFilter();
break;
case SurveyTrigger:
dataTask=new SurveyTrigger(context);
((SurveyTrigger)dataTask).setSurveyName("String_Node_Str");
break;
case Trigger:
String matches=task.getString(JsonTrigger.MATCHES,null);
JsonTrigger jsonTrigger=new JsonTrigger();
List<Condition> conditionsList=jsonTrigger.toConditions(task.getJsonNode());
dataTask=new GeneralTrigger(context,conditionsList,matches);
break;
case StopTrigger:
String matches2=task.getString(JsonTrigger.MATCHES,null);
JsonTrigger jsonTrigger2=new JsonTrigger();
List<Condition> conditionsList2=jsonTrigger2.toConditions(task.getJsonNode());
dataTask=new StopTrigger(context,conditionsList2,matches2);
break;
default :
return null;
}
if (task.getSampleFrequency() > 0) {
dataTask.setSampleFrequency(task.getSampleFrequency());
}
 else if (task.getPeriodTime() > 0) {
dataTask.setPeriodTime(task.getPeriodTime());
}
dataTask.setTaskType(task.getTaskType());
dataTask.setName(task.getName());
dataTask.setTriggered(task.isTriggered());
return dataTask;
}