nus-yam/ex-repair huggingface dataset:
Program: 180167
Project: 180167
Buggy source:
public static BundleContext getContext(){
  return context;
}

Fixed version (ground truth):
/** 
 * @return BundleContext
 */
public static BundleContext getContext(){
  return context;
}
Program: 180168
Project: 180168
Buggy source:
public WSHtmlServlet(BundleContext context,Hashtable servicesMap,ConfigurationAdmin configAdmin){
  super(context,servicesMap,configAdmin);
}

Fixed version (ground truth):
/** 
 * @param context <String, PublicWSProvider>
 * @param servicesMap map of services
 * @param configAdmin instance of ConfigAdmin
 */
public WSHtmlServlet(BundleContext context,Map<String,PublicWSProvider> servicesMap,ConfigurationAdmin configAdmin){
  super(context,servicesMap,configAdmin);
}
Program: 180169
Project: 180169
Buggy source:
private String getRequestInfo(PublicWSProvider pubService,PublicWSDefinition def,String reqType){
  String out="String_Node_Str" + reqType + "String_Node_Str"+ "String_Node_Str"+ def.getReturnType()+ "String_Node_Str";
  if (def.getParameters() != null)   out+="String_Node_Str" + def.getParameters().toString();
  out+="String_Node_Str";
  return out;
}

Fixed version (ground truth):
/** 
 * @param pubService PublicWSProvider
 * @param def PublicWSDefinition
 * @param reqType request type
 * @return request info
 */
private String getRequestInfo(PublicWSProvider pubService,PublicWSDefinition def,String reqType){
  String out="String_Node_Str" + reqType + "String_Node_Str"+ "String_Node_Str"+ def.getReturnType()+ "String_Node_Str";
  if (def.getParameters() != null)   out+="String_Node_Str" + def.getParameters().toString();
  out+="String_Node_Str";
  return out;
}
Program: 180171
Project: 180171
Buggy source:
/** 
 * @param context BundleContext used to load extensions contributed by bundles.
 * @return The BMIDevices attached at the time of the call.  If a given array element is null, no module is attached to that slot.
 * @throws IOException IOException on File I/O error
 */
public static BMIDevice[] getDevices(BundleContext context) throws IOException {
  BMIDevice[] devs=new BMIDevice[BMIDevice.MAX_BMI_SLOTS];
  for (int i=0; i < BMIDevice.MAX_BMI_SLOTS; ++i) {
    File prodFile=getBMIDeviceRoot(i);
    if (!validBMIDeviceRoot(prodFile)) {
      devs[i]=null;
      continue;
    }
    devs[i]=BMIDevice.createFromSYSDirectory(context,prodFile,i);
  }
  return devs;
}

Fixed version (ground truth):
/** 
 * @param context BundleContext used to load extensions contributed by bundles.
 * @return The BMIDevices attached at the time of the call.  If a given array element is null, no module is attached to that slot.
 * @throws IOException IOException on File I/O error
 */
public static BMIDevice[] getDevices(BundleContext context) throws IOException {
  BMIDevice[] devs=new BMIDevice[BMIDevice.MAX_BMI_SLOTS];
  for (int i=0; i < BMIDevice.MAX_BMI_SLOTS; ++i) {
    File prodFile=getBMIDeviceRoot(i);
    if (prodFile == null) {
      devs[i]=null;
      continue;
    }
    devs[i]=BMIDevice.createFromSYSDirectory(context,prodFile,i);
  }
  return devs;
}
Program: 180172
Project: 180172
Buggy source:
/** 
 * @param i slot index
 * @return valid directory of BMI device root
 * @throws IOException 
 */
private static File getBMIDeviceRoot(int i) throws IOException {
  File root=new File("String_Node_Str" + i + "String_Node_Str"+ i);
  if (!root.exists() || root.isFile())   throw new IOException("String_Node_Str" + root);
  return root;
}

Fixed version (ground truth):
/** 
 * @param i slot index
 * @return valid directory of BMI device root
 * @throws IOException 
 */
private static File getBMIDeviceRoot(int i) throws IOException {
  File root=new File("String_Node_Str".replace("String_Node_Str","String_Node_Str" + i));
  if (!root.exists() || root.isFile() || root.listFiles().length == 0)   return null;
  return root;
}
Program: 180173
Project: 180173
Buggy source:
/** 
 * @param device sysfs device
 */
public BMIModuleEvent(BMIDevice device){
  this.moduleId=device.getProductId();
  this.version="String_Node_Str" + device.getRevision();
  this.slot=device.getSlot();
  this.event=EVENT_TYPE.INSERT;
}

Fixed version (ground truth):
/** 
 * @param device sysfs device
 */
public BMIModuleEvent(BMIDevice device){
  this.bmiDevice=device;
  this.moduleId=device.getProductId();
  this.version="String_Node_Str" + device.getRevision();
  this.slot=device.getSlot();
  this.event=EVENT_TYPE.INSERT;
}
Program: 180174
Project: 180174
Buggy source:
/** 
 * See http://lurcher/wiki/BMI_-_Runtime_Interface#Message_Definition.
 * @return true if parse successful
 * @throws IOException on File I/O error
 */
public boolean parse() throws IOException {
  String[] toks=raw.split("String_Node_Str");
  if (toks.length != 4) {
    return false;
  }
  this.moduleId=toks[0].trim();
  this.version=toks[1].trim();
  try {
    this.slot=Integer.parseInt(toks[2]);
  }
 catch (  NumberFormatException e) {
    return false;
  }
  String action=toks[3].trim().toUpperCase();
  if (action.equals("String_Node_Str")) {
    this.event=EVENT_TYPE.INSERT;
    this.bmiDevice=BMIDeviceHelper.getDevice(Activator.getContext(),slot);
  }
 else   if (action.equals("String_Node_Str")) {
    this.event=EVENT_TYPE.REMOVE;
  }
 else {
    return false;
  }
  return true;
}

Fixed version (ground truth):
/** 
 * See http://lurcher/wiki/BMI_-_Runtime_Interface#Message_Definition.
 * @return true if parse successful
 * @throws IOException on File I/O error
 */
private boolean parse() throws IOException {
  String[] toks=raw.split("String_Node_Str");
  if (toks.length != 4) {
    return false;
  }
  this.moduleId=toks[0].trim();
  this.version=toks[1].trim();
  try {
    this.slot=Integer.parseInt(toks[2]);
  }
 catch (  NumberFormatException e) {
    return false;
  }
  String action=toks[3].trim().toUpperCase();
  if (action.equals("String_Node_Str")) {
    this.event=EVENT_TYPE.INSERT;
    this.bmiDevice=BMIDeviceHelper.getDevice(Activator.getContext(),slot);
  }
 else   if (action.equals("String_Node_Str")) {
    this.event=EVENT_TYPE.REMOVE;
  }
 else {
    return false;
  }
  return true;
}
Program: 180175
Project: 180175
Buggy source:
public void run(){
  logService.log(LogService.LOG_INFO,"String_Node_Str" + pipeFilename);
  while (!Thread.currentThread().isInterrupted()) {
    try {
      BufferedReader reader=new BufferedReader(new FileReader(pipeFilename));
      String line=null;
      while ((line=reader.readLine()) != null) {
        if (line.equals(POISON_PILL)) {
          return;
        }
        if (logService != null) {
          logService.log(LogService.LOG_DEBUG,"String_Node_Str" + line);
        }
        BMIModuleEvent m=new BMIModuleEvent(line);
        if (m.parse()) {
          eventHandler.handleEvent(m);
        }
 else {
          logService.log(LogService.LOG_ERROR,"String_Node_Str" + line);
        }
      }
    }
 catch (    FileNotFoundException e) {
      logService.log(LogService.LOG_ERROR,e.getMessage());
    }
catch (    IOException e) {
      logService.log(LogService.LOG_ERROR,e.getMessage());
    }
 finally {
      IOUtils.closeQuietly(stream);
    }
  }
}

Fixed version (ground truth):
public void run(){
  logService.log(LogService.LOG_INFO,"String_Node_Str" + pipeFilename);
  while (!Thread.currentThread().isInterrupted()) {
    try {
      BufferedReader reader=new BufferedReader(new FileReader(pipeFilename));
      String line=null;
      while ((line=reader.readLine()) != null) {
        if (line.equals(POISON_PILL)) {
          return;
        }
        if (logService != null) {
          logService.log(LogService.LOG_DEBUG,"String_Node_Str" + line);
        }
        try {
          BMIModuleEvent m=new BMIModuleEvent(line);
          eventHandler.handleEvent(m);
        }
 catch (        IOException e) {
          logService.log(LogService.LOG_ERROR,"String_Node_Str" + line);
        }
      }
    }
 catch (    FileNotFoundException e) {
      logService.log(LogService.LOG_ERROR,e.getMessage());
    }
catch (    IOException e) {
      logService.log(LogService.LOG_ERROR,e.getMessage());
    }
 finally {
      IOUtils.closeQuietly(stream);
    }
  }
}
Program: 180176
Project: 180176
Buggy source:
public void setup() throws Exception {
  String devnode_gps="String_Node_Str" + Integer.toString(getSlotId());
  String devnode_gpscontrol="String_Node_Str" + Integer.toString(getSlotId());
  GPS gps=new GPS();
  CharDeviceUtils.openDeviceWithRetry(gps,devnode_gps,FCNTL_H.O_RDWR | FCNTL_H.O_NONBLOCK,2);
  int result=gps.init();
  if (result < 0) {
    throw new RuntimeException("String_Node_Str" + devnode_gpscontrol);
  }
  gpsControl=new GPSControl();
  getLog().log(LogService.LOG_DEBUG,"String_Node_Str" + devnode_gpscontrol);
  CharDeviceUtils.openDeviceWithRetry(gpsControl,devnode_gpscontrol,2);
  gps.close();
  getLog().log(LogService.LOG_DEBUG,"String_Node_Str" + devnode_gps);
  gpsInputStream=new FileInputStream(devnode_gps);
  nmeaProvider=new NMEASentenceProvider(gpsInputStream,context);
}

Fixed version (ground truth):
public void setup() throws Exception {
  String devnode_gps="String_Node_Str" + Integer.toString(getSlotId());
  String devnode_gpscontrol="String_Node_Str" + Integer.toString(getSlotId());
  GPS gps=new GPS();
  CharDeviceUtils.openDeviceWithRetry(gps,devnode_gps,FCNTL_H.O_RDWR | FCNTL_H.O_NONBLOCK,2);
  int result=gps.init();
  if (result < 0) {
    throw new RuntimeException("String_Node_Str" + devnode_gpscontrol);
  }
  gpsControl=new GPSControl();
  getLog().log(LogService.LOG_DEBUG,"String_Node_Str" + devnode_gpscontrol);
  CharDeviceUtils.openDeviceWithRetry(gpsControl,devnode_gpscontrol,2);
  gps.close();
  getLog().log(LogService.LOG_DEBUG,"String_Node_Str" + devnode_gps);
  gpsInputStream=new FileInputStream(devnode_gps);
  nmeaProvider=new NMEASentenceProvider(gpsInputStream,context,getLog());
}
Program: 180177
Project: 180177
Buggy source:
private void notifySubscribers(AbstractNMEASentence objSentence){
  if (subscribers == null || subscribers.size() == 0) {
    return;
  }
synchronized (subscribers) {
    for (Iterator i=subscribers.iterator(); i.hasNext(); ) {
      Object subscriber=i.next();
      try {
        if (subscriber instanceof INMEASentenceSubscriber) {
          INMEASentenceSubscriber sub=(INMEASentenceSubscriber)subscriber;
          sub.sentenceReceived(objSentence);
        }
 else         if (subscriber instanceof IPositionSubscriber && objSentence instanceof RMC) {
          IPositionSubscriber sub=(IPositionSubscriber)subscriber;
          sub.positionUpdate(calculatePosition((RMC)objSentence));
        }
      }
 catch (      RuntimeException e) {
        LogServiceUtil.logBundleException(log,"String_Node_Str",e);
      }
    }
  }
}

Fixed version (ground truth):
private void notifySubscribers(AbstractNMEASentence objSentence){
  if (subscribers == null || subscribers.size() == 0) {
    return;
  }
synchronized (subscribers) {
    for (Iterator<Object> i=subscribers.iterator(); i.hasNext(); ) {
      Object subscriber=i.next();
      try {
        if (subscriber instanceof INMEASentenceSubscriber) {
          INMEASentenceSubscriber sub=(INMEASentenceSubscriber)subscriber;
          sub.sentenceReceived(objSentence);
        }
 else         if (subscriber instanceof IPositionSubscriber && objSentence instanceof RMC) {
          IPositionSubscriber sub=(IPositionSubscriber)subscriber;
          sub.positionUpdate(calculatePosition((RMC)objSentence));
        }
      }
 catch (      RuntimeException e) {
        LogServiceUtil.logBundleException(log,"String_Node_Str",e);
      }
    }
  }
}
Program: 180178
Project: 180178
Buggy source:
public void serviceChanged(ServiceEvent event){
switch (event.getType()) {
case ServiceEvent.REGISTERED:
    if (subscribers == null) {
      subscribers=new ArrayList();
    }
  subscribers.add(context.getService(event.getServiceReference()));
break;
case ServiceEvent.UNREGISTERING:
if (subscribers != null) subscribers.remove(context.getService(event.getServiceReference()));
break;
}
}

Fixed version (ground truth):
public void serviceChanged(ServiceEvent event){
switch (event.getType()) {
case ServiceEvent.REGISTERED:
    if (subscribers == null) {
      subscribers=new ArrayList<Object>();
    }
  subscribers.add(context.getService(event.getServiceReference()));
break;
case ServiceEvent.UNREGISTERING:
if (subscribers != null) subscribers.remove(context.getService(event.getServiceReference()));
break;
}
}
Program: 180179
Project: 180179
Buggy source:
public NMEASentenceProvider(InputStream nmeaStream,BundleContext context){
  this.nmeaStream=nmeaStream;
  this.context=context;
  this.log=LogServiceUtil.getLogService(context);
  if (context.getProperty(SLEEP_INTERVAL_PROPERTY_KEY) == null) {
    readSleepInterval=DEFAULT_SLEEP_INTERVAL;
  }
 else {
    readSleepInterval=Integer.parseInt(context.getProperty(SLEEP_INTERVAL_PROPERTY_KEY));
  }
}

Fixed version (ground truth):
public NMEASentenceProvider(InputStream nmeaStream,BundleContext context,LogService log){
  this.nmeaStream=nmeaStream;
  this.context=context;
  this.log=log;
  if (context.getProperty(SLEEP_INTERVAL_PROPERTY_KEY) == null) {
    readSleepInterval=DEFAULT_SLEEP_INTERVAL;
  }
 else {
    readSleepInterval=Integer.parseInt(context.getProperty(SLEEP_INTERVAL_PROPERTY_KEY));
  }
}
Program: 180181
Project: 180181
Buggy source:
/** 
 * Discover attached BMI devices and send INSERT events into system.
 * @throws IOException on File I/O error
 */
private void coldPlug() throws IOException {
  List<BMIDevice> devices=Arrays.asList(BMIDeviceHelper.getDevices(context));
  if (devices != null) {
    logService.log(LogService.LOG_DEBUG,"String_Node_Str");
    for (    BMIDevice bmiMessage : devices) {
      logService.log(LogService.LOG_DEBUG,"String_Node_Str" + bmiMessage.toString());
      eventHandler.handleEvent(new BMIModuleEvent(bmiMessage));
    }
  }
 else {
    logService.log(LogService.LOG_DEBUG,"String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Discover attached BMI devices and send INSERT events into system.
 * @throws IOException on File I/O error
 */
private void coldPlug() throws IOException {
  List<BMIDevice> devices=Arrays.asList(BMIDeviceHelper.getDevices(context));
  if (devices != null) {
    logService.log(LogService.LOG_DEBUG,"String_Node_Str");
    for (    BMIDevice bmiMessage : devices) {
      if (bmiMessage != null) {
        logService.log(LogService.LOG_DEBUG,"String_Node_Str" + bmiMessage.toString());
        eventHandler.handleEvent(new BMIModuleEvent(bmiMessage));
      }
    }
  }
 else {
    logService.log(LogService.LOG_DEBUG,"String_Node_Str");
  }
}
Program: 180182
Project: 180182
Buggy source:
public void start() throws Exception {
  Dictionary modProperties=getCommonProperties();
  modProperties.put("String_Node_Str",suspended ? "String_Node_Str" : "String_Node_Str");
  moduleRef=context.registerService(IModuleControl.class.getName(),this,modProperties);
  registerService(IModuleLEDController.class.getName(),this,createExgtendedServiceProperties());
  ML8953AccelerometerImplementation ml8953Control=new ML8953AccelerometerImplementation();
  registerService(IML8953Accelerometer.class.getName(),ml8953Control,modProperties);
  registerService(PublicWSProvider.class.getName(),new AccelerationWS(ml8953Control,getLog()),modProperties);
  registerService(ILCDModuleControl.class.getName(),this,createExgtendedServiceProperties());
  registerService(IModuleDisplay.class.getName(),LCDModlet.this,createExgtendedServiceProperties());
}

Fixed version (ground truth):
public void start() throws Exception {
  Dictionary modProperties=getCommonProperties();
  modProperties.put("String_Node_Str",suspended ? "String_Node_Str" : "String_Node_Str");
  moduleRef=context.registerService(IModuleControl.class.getName(),this,modProperties);
  ML8953AccelerometerImplementation ml8953Control=new ML8953AccelerometerImplementation();
  registerService(IML8953Accelerometer.class.getName(),ml8953Control,modProperties);
  registerService(PublicWSProvider.class.getName(),new AccelerationWS(ml8953Control,getLog()),modProperties);
  registerService(ILCDModuleControl.class.getName(),this,createExtendedServiceProperties());
  registerService(IModuleDisplay.class.getName(),LCDModlet.this,createExtendedServiceProperties());
}
Program: 180183
Project: 180183
Buggy source:
private void registerService(ServiceReference sr,int eventType){
  IModletFactory factory=(IModletFactory)context.getService(sr);
  validateFactory(factory);
switch (eventType) {
case ServiceEvent.REGISTERED:
    if (!modletFactories.containsKey(factory.getModuleId())) {
      modletFactories.put(factory.getModuleId(),new ArrayList<IModletFactory>());
    }
 else {
      logService.log(LogService.LOG_WARNING,"String_Node_Str" + factory.getName() + "String_Node_Str");
      return;
    }
  List<IModletFactory> ml=modletFactories.get(factory.getModuleId());
if (!ml.contains(factory)) {
  ml.add(factory);
}
logService.log(LogService.LOG_INFO,"String_Node_Str" + factory.getName() + "String_Node_Str"+ factory.getModuleId()+ "String_Node_Str");
if (context.getProperty("String_Node_Str") != null && context.getProperty("String_Node_Str").equals("String_Node_Str")) {
try {
createModlets(factory);
}
 catch (Exception e) {
logService.log(LogService.LOG_ERROR,"String_Node_Str" + e.getMessage());
}
}
break;
case ServiceEvent.UNREGISTERING:
if (modletFactories.containsKey(factory.getModuleId())) {
modletFactories.get(factory.getModuleId()).remove(factory);
logService.log(LogService.LOG_DEBUG,"String_Node_Str" + factory.getName() + "String_Node_Str");
}
 else {
logService.log(LogService.LOG_ERROR,"String_Node_Str" + factory.getModuleId());
}
break;
default :
logService.log(LogService.LOG_ERROR,"String_Node_Str" + eventType);
}
}

Fixed version (ground truth):
/** 
 * @param sr ServiceReference
 * @param eventType type of event
 */
private void registerService(ServiceReference sr,int eventType){
  IModletFactory factory=(IModletFactory)context.getService(sr);
  validateFactory(factory);
switch (eventType) {
case ServiceEvent.REGISTERED:
    if (!modletFactories.containsKey(factory.getModuleId())) {
      modletFactories.put(factory.getModuleId(),new ArrayList<IModletFactory>());
    }
 else {
      logService.log(LogService.LOG_WARNING,"String_Node_Str" + factory.getName() + "String_Node_Str");
      return;
    }
  List<IModletFactory> ml=modletFactories.get(factory.getModuleId());
if (!ml.contains(factory)) {
  ml.add(factory);
}
logService.log(LogService.LOG_INFO,"String_Node_Str" + factory.getName() + "String_Node_Str"+ factory.getModuleId()+ "String_Node_Str");
if (context.getProperty("String_Node_Str") != null && context.getProperty("String_Node_Str").equals("String_Node_Str")) {
try {
createModlets(factory);
}
 catch (Exception e) {
logService.log(LogService.LOG_ERROR,"String_Node_Str" + e.getMessage());
}
}
break;
case ServiceEvent.UNREGISTERING:
if (modletFactories.containsKey(factory.getModuleId())) {
modletFactories.get(factory.getModuleId()).remove(factory);
logService.log(LogService.LOG_DEBUG,"String_Node_Str" + factory.getName() + "String_Node_Str");
}
 else {
logService.log(LogService.LOG_ERROR,"String_Node_Str" + factory.getModuleId());
}
break;
default :
logService.log(LogService.LOG_ERROR,"String_Node_Str" + eventType);
}
}
Program: 180184
Project: 180184
Buggy source:
public void start(BundleContext context) throws Exception {
  this.context=context;
  modletFactories=new Hashtable<String,List<IModletFactory>>();
  activeModlets=new Hashtable<String,List<IModlet>>();
  logService=LogServiceUtil.getLogService(context);
  context.addServiceListener(this,FilterUtil.generateServiceFilter(IModletFactory.class.getName()));
  registerExistingServices();
  pipeFilename=context.getProperty(PIPE_FILENAME_KEY);
  if (pipeFilename == null || pipeFilename.length() == 0)   pipeFilename=DEFAULT_PIPE_FILENAME;
  createPipe(pipeFilename);
  eventHandler=new BMIModuleEventHandler(context,logService,modletFactories,activeModlets);
  pipeReader=new PipeReader(pipeFilename,eventHandler,logService);
  coldPlug();
  pipeReader.start();
}

Fixed version (ground truth):
public void start(BundleContext context) throws Exception {
  Activator.context=context;
  modletFactories=new Hashtable<String,List<IModletFactory>>();
  activeModlets=new Hashtable<String,List<IModlet>>();
  logService=LogServiceUtil.getLogService(context);
  context.addServiceListener(this,FilterUtil.generateServiceFilter(IModletFactory.class.getName()));
  registerExistingServices();
  pipeFilename=context.getProperty(PIPE_FILENAME_KEY);
  if (pipeFilename == null || pipeFilename.length() == 0)   pipeFilename=DEFAULT_PIPE_FILENAME;
  createPipe(pipeFilename);
  eventHandler=new BMIModuleEventHandler(context,logService,modletFactories,activeModlets);
  pipeReader=new PipeReader(pipeFilename,eventHandler,logService);
  context.addFrameworkListener(this);
}
Program: 180185
Project: 180185
Buggy source:
public static BundleContext getContext(){
  return context;
}

Fixed version (ground truth):
/** 
 * @return BundleContext
 */
public static BundleContext getContext(){
  return context;
}
Program: 180187
Project: 180187
Buggy source:
/** 
 * @return true if device was successfully suspended, false otherwise.
 * @throws IOException 
 */
public void suspend() throws IOException {
  println(new File(root,SUSPEND_FILENAME),"String_Node_Str");
}

Fixed version (ground truth):
/** 
 * @throws IOException 
 */
public void suspend() throws IOException {
  println(new File(root,SUSPEND_FILENAME),"String_Node_Str");
}
Program: 180188
Project: 180188
Buggy source:
/** 
 * @return true if device was successfully resumed, false otherwise.
 * @throws IOException 
 */
public void resume() throws IOException {
  println(new File(root,SUSPEND_FILENAME),"String_Node_Str");
}

Fixed version (ground truth):
/** 
 * @throws IOException 
 */
public void resume() throws IOException {
  println(new File(root,SUSPEND_FILENAME),"String_Node_Str");
}
Program: 180189
Project: 180189
Buggy source:
/** 
 * Create an instance of BMIModuleProperties class using the base BMI /sys filesystem directory, for example /sys/devices/conn-m1.
 * @param directory of BMI sysfs entry
 * @param slot slot index
 * @return BMIDevice
 */
protected static BMIDevice createFromSYSDirectory(final BundleContext context,File directory,int slot){
  if (directory == null || !directory.exists() || !directory.isDirectory()) {
    return null;
  }
  final String productId=parseHexInt(getFirstLineofFile(new File(directory,"String_Node_Str")));
  BMIDeviceNodeFactory factory;
  try {
    factory=Fn.find(new Fn.Function<ServiceReference,BMIDeviceNodeFactory>(){
      @Override public BMIDeviceNodeFactory apply(      ServiceReference element){
        if (element.getProperty("String_Node_Str") != null && element.getProperty("String_Node_Str").equals(productId))         return (BMIDeviceNodeFactory)context.getService(element);
        return null;
      }
    }
,context.getAllServiceReferences(BMIDeviceNodeFactory.class.getName(),null));
    if (factory != null)     return factory.createBMIDeviceNode(directory,slot);
  }
 catch (  InvalidSyntaxException e) {
  }
  return new BMIDevice(directory,slot);
}

Fixed version (ground truth):
/** 
 * Create an instance of BMIModuleProperties class using the base BMI /sys filesystem directory, for example /sys/devices/conn-m1.
 * @param directory of BMI sysfs entry
 * @param slot slot index
 * @return BMIDevice
 */
protected static BMIDevice createFromSYSDirectory(final BundleContext context,File directory,int slot){
  if (directory == null || !directory.exists() || !directory.isDirectory()) {
    return null;
  }
  final String productId=parseHexInt(getFirstLineofFile(new File(directory,"String_Node_Str")));
  BMIDeviceNodeFactory factory;
  try {
    factory=Fn.find(new Fn.Function<ServiceReference,BMIDeviceNodeFactory>(){
      @Override public BMIDeviceNodeFactory apply(      ServiceReference element){
        if (element.getProperty("String_Node_Str") != null && element.getProperty("String_Node_Str").equals(productId))         return (BMIDeviceNodeFactory)context.getService(element);
        return null;
      }
    }
,context.getServiceReferences(BMIDeviceNodeFactory.class.getName(),null));
    if (factory != null)     return factory.createBMIDeviceNode(directory,slot);
  }
 catch (  InvalidSyntaxException e) {
  }
  return new BMIDevice(directory,slot);
}
Program: 180190
Project: 180190
Buggy source:
public void setup() throws Exception {
  this.videoOutDevice=(VideoOutBMIDevice)BMIDeviceHelper.getDevice(context,slotId);
}

Fixed version (ground truth):
public void setup() throws Exception {
  this.videoOutDevice=(VideoOutBMIDevice)BMIDeviceHelper.getDevice(slotId);
}
Program: 180191
Project: 180191
Buggy source:
public VideoModlet(BundleContext context,int slotId,String moduleId,BMIModuleProperties properties){
  this.context=context;
  this.slotId=slotId;
  this.moduleId=moduleId;
  this.properties=properties;
  this.moduleName="String_Node_Str";
  this.log=LogServiceUtil.getLogService(context);
  System.out.println("String_Node_Str");
  this.videoOutDevice=(VideoOutDevice)BMIDeviceHelper.getDevice(slotId);
}

Fixed version (ground truth):
public VideoModlet(BundleContext context,int slotId,String moduleId,BMIModuleProperties properties){
  this.context=context;
  this.slotId=slotId;
  this.moduleId=moduleId;
  this.properties=properties;
  this.moduleName="String_Node_Str";
  this.log=LogServiceUtil.getLogService(context);
  System.out.println("String_Node_Str");
}
Program: 180192
Project: 180192
Buggy source:
public void setup() throws Exception {
}

Fixed version (ground truth):
public void setup() throws Exception {
  this.videoOutDevice=(VideoOutDevice)BMIDeviceHelper.getDevice(slotId);
}
Program: 180193
Project: 180193
Buggy source:
static BundleContext getContext(){
  return context;
}

Fixed version (ground truth):
public static BundleContext getContext(){
  return context;
}
Program: 180194
Project: 180194
Buggy source:
public ModuleServlet(){
  this.modules=new IModuleControl[4];
  for (int i=0; i < modules.length; ++i)   modules[i]=null;
}

Fixed version (ground truth):
public ModuleServlet(){
  context=Activator.getContext();
  this.modules=new IModuleControl[4];
  for (int i=0; i < modules.length; ++i)   modules[i]=null;
}
Program: 180195
Project: 180195
Buggy source:
@Override public void serviceChanged(ServiceEvent event){
  IModuleControl imc=(IModuleControl)event.getSource();
  if (event.getType() == ServiceEvent.REGISTERED) {
    if (modules[imc.getSlotId()] != null)     Activator.getLog().log(LogService.LOG_WARNING,"String_Node_Str");
    modules[imc.getSlotId()]=imc;
  }
 else   if (event.getType() == ServiceEvent.UNREGISTERING) {
    modules[imc.getSlotId()]=null;
  }
}

Fixed version (ground truth):
@Override public void serviceChanged(ServiceEvent event){
  IModuleControl imc=(IModuleControl)context.getService(event.getServiceReference());
  if (event.getType() == ServiceEvent.REGISTERED) {
    if (modules[imc.getSlotId()] != null)     Activator.getLog().log(LogService.LOG_WARNING,"String_Node_Str");
    modules[imc.getSlotId()]=imc;
  }
 else   if (event.getType() == ServiceEvent.UNREGISTERING) {
    modules[imc.getSlotId()]=null;
  }
}
Program: 180196
Project: 180196
Buggy source:
/** 
 * Create an instance of BMIModuleProperties class using the base BMI /sys filesystem directory, for example /sys/devices/conn-m1.
 * @param directory of BMI sysfs entry
 * @param slot slot index
 * @return BMIDevice
 */
protected static BMIDevice createFromSYSDirectory(final BundleContext context,File directory,int slot){
  if (directory == null || !directory.exists() || !directory.isDirectory()) {
    return null;
  }
  final String productId=parseHexInt(getFirstLineofFile(new File(directory,"String_Node_Str")));
  BMIDeviceNodeFactory factory;
  try {
    factory=Fn.find(new Fn.Function<ServiceReference,BMIDeviceNodeFactory>(){
      @Override public BMIDeviceNodeFactory apply(      ServiceReference element){
        if (element.getProperty("String_Node_Str") != null && element.getProperty("String_Node_Str").equals(productId))         return context.getService(element);
        return null;
      }
    }
,context.getAllServiceReferences(BMIDeviceNodeFactory.class.getName(),null));
    if (factory != null)     return factory.createBMIDeviceNode(directory,slot);
  }
 catch (  InvalidSyntaxException e) {
  }
  return new BMIDevice(directory,slot);
}

Fixed version (ground truth):
/** 
 * Create an instance of BMIModuleProperties class using the base BMI /sys filesystem directory, for example /sys/devices/conn-m1.
 * @param directory of BMI sysfs entry
 * @param slot slot index
 * @return BMIDevice
 */
protected static BMIDevice createFromSYSDirectory(final BundleContext context,File directory,int slot){
  if (directory == null || !directory.exists() || !directory.isDirectory()) {
    return null;
  }
  final String productId=parseHexInt(getFirstLineofFile(new File(directory,"String_Node_Str")));
  BMIDeviceNodeFactory factory;
  try {
    factory=Fn.find(new Fn.Function<ServiceReference,BMIDeviceNodeFactory>(){
      @Override public BMIDeviceNodeFactory apply(      ServiceReference element){
        if (element.getProperty("String_Node_Str") != null && element.getProperty("String_Node_Str").equals(productId))         return (BMIDeviceNodeFactory)context.getService(element);
        return null;
      }
    }
,context.getAllServiceReferences(BMIDeviceNodeFactory.class.getName(),null));
    if (factory != null)     return factory.createBMIDeviceNode(directory,slot);
  }
 catch (  InvalidSyntaxException e) {
  }
  return new BMIDevice(directory,slot);
}
Program: 180197
Project: 180197
Buggy source:
@Override public BMIDeviceNodeFactory apply(ServiceReference element){
  if (element.getProperty("String_Node_Str") != null && element.getProperty("String_Node_Str").equals(productId))   return context.getService(element);
  return null;
}

Fixed version (ground truth):
@Override public BMIDeviceNodeFactory apply(ServiceReference element){
  if (element.getProperty("String_Node_Str") != null && element.getProperty("String_Node_Str").equals(productId))   return (BMIDeviceNodeFactory)context.getService(element);
  return null;
}
Program: 180198
Project: 180198
Buggy source:
/** 
 * @return list of BMIDevices that are currently attached, or empty list if no modules are attached.
 */
public static List getAttachedDevices(){
  BMIDevice[] devs=getDevices();
  List l=new ArrayList();
  for (int i=0; i < 4; ++i) {
    if (devs[i] != null) {
      l.add(devs[i]);
    }
  }
  return l;
}

Fixed version (ground truth):
/** 
 * @return list of BMIDevices that are currently attached, or empty list if no modules are attached.
 */
public static List<BMIDevice> getAttachedDevices(){
  BMIDevice[] devs=getDevices();
  List<BMIDevice> l=new ArrayList<BMIDevice>();
  for (int i=0; i < 4; ++i) {
    if (devs[i] != null) {
      l.add(devs[i]);
    }
  }
  return l;
}
Program: 180199
Project: 180199
Buggy source:
/** 
 * @param slot
 * @return The BMIDevice that exists at the passed slot or null if no device attached.
 */
public static BMIDevice getDevice(int slot){
  if (slot < 0 || slot > 3) {
    return null;
  }
  return getDevices()[slot];
}

Fixed version (ground truth):
/** 
 * @param slot Legal values: 0 - 3
 * @return The BMIDevice that exists at the passed slot or null if no device attached.
 */
public static BMIDevice getDevice(int slot){
  if (slot < 0 || slot > 3) {
    return null;
  }
  return getDevices()[slot];
}
Program: 180200
Project: 180200
Buggy source:
public void start(BundleContext context) throws Exception {
  this.context=context;
  Activator.ref=this;
  modletFactories=new Hashtable();
  activeModlets=new Hashtable();
  ServiceReference sr=context.getServiceReference(LogService.class.getName());
  if (sr != null) {
    logService=(LogService)context.getService(sr);
  }
  context.addServiceListener(this,"String_Node_Str" + Constants.OBJECTCLASS + "String_Node_Str"+ IModletFactory.class.getName()+ "String_Node_Str");
  registerExistingServices(context);
  pipeFilename=context.getProperty("String_Node_Str");
  if (pipeFilename == null || pipeFilename.length() == 0) {
    pipeFilename=DEFAULT_PIPE_FILENAME;
  }
  logService.log(LogService.LOG_INFO,"String_Node_Str" + pipeFilename);
  createPipe(pipeFilename);
  pipeReader=new PipeReader(pipeFilename,Manager.getManager(context,logService,modletFactories,activeModlets),logService);
  logService.log(LogService.LOG_INFO,"String_Node_Str");
  coldPlug();
  logService.log(LogService.LOG_INFO,"String_Node_Str" + pipeFilename);
  pipeReader.start();
}

Fixed version (ground truth):
public void start(BundleContext context) throws Exception {
  this.context=context;
  Activator.ref=this;
  modletFactories=new Hashtable();
  activeModlets=new Hashtable();
  logService=LogServiceUtil.getLogService(context);
  context.addServiceListener(this,"String_Node_Str" + Constants.OBJECTCLASS + "String_Node_Str"+ IModletFactory.class.getName()+ "String_Node_Str");
  registerExistingServices(context);
  pipeFilename=context.getProperty("String_Node_Str");
  if (pipeFilename == null || pipeFilename.length() == 0) {
    pipeFilename=DEFAULT_PIPE_FILENAME;
  }
  logService.log(LogService.LOG_INFO,"String_Node_Str" + pipeFilename);
  createPipe(pipeFilename);
  pipeReader=new PipeReader(pipeFilename,Manager.getManager(context,logService,modletFactories,activeModlets),logService);
  logService.log(LogService.LOG_INFO,"String_Node_Str");
  coldPlug();
  logService.log(LogService.LOG_INFO,"String_Node_Str" + pipeFilename);
  pipeReader.start();
}
Program: 180201
Project: 180201
Buggy source:
/** 
 * Allows the user to set the service dependencies by adding them to services list returned by getServices(). i.e.nl getServices().add(MyService.class.getName());
 */
public void initServices(){
  getServices().add(com.buglabs.osgi.sewing.pub.ISewingService.class.getName());
  getServices().add(org.osgi.service.cm.ConfigurationAdmin.class.getName());
  getServices().add(IShellService.class.getName());
  getServices().add(com.buglabs.app.bugdash2.IBatteryInfoProvider.class.getName());
  getServices().add(LogService.class.getName());
}

Fixed version (ground truth):
/** 
 * Allows the user to set the service dependencies by adding them to services list returned by getServices(). i.e.nl getServices().add(MyService.class.getName());
 */
public void initServices(){
  getServices().add(com.buglabs.osgi.sewing.pub.ISewingService.class.getName());
  getServices().add(org.osgi.service.cm.ConfigurationAdmin.class.getName());
  getServices().add(com.buglabs.util.shell.pub.IShellService.class.getName());
  getServices().add(com.buglabs.app.bugdash2.IBatteryInfoProvider.class.getName());
  getServices().add(LogService.class.getName());
}
Program: 180202
Project: 180202
Buggy source:
public void setup() throws Exception {
  int slot=slotId + 1;
  String devnode_motion="String_Node_Str" + slot;
  String devnode_acc="String_Node_Str" + slot;
  String devnode_mdacc_control="String_Node_Str" + slot;
  motionDevice=new Motion();
  CharDeviceUtils.openDeviceWithRetry(motionDevice,devnode_motion,2);
  int retval=motionDevice.ioctl_BMI_MDACC_MOTION_DETECTOR_RUN();
  if (retval < 0) {
    throw new IOException("String_Node_Str" + devnode_motion);
  }
  accDevice=new Accelerometer();
  CharDeviceUtils.openDeviceWithRetry(accDevice,devnode_acc,2);
  accIs=new CharDeviceInputStream(accDevice);
  accControl=new AccelerometerControl(accDevice);
  acceld=new AccelerometerSimpleRawFeed(accIs,accControl);
  mdaccControlDevice=new MDACCControl();
  CharDeviceUtils.openDeviceWithRetry(mdaccControlDevice,devnode_mdacc_control,2);
  motionIs=new CharDeviceInputStream(motionDevice);
  motiond=new MotionRawFeed(motionIs);
  motionSubject=new MotionSubject(motiond.getInputStream(),this,log);
}

Fixed version (ground truth):
public void setup() throws Exception {
  int slot=slotId;
  String devnode_motion="String_Node_Str" + slot;
  String devnode_acc="String_Node_Str" + slot;
  String devnode_mdacc_control="String_Node_Str" + slot;
  motionDevice=new Motion();
  CharDeviceUtils.openDeviceWithRetry(motionDevice,devnode_motion,2);
  int retval=motionDevice.ioctl_BMI_MDACC_MOTION_DETECTOR_RUN();
  if (retval < 0) {
    throw new IOException("String_Node_Str" + devnode_motion);
  }
  accDevice=new Accelerometer();
  CharDeviceUtils.openDeviceWithRetry(accDevice,devnode_acc,2);
  accIs=new CharDeviceInputStream(accDevice);
  accControl=new AccelerometerControl(accDevice);
  acceld=new AccelerometerSimpleRawFeed(accIs,accControl);
  mdaccControlDevice=new MDACCControl();
  CharDeviceUtils.openDeviceWithRetry(mdaccControlDevice,devnode_mdacc_control,2);
  motionIs=new CharDeviceInputStream(motionDevice);
  motiond=new MotionRawFeed(motionIs);
  motionSubject=new MotionSubject(motiond.getInputStream(),this,log);
}
Program: 180203
Project: 180203
Buggy source:
/** 
 * Create a node with a parent and a String value.
 * @param parent
 * @param tagName
 * @param value
 */
public XmlNode(XmlNode parent,String tagName,String value){
  this(parent,tagName);
  if (value.length() > 0) {
    this.text=value;
  }
}

Fixed version (ground truth):
/** 
 * Create a node with a parent and a String value.
 * @param parent
 * @param tagName
 * @param value
 */
public XmlNode(XmlNode parent,String tagName,String value){
  this(parent,tagName);
  if (value != null && value.length() > 0) {
    this.text=value;
  }
}
Program: 180204
Project: 180204
Buggy source:
public static RecordStore openRecordStore(String recordStoreName,boolean createIfNecessary) throws RecordStoreException {
  ConfigurationAdmin ca=getConfigurationAdmin(Activator.getInstance().getBundleContext());
  if (ca == null) {
    throw new RecordStoreException("String_Node_Str");
  }
  try {
    Configuration c=ca.getConfiguration(createPid(recordStoreName));
    if (c.getProperties().get(KEYSTORE_KEY) == null && !createIfNecessary) {
      throw new RecordStoreException("String_Node_Str" + recordStoreName + "String_Node_Str");
    }
    Dictionary keystore=(Dictionary)c.getProperties().get(KEYSTORE_KEY);
    if (keystore == null) {
      keystore=new Hashtable();
      c.getProperties().put(KEYSTORE_KEY,keystore);
    }
    return new RecordStore(recordStoreName,keystore);
  }
 catch (  IOException e) {
    throw new RecordStoreException("String_Node_Str",e);
  }
}

Fixed version (ground truth):
public static RecordStore openRecordStore(String recordStoreName,boolean createIfNecessary) throws RecordStoreException {
  ConfigurationAdmin ca=getConfigurationAdmin(Activator.getInstance().getBundleContext());
  if (ca == null) {
    throw new RecordStoreException("String_Node_Str");
  }
  try {
    Configuration c=ca.getConfiguration(createPid(recordStoreName));
    c.update();
    if (c.getProperties().get(KEYSTORE_KEY) == null && !createIfNecessary) {
      throw new RecordStoreException("String_Node_Str" + recordStoreName + "String_Node_Str");
    }
    Dictionary keystore=(Dictionary)c.getProperties().get(KEYSTORE_KEY);
    if (keystore == null) {
      keystore=new Hashtable();
      c.getProperties().put(KEYSTORE_KEY,keystore);
    }
    return new RecordStore(recordStoreName,keystore);
  }
 catch (  IOException e) {
    throw new RecordStoreException("String_Node_Str",e);
  }
}
Program: 180205
Project: 180205
Buggy source:
/** 
 * Create a node with a parent and a String value.
 * @param parent
 * @param tagName
 * @param value
 */
public XmlNode(XmlNode parent,String tagName,String value){
  this(parent,tagName);
  this.text=value;
}

Fixed version (ground truth):
/** 
 * Create a node with a parent and a String value.
 * @param parent
 * @param tagName
 * @param value
 */
public XmlNode(XmlNode parent,String tagName,String value){
  this(parent,tagName);
  if (value.length() > 0) {
    this.text=value;
  }
}
Program: 180207
Project: 180207
Buggy source:
/** 
 * Reduce the size of the list until it matches the defined size.
 */
private void checkAndRemove(){
  while (list.size() > size) {
    list.removeFirst();
  }
}

Fixed version (ground truth):
/** 
 * Reduce the size of the list until it matches the defined size.
 */
private synchronized void checkAndRemove(){
  while (list.size() > size) {
    list.removeFirst();
  }
}
Program: 180208
Project: 180208
Buggy source:
public Object addingService(ServiceReference arg0){
  sc++;
  Object svc=bc.getService(arg0);
  serviceMap.put(arg0.getProperty(Constants.OBJECTCLASS),svc);
  if (thread == null && sc == services.length && !(runnable instanceof UnmanagedRunnable)) {
    if (runnable instanceof ManagedInlineRunnable) {
      runnable.run(serviceMap);
    }
 else {
      thread=new Thread(new Runnable(){
        public void run(){
          runnable.run(serviceMap);
        }
      }
);
      thread.start();
    }
  }
  if (runnable instanceof UnmanagedRunnable) {
    return ((UnmanagedRunnable)runnable).addingService(arg0);
  }
  return svc;
}

Fixed version (ground truth):
public Object addingService(ServiceReference arg0){
  sc++;
  Object svc=bc.getService(arg0);
  String key=((String[])arg0.getProperty(Constants.OBJECTCLASS))[0];
  serviceMap.put(key,svc);
  if (thread == null && sc == services.length && !(runnable instanceof UnmanagedRunnable)) {
    if (runnable instanceof ManagedInlineRunnable) {
      runnable.run(serviceMap);
    }
 else {
      thread=new Thread(new Runnable(){
        public void run(){
          runnable.run(serviceMap);
        }
      }
);
      thread.start();
    }
  }
  if (runnable instanceof UnmanagedRunnable) {
    return ((UnmanagedRunnable)runnable).addingService(arg0);
  }
  return svc;
}
Program: 180209
Project: 180209
Buggy source:
public void removedService(ServiceReference arg0,Object arg1){
  sc--;
  if (!(thread == null) && !thread.isInterrupted() && !(runnable instanceof UnmanagedRunnable)) {
    runnable.shutdown();
    thread.interrupt();
    return;
  }
  if (runnable instanceof UnmanagedRunnable) {
    ((UnmanagedRunnable)runnable).removedService(arg0,arg1);
  }
  if (runnable instanceof ManagedInlineRunnable) {
    ((ManagedInlineRunnable)runnable).shutdown();
  }
}

Fixed version (ground truth):
public void removedService(ServiceReference arg0,Object arg1){
  String key=((String[])arg0.getProperty(Constants.OBJECTCLASS))[0];
  serviceMap.remove(key);
  sc--;
  if (!(thread == null) && !thread.isInterrupted() && !(runnable instanceof UnmanagedRunnable)) {
    runnable.shutdown();
    thread.interrupt();
    return;
  }
  if (runnable instanceof UnmanagedRunnable) {
    ((UnmanagedRunnable)runnable).removedService(arg0,arg1);
  }
  if (runnable instanceof ManagedInlineRunnable) {
    ((ManagedInlineRunnable)runnable).shutdown();
  }
}
Program: 180210
Project: 180210
Buggy source:
public void modifiedService(ServiceReference arg0,Object arg1){
  if (runnable instanceof UnmanagedRunnable) {
    ((UnmanagedRunnable)runnable).modifiedService(arg0,arg1);
  }
}

Fixed version (ground truth):
public void modifiedService(ServiceReference arg0,Object arg1){
  String key=((String[])arg0.getProperty(Constants.OBJECTCLASS))[0];
  serviceMap.put(key,arg1);
  if (runnable instanceof UnmanagedRunnable) {
    ((UnmanagedRunnable)runnable).modifiedService(arg0,arg1);
  }
}
Program: 180211
Project: 180211
Buggy source:
public ServiceTrackerHelper(BundleContext bc,ManagedRunnable t,String[] services){
  this.bc=bc;
  this.runnable=t;
  this.services=services;
  this.serviceMap=new HashMap();
  this.log=LogServiceUtil.getLogService(bc);
  sc=0;
}

Fixed version (ground truth):
public ServiceTrackerHelper(BundleContext bc,ManagedRunnable t,int serviceCount){
  this.bc=bc;
  this.runnable=t;
  this.serviceCount=serviceCount;
  this.serviceMap=new HashMap();
  this.log=LogServiceUtil.getLogService(bc);
  sc=0;
}
Program: 180212
Project: 180212
Buggy source:
public Object addingService(ServiceReference arg0){
  sc++;
  Object svc=bc.getService(arg0);
  String key=((String[])arg0.getProperty(Constants.OBJECTCLASS))[0];
  serviceMap.put(key,svc);
  if (thread == null && sc == services.length && !(runnable instanceof UnmanagedRunnable)) {
    if (runnable instanceof ManagedInlineRunnable) {
      runnable.run(serviceMap);
    }
 else {
      thread=new Thread(new Runnable(){
        public void run(){
          runnable.run(serviceMap);
        }
      }
);
      thread.start();
    }
  }
  if (runnable instanceof UnmanagedRunnable) {
    return ((UnmanagedRunnable)runnable).addingService(arg0);
  }
  return svc;
}

Fixed version (ground truth):
public Object addingService(ServiceReference arg0){
  Object svc=bc.getService(arg0);
  String key=((String[])arg0.getProperty(Constants.OBJECTCLASS))[0];
  if (!serviceMap.containsKey(key)) {
    sc++;
    serviceMap.put(key,svc);
  }
  if (thread == null && sc == serviceCount && !(runnable instanceof UnmanagedRunnable)) {
    if (runnable instanceof ManagedInlineRunnable) {
      runnable.run(serviceMap);
    }
 else {
      thread=new Thread(new Runnable(){
        public void run(){
          runnable.run(serviceMap);
        }
      }
);
      thread.start();
    }
  }
  if (runnable instanceof UnmanagedRunnable) {
    return ((UnmanagedRunnable)runnable).addingService(arg0);
  }
  return svc;
}
Program: 180213
Project: 180213
Buggy source:
public void removedService(ServiceReference arg0,Object arg1){
  String key=((String[])arg0.getProperty(Constants.OBJECTCLASS))[0];
  serviceMap.remove(key);
  sc--;
  if (!(thread == null) && !thread.isInterrupted() && !(runnable instanceof UnmanagedRunnable)) {
    runnable.shutdown();
    thread.interrupt();
    return;
  }
  if (runnable instanceof UnmanagedRunnable) {
    ((UnmanagedRunnable)runnable).removedService(arg0,arg1);
  }
  if (runnable instanceof ManagedInlineRunnable) {
    ((ManagedInlineRunnable)runnable).shutdown();
  }
}

Fixed version (ground truth):
public void removedService(ServiceReference arg0,Object arg1){
  String key=((String[])arg0.getProperty(Constants.OBJECTCLASS))[0];
  if (serviceMap.containsKey(key)) {
    serviceMap.remove(key);
    sc--;
  }
  if (!(thread == null) && !thread.isInterrupted() && !(runnable instanceof UnmanagedRunnable)) {
    runnable.shutdown();
    thread.interrupt();
    thread=null;
    return;
  }
  if (runnable instanceof UnmanagedRunnable) {
    ((UnmanagedRunnable)runnable).removedService(arg0,arg1);
  }
  if (runnable instanceof ManagedInlineRunnable) {
    ((ManagedInlineRunnable)runnable).shutdown();
  }
}
Program: 180214
Project: 180214
Buggy source:
/** 
 * Get a list of BMIMessage strings for existing modules based on entries in the /sys filesystem.
 * @return
 * @throws IOException
 */
private List getSysFSModules() throws IOException {
  List slots=null;
  for (int i=0; i < 4; ++i) {
    File prodFile=new File("String_Node_Str" + i + "String_Node_Str"+ i+ "String_Node_Str"+ i+ "String_Node_Str");
    if (!prodFile.exists()) {
      logService.log(LogService.LOG_DEBUG,"String_Node_Str" + i);
      continue;
    }
    if (slots == null) {
      slots=new ArrayList();
    }
    BMIModuleProperties props=BMIModuleProperties.createFromSYSDirectory(prodFile.getParentFile());
    BMIMessage m=new BMIMessage(props,i);
    slots.add(m);
  }
  return slots;
}

Fixed version (ground truth):
/** 
 * Get a list of BMIMessage strings for existing modules based on entries in the /sys filesystem.
 * @return
 * @throws IOException
 */
private List getSysFSModules() throws IOException {
  List slots=null;
  for (int i=0; i < 4; ++i) {
    File prodFile=new File("String_Node_Str" + i + "String_Node_Str"+ i+ "String_Node_Str");
    if (!prodFile.exists()) {
      logService.log(LogService.LOG_DEBUG,"String_Node_Str" + i);
      continue;
    }
    if (slots == null) {
      slots=new ArrayList();
    }
    BMIModuleProperties props=BMIModuleProperties.createFromSYSDirectory(prodFile.getParentFile());
    BMIMessage m=new BMIMessage(props,i);
    slots.add(m);
  }
  return slots;
}
Program: 180215
Project: 180215
Buggy source:
/** 
 * Return a file represented the root directory of a BMI module given it's slot #.
 * @param slot
 * @return
 */
private File sysDirectory(int slot){
  return new File("String_Node_Str" + slot + "String_Node_Str"+ slot+ "String_Node_Str"+ slot);
}

Fixed version (ground truth):
/** 
 * Return a file represented the root directory of a BMI module given it's slot #.
 * @param slot
 * @return
 */
private File sysDirectory(int slot){
}