nus-yam/ex-repair huggingface dataset:
Program: 94307
Project: 94307
Buggy source:
/** 
 * Construct a properties object from the dictionary for this ServiceRegistration.
 * @param props The properties for this service.
 * @return A Properties object for this ServiceRegistration.
 */
protected Properties createProperties(Dictionary props){
  final Properties resultProps=new Properties(props);
  resultProps.setProperty(RemoteServiceRegistryImpl.REMOTEOBJECTCLASS,clazzes);
  resultProps.setProperty(RemoteServiceRegistryImpl.REMOTESERVICE_ID,new Long(getID().getContainerRelativeID()));
  final Object ranking=resultProps.getProperty(RemoteServiceRegistryImpl.REMOTESERVICE_RANKING);
  serviceranking=(ranking instanceof Integer) ? ((Integer)ranking).intValue() : 0;
  return (resultProps);
}

Fixed version (ground truth):
/** 
 * Construct a properties object from the dictionary for this ServiceRegistration.
 * @param props The properties for this service.
 * @return A Properties object for this ServiceRegistration.
 */
protected Properties createProperties(Dictionary props){
  final Properties resultProps=new Properties(props);
  resultProps.setProperty(RemoteServiceRegistryImpl.REMOTEOBJECTCLASS,clazzes);
  resultProps.setProperty(RemoteServiceRegistryImpl.REMOTESERVICE_ID,new Long(getID().getContainerRelativeID()));
  final Object ranking=props.get(RemoteServiceRegistryImpl.REMOTESERVICE_RANKING);
  serviceranking=(ranking instanceof Integer) ? ((Integer)ranking).intValue() : 0;
  return (resultProps);
}
Program: 94308
Project: 94308
Buggy source:
/** 
 * @since 3.2
 */
protected void localRegisterService(RemoteServiceRegistrationImpl registration){
  final Object localServiceRegistrationValue=registration.getProperty(org.eclipse.ecf.remoteservice.Constants.AUTOREGISTER_REMOTE_PROXY);
  if (localServiceRegistrationValue != null) {
    final BundleContext context=Activator.getDefault().getContext();
    if (context == null)     return;
    final RemoteServiceImpl remoteServiceImpl=new RemoteServiceImpl(this,registration);
    Object service;
    try {
      service=remoteServiceImpl.getProxy();
    }
 catch (    final ECFException e) {
      e.printStackTrace();
      log("String_Node_Str",e);
      return;
    }
    final Hashtable properties=new Hashtable();
    final String[] keys=registration.getPropertyKeys();
    for (int i=0; i < keys.length; i++) {
      final Object value=registration.getProperty(keys[i]);
      if (value != null) {
        properties.put(keys[i],value);
      }
    }
    final ID remoteContainerID=registration.getContainerID();
    properties.put(org.eclipse.ecf.remoteservice.Constants.SERVICE_CONTAINER_ID,remoteContainerID.getName());
    final ServiceRegistration serviceRegistration=context.registerService(registration.getClasses(),service,properties);
    addLocalServiceRegistration(remoteContainerID,serviceRegistration);
  }
}

Fixed version (ground truth):
/** 
 * @since 3.2
 */
protected void localRegisterService(RemoteServiceRegistrationImpl registration){
  final Object localServiceRegistrationValue=registration.getProperty(org.eclipse.ecf.remoteservice.Constants.AUTOREGISTER_REMOTE_PROXY);
  if (localServiceRegistrationValue != null) {
    final BundleContext context=Activator.getDefault().getContext();
    if (context == null)     return;
    final RemoteServiceImpl remoteServiceImpl=new RemoteServiceImpl(this,registration);
    Object service;
    try {
      service=remoteServiceImpl.getProxy();
    }
 catch (    final ECFException e) {
      e.printStackTrace();
      log("String_Node_Str",e);
      return;
    }
    final Hashtable properties=new Hashtable();
    final String[] keys=registration.getPropertyKeys();
    for (int i=0; i < keys.length; i++) {
      final Object value=registration.getProperty(keys[i]);
      if (value != null) {
        properties.put(keys[i],value);
      }
    }
    final ID remoteContainerID=registration.getContainerID();
    final ServiceRegistration serviceRegistration=context.registerService(registration.getClasses(),service,properties);
    addLocalServiceRegistration(remoteContainerID,serviceRegistration);
  }
}
Program: 94309
Project: 94309
Buggy source:
protected Properties createServiceDiscoveryProperties(){
  Properties props=new RemoteServiceProperties(serviceHostContainerType,serviceHostContainer);
  props.put(Constants.AUTOREGISTER_REMOTE_PROXY,"String_Node_Str");
  return props;
}

Fixed version (ground truth):
protected Properties createServiceDiscoveryProperties(){
  Properties props=new Properties();
  props.put(Constants.SERVICE_CONTAINER_ID,serviceHostContainer.getID());
  props.put(Constants.SERVICE_CONTAINER_FACTORY_NAME,serviceHostContainerType);
  props.put(Constants.AUTOREGISTER_REMOTE_PROXY,"String_Node_Str");
  return props;
}
Program: 94310
Project: 94310
Buggy source:
/** 
 * Construct a properties object from the dictionary for this ServiceRegistration.
 * @param props The properties for this service.
 * @return A Properties object for this ServiceRegistration.
 */
protected Properties createProperties(Dictionary props){
  final Properties resultProps=new Properties(props);
  resultProps.setProperty(RemoteServiceRegistryImpl.REMOTEOBJECTCLASS,clazzes);
  resultProps.setProperty(RemoteServiceRegistryImpl.REMOTESERVICE_ID,new Long(getID().getContainerRelativeID()));
  final Object ranking=props.get(RemoteServiceRegistryImpl.REMOTESERVICE_RANKING);
  serviceranking=(ranking instanceof Integer) ? ((Integer)ranking).intValue() : 0;
  return (resultProps);
}

Fixed version (ground truth):
/** 
 * Construct a properties object from the dictionary for this ServiceRegistration.
 * @param props The properties for this service.
 * @return A Properties object for this ServiceRegistration.
 */
protected Properties createProperties(Dictionary props){
  final Properties resultProps=new Properties(props);
  resultProps.setProperty(RemoteServiceRegistryImpl.REMOTEOBJECTCLASS,clazzes);
  resultProps.setProperty(RemoteServiceRegistryImpl.REMOTESERVICE_ID,new Long(getID().getContainerRelativeID()));
  final Object ranking=(props == null) ? null : props.get(RemoteServiceRegistryImpl.REMOTESERVICE_RANKING);
  serviceranking=(ranking instanceof Integer) ? ((Integer)ranking).intValue() : 0;
  return (resultProps);
}
Program: 94311
Project: 94311
Buggy source:
public RemoteServiceEndpointDescriptionImpl(IServiceInfo serviceInfo){
  super(((ServiceProperties)serviceInfo.getServiceProperties()).asProperties());
  this.serviceId=serviceInfo.getServiceID();
  IServiceProperties serviceProperties=serviceInfo.getServiceProperties();
  final byte[] endpointBytes=serviceProperties.getPropertyBytes(RemoteServicePublication.ENDPOINT_CONTAINERID);
  if (endpointBytes == null)   throw new IDCreateException("String_Node_Str");
  final String endpointStr=new String(endpointBytes);
  final String namespaceStr=serviceProperties.getPropertyString(RemoteServicePublication.ENDPOINT_CONTAINERID_NAMESPACE);
  if (namespaceStr == null) {
    throw new IDCreateException("String_Node_Str");
  }
  endpointId=IDFactory.getDefault().createID(namespaceStr,endpointStr);
  final byte[] targetBytes=serviceProperties.getPropertyBytes(RemoteServicePublication.TARGET_CONTAINERID);
  if (targetBytes != null) {
    final String targetStr=new String(targetBytes);
    String targetNamespaceStr=serviceProperties.getPropertyString(RemoteServicePublication.TARGET_CONTAINERID_NAMESPACE);
    if (targetNamespaceStr == null)     targetNamespaceStr=namespaceStr;
    targetId=IDFactory.getDefault().createID(targetNamespaceStr,targetStr);
  }
  URI serviceLocation=this.serviceId.getLocation();
  long rsId=this.getRemoteServiceId();
  hashCode=31 * hashCode + (int)(rsId ^ (rsId >>> 32));
  hashCode=31 * hashCode + serviceLocation.hashCode();
}

Fixed version (ground truth):
public RemoteServiceEndpointDescriptionImpl(IServiceInfo serviceInfo){
  super(((ServiceProperties)serviceInfo.getServiceProperties()).asProperties());
  this.serviceId=serviceInfo.getServiceID();
  IServiceProperties serviceProperties=serviceInfo.getServiceProperties();
  final byte[] endpointBytes=serviceProperties.getPropertyBytes(RemoteServicePublication.ENDPOINT_CONTAINERID);
  if (endpointBytes == null)   throw new IDCreateException("String_Node_Str");
  final String endpointStr=new String(endpointBytes);
  final String namespaceStr=serviceProperties.getPropertyString(RemoteServicePublication.ENDPOINT_CONTAINERID_NAMESPACE);
  if (namespaceStr == null) {
    throw new IDCreateException("String_Node_Str");
  }
  endpointId=IDFactory.getDefault().createID(namespaceStr,endpointStr);
  final byte[] targetBytes=serviceProperties.getPropertyBytes(RemoteServicePublication.TARGET_CONTAINERID);
  if (targetBytes != null) {
    final String targetStr=new String(targetBytes);
    String targetNamespaceStr=serviceProperties.getPropertyString(RemoteServicePublication.TARGET_CONTAINERID_NAMESPACE);
    if (targetNamespaceStr == null)     targetNamespaceStr=namespaceStr;
    targetId=IDFactory.getDefault().createID(targetNamespaceStr,targetStr);
  }
  URI serviceLocation=this.serviceId.getLocation();
  long rsId=this.getRemoteServiceId();
  hashCode=31 * hashCode + (int)(rsId ^ (rsId >>> 32));
  hashCode=31 * hashCode + serviceLocation.hashCode();
  hashCode=31 * hashCode + endpointId.hashCode();
}
Program: 94312
Project: 94312
Buggy source:
public boolean equals(Object obj){
  if (this == obj)   return true;
  if (obj == null)   return false;
  if (getClass() != obj.getClass())   return false;
  RemoteServiceEndpointDescriptionImpl other=(RemoteServiceEndpointDescriptionImpl)obj;
  return this.serviceId.getLocation().equals(other.serviceId.getLocation()) && getRemoteServiceId() == other.getRemoteServiceId();
}

Fixed version (ground truth):
public boolean equals(Object obj){
  if (this == obj)   return true;
  if (obj == null)   return false;
  if (getClass() != obj.getClass())   return false;
  RemoteServiceEndpointDescriptionImpl other=(RemoteServiceEndpointDescriptionImpl)obj;
  return this.serviceId.getLocation().equals(other.serviceId.getLocation()) && getRemoteServiceId() == other.getRemoteServiceId() && endpointId.equals(other.getEndpointAsID());
}
Program: 94313
Project: 94313
Buggy source:
protected void handleSharedObjectMessage(ContainerMessage mess) throws IOException {
  final ID fromID=mess.getFromContainerID();
  final ID toID=mess.getToContainerID();
  final ContainerMessage.SharedObjectMessage resp=(ContainerMessage.SharedObjectMessage)mess.getData();
  final ID sharedObjectID=resp.getFromSharedObjectID();
  SOWrapper sow=null;
  Serializable obj=null;
  debug("String_Node_Str" + fromID + "String_Node_Str"+ toID+ "String_Node_Str"+ sharedObjectID+ "String_Node_Str");
synchronized (getGroupMembershipLock()) {
    sow=getSharedObjectWrapper(sharedObjectID);
    if (sow != null) {
      try {
        obj=(Serializable)deserializeSharedObjectMessage((byte[])resp.getData());
        sow.deliverSharedObjectMessage(fromID,obj);
      }
 catch (      final ClassNotFoundException e) {
        Trace.catching(ProviderPlugin.PLUGIN_ID,ECFProviderDebugOptions.EXCEPTIONS_CATCHING,this.getClass(),"String_Node_Str",e);
        printToSystemError("String_Node_Str" + sharedObjectID + "String_Node_Str"+ fromID,e);
      }
    }
 else     handleUndeliveredSharedObjectMessage(resp);
    forward(fromID,toID,mess);
  }
  if (sow != null)   fireContainerEvent(new ContainerSharedObjectMessageReceivingEvent(getID(),fromID,sharedObjectID,obj));
}

Fixed version (ground truth):
protected void handleSharedObjectMessage(ContainerMessage mess) throws IOException {
  final ID fromID=mess.getFromContainerID();
  final ID toID=mess.getToContainerID();
  final ContainerMessage.SharedObjectMessage resp=(ContainerMessage.SharedObjectMessage)mess.getData();
  final ID sharedObjectID=resp.getFromSharedObjectID();
  SOWrapper sow=null;
  Serializable obj=null;
  debug("String_Node_Str" + fromID + "String_Node_Str"+ toID+ "String_Node_Str"+ sharedObjectID+ "String_Node_Str");
synchronized (getGroupMembershipLock()) {
    sow=getSharedObjectWrapper(sharedObjectID);
    if (sow != null) {
      try {
        obj=(Serializable)deserializeSharedObjectMessage((byte[])resp.getData());
        sow.deliverSharedObjectMessage(fromID,obj);
      }
 catch (      final ClassNotFoundException e) {
        String message="String_Node_Str" + sharedObjectID + "String_Node_Str"+ fromID;
        ProviderPlugin.getDefault().log(new Status(IStatus.ERROR,ProviderPlugin.PLUGIN_ID,message,e));
        printToSystemError(message,e);
      }
catch (      final IOException e) {
        String message="String_Node_Str" + sharedObjectID + "String_Node_Str"+ fromID;
        ProviderPlugin.getDefault().log(new Status(IStatus.ERROR,ProviderPlugin.PLUGIN_ID,message,e));
        printToSystemError(message,e);
      }
catch (      final NoClassDefFoundError e) {
        String message="String_Node_Str" + sharedObjectID + "String_Node_Str"+ fromID;
        ProviderPlugin.getDefault().log(new Status(IStatus.ERROR,ProviderPlugin.PLUGIN_ID,message,e));
        printToSystemError(message,e);
      }
    }
 else     handleUndeliveredSharedObjectMessage(resp);
    forward(fromID,toID,mess);
  }
  if (sow != null)   fireContainerEvent(new ContainerSharedObjectMessageReceivingEvent(getID(),fromID,sharedObjectID,obj));
}
Program: 94314
Project: 94314
Buggy source:
Object doInvoke(final Object target) throws Exception {
  if (target == null)   throw new NoSuchMethodException("String_Node_Str");
  Method meth=null;
  if (clazz == null) {
    meth=findMethodRecursive(target.getClass());
  }
 else {
    meth=findMethod(getClass(target.getClass().getClassLoader(),clazz));
  }
  if (meth == null)   throw new NoSuchMethodException(getMethod());
  final Method toCall=meth;
  AccessController.doPrivileged(new PrivilegedExceptionAction(){
    public Object run() throws Exception {
      if (!toCall.isAccessible())       toCall.setAccessible(true);
      return null;
    }
  }
);
  return toCall.invoke(target,getParameters());
}

Fixed version (ground truth):
Object doInvoke(final Object target) throws Exception {
  if (target == null)   throw new NoSuchMethodException("String_Node_Str");
  Method meth=null;
  if (clazz == null) {
    meth=findMethodRecursive(target.getClass());
  }
 else {
    meth=findMethod(getClass(target.getClass().getClassLoader(),clazz));
  }
  if (meth == null) {
    Class[] someParameterTypes=getParameterTypes();
    throw new NoSuchMethodException("String_Node_Str" + getMethod() + "String_Node_Str"+ ((someParameterTypes == null) ? "String_Node_Str" : Arrays.asList(someParameterTypes).toString())+ "String_Node_Str");
  }
  final Method toCall=meth;
  AccessController.doPrivileged(new PrivilegedExceptionAction(){
    public Object run() throws Exception {
      if (!toCall.isAccessible())       toCall.setAccessible(true);
      return null;
    }
  }
);
  return toCall.invoke(target,getParameters());
}
Program: 94315
Project: 94315
Buggy source:
/** 
 * Initialization method called by Activator.
 */
public void init(){
  log(LogService.LOG_DEBUG,"String_Node_Str");
  discoTrackerCustomizer=new DSTTracker(context);
  discoTracker=new ServiceTracker(context,DiscoveredServiceTracker.class.getName(),discoTrackerCustomizer);
  discoTracker.open();
  spTracker=new ServiceTracker(context,ServicePublication.class.getName(),new ServicePublicationTracker(context,this));
  spTracker.open();
  bt=new BundleTracker(context,36,new BundleTrackerImpl(this));
  bt.open();
}

Fixed version (ground truth):
/** 
 * Initialization method called by Activator.
 */
public void init(){
  log(LogService.LOG_DEBUG,"String_Node_Str");
  discoTrackerCustomizer=new DSTTracker(context);
  discoTracker=new ServiceTracker(context,DiscoveredServiceTracker.class.getName(),discoTrackerCustomizer);
  discoTracker.open();
  spTracker=new ServiceTracker(context,ServicePublication.class.getName(),new ServicePublicationTracker(context,this));
  spTracker.open();
  bt=new BundleTracker(context,Bundle.ACTIVE | Bundle.STARTING,new BundleTrackerImpl(this));
  bt.open();
}
Program: 94316
Project: 94316
Buggy source:
/** 
 * @param bundle
 * @param result
 * @param tokenizer
 */
private void handleRemoteService(final Bundle bundle,Collection result,StringTokenizer tokenizer){
  String token=tokenizer.nextToken().trim();
  String path=token.substring(0,token.lastIndexOf("String_Node_Str"));
  int start=path.indexOf("String_Node_Str");
  if (start >= 0) {
    int end=path.indexOf("String_Node_Str");
    String substring=path.substring(start + 2,end);
    String property=System.getProperty(substring);
    path=path.replaceAll("String_Node_Str" + substring + "String_Node_Str",property);
  }
  String files=token.substring(token.lastIndexOf("String_Node_Str") + 1,token.length());
  Enumeration enumeration=bundle.findEntries(path,files,false);
  if (enumeration == null) {
    File f=new File(path + File.separator + files);
    if (f.isFile() && f.exists()) {
      try {
        result.add(f.toURL());
      }
 catch (      MalformedURLException e) {
      }
    }
 else     if (f.isDirectory() && f.exists()) {
      addFilesToResult(result,f);
    }
 else     if (new File(path).isDirectory()) {
      File directory=new File(path);
      if (directory.exists() && files.equals("String_Node_Str")) {
        addFilesToResult(result,directory);
      }
    }
  }
 else {
    while (enumeration.hasMoreElements()) {
      result.add(enumeration.nextElement());
    }
  }
}

Fixed version (ground truth):
/** 
 * @param bundle
 * @param result
 * @param tokenizer
 */
private void handleRemoteService(final Bundle bundle,Collection result,StringTokenizer tokenizer){
  String token=tokenizer.nextToken().trim();
  int lastSlash=token.lastIndexOf("String_Node_Str");
  String path=(lastSlash <= 0) ? "String_Node_Str" : token.substring(0,lastSlash);
  int start=path.indexOf("String_Node_Str");
  if (start >= 0) {
    int end=path.indexOf("String_Node_Str");
    String substring=path.substring(start + 2,end);
    String property=System.getProperty(substring);
    path=path.replaceAll("String_Node_Str" + substring + "String_Node_Str",property);
  }
  String files=token.substring(lastSlash + 1,token.length());
  Enumeration enumeration=bundle.findEntries(path,files,false);
  if (enumeration == null) {
    File f=new File(path + File.separator + files);
    if (f.isFile() && f.exists()) {
      try {
        result.add(f.toURL());
      }
 catch (      MalformedURLException e) {
      }
    }
 else     if (f.isDirectory() && f.exists()) {
      addFilesToResult(result,f);
    }
 else     if (new File(path).isDirectory()) {
      File directory=new File(path);
      if (directory.exists() && files.equals("String_Node_Str")) {
        addFilesToResult(result,directory);
      }
    }
  }
 else {
    while (enumeration.hasMoreElements()) {
      result.add(enumeration.nextElement());
    }
  }
}
Program: 94317
Project: 94317
Buggy source:
public void stop(BundleContext ctxt) throws Exception {
  this.context=null;
  plugin=null;
}

Fixed version (ground truth):
public void stop(BundleContext ctxt) throws Exception {
  if (logServiceTracker != null) {
    logServiceTracker.close();
    logServiceTracker=null;
    logService=null;
  }
  this.context=null;
  plugin=null;
}
Program: 94318
Project: 94318
Buggy source:
public void log(IStatus status){
  LogService logService=getLogService();
  if (logService != null) {
    logService.log(LogHelper.getLogCode(status),LogHelper.getLogMessage(status),status.getException());
  }
}

Fixed version (ground truth):
public void log(IStatus status){
  LogService ls=getLogService();
  if (ls != null) {
    ls.log(LogHelper.getLogCode(status),LogHelper.getLogMessage(status),status.getException());
  }
}
Program: 94319
Project: 94319
Buggy source:
protected LogService getLogService(){
  if (logServiceTracker == null) {
    logServiceTracker=new ServiceTracker(this.context,LogService.class.getName(),null);
    logServiceTracker.open();
  }
  return (LogService)logServiceTracker.getService();
}

Fixed version (ground truth):
protected LogService getLogService(){
  if (logServiceTracker == null) {
    logServiceTracker=new ServiceTracker(this.context,LogService.class.getName(),null);
    logServiceTracker.open();
  }
  logService=(LogService)logServiceTracker.getService();
  if (logService == null)   logService=new SystemLogService(PLUGIN_ID);
  return logService;
}
Program: 94323
Project: 94323
Buggy source:
public DiscoveredServiceTrackerImpl(DistributionProviderImpl dp){
  this.distributionProvider=dp;
  ThreadGroup eventGroup=new ThreadGroup("String_Node_Str");
  eventGroup.setDaemon(true);
  queue=new ListenerQueue(new EventManager("String_Node_Str",eventGroup));
  CopyOnWriteIdentityMap listeners=new CopyOnWriteIdentityMap();
  listeners.put(this,this);
  queue.queueListeners(listeners.entrySet(),new EventDispatcher(){
    public void dispatchEvent(    Object eventListener,    Object listenerObject,    int eventAction,    Object eventObject){
      RemoteServiceEndpointDescription rsEndpointDescription=((DiscoveredEndpointEvent)eventObject).getEndpointDescription();
      try {
        handleDiscoveredServiceAvailable(rsEndpointDescription);
      }
 catch (      Exception e) {
        logError("String_Node_Str","String_Node_Str" + rsEndpointDescription,e);
        throw new RuntimeException("String_Node_Str" + rsEndpointDescription,e);
      }
    }
  }
);
}

Fixed version (ground truth):
public DiscoveredServiceTrackerImpl(DistributionProviderImpl dp){
  this.distributionProvider=dp;
  ThreadGroup eventGroup=new ThreadGroup("String_Node_Str");
  eventGroup.setDaemon(true);
  eventManager=new EventManager("String_Node_Str",eventGroup);
  queue=new ListenerQueue(eventManager);
  CopyOnWriteIdentityMap listeners=new CopyOnWriteIdentityMap();
  listeners.put(this,this);
  queue.queueListeners(listeners.entrySet(),new EventDispatcher(){
    public void dispatchEvent(    Object eventListener,    Object listenerObject,    int eventAction,    Object eventObject){
      RemoteServiceEndpointDescription rsEndpointDescription=((DiscoveredEndpointEvent)eventObject).getEndpointDescription();
      try {
        handleDiscoveredServiceAvailable(rsEndpointDescription);
      }
 catch (      Exception e) {
        logError("String_Node_Str","String_Node_Str" + rsEndpointDescription,e);
        throw new RuntimeException("String_Node_Str" + rsEndpointDescription,e);
      }
    }
  }
);
}
Program: 94324
Project: 94324
Buggy source:
protected NameValuePair[] toNameValuePairs(String uri,IRemoteCall call,IRemoteCallable callable) throws NotSerializableException {
  IRemoteCallParameter[] restParameters=prepareParameters(uri,call,callable);
  List nameValueList=new ArrayList();
  if (restParameters != null) {
    for (int i=0; i < restParameters.length; i++) {
      try {
        String parameterValue=null;
        Object o=restParameters[i].getValue();
        if (o instanceof String) {
          parameterValue=(String)o;
        }
 else         if (o != null) {
          parameterValue=o.toString();
        }
        if (parameterValue != null) {
          String parameterName=URLEncoder.encode(restParameters[i].getName(),"String_Node_Str");
          parameterValue=URLEncoder.encode(parameterValue,"String_Node_Str");
          nameValueList.add(new NameValuePair(parameterName,parameterValue));
        }
      }
 catch (      UnsupportedEncodingException e) {
        logException("String_Node_Str",e);
      }
    }
  }
  return (NameValuePair[])nameValueList.toArray(new NameValuePair[nameValueList.size()]);
}

Fixed version (ground truth):
protected NameValuePair[] toNameValuePairs(String uri,IRemoteCall call,IRemoteCallable callable) throws NotSerializableException {
  IRemoteCallParameter[] restParameters=prepareParameters(uri,call,callable);
  List nameValueList=new ArrayList();
  if (restParameters != null) {
    for (int i=0; i < restParameters.length; i++) {
      String parameterValue=null;
      Object o=restParameters[i].getValue();
      if (o instanceof String) {
        parameterValue=(String)o;
      }
 else       if (o != null) {
        parameterValue=o.toString();
      }
      if (parameterValue != null) {
        nameValueList.add(new NameValuePair(restParameters[i].getName(),parameterValue));
      }
    }
  }
  return (NameValuePair[])nameValueList.toArray(new NameValuePair[nameValueList.size()]);
}
Program: 94325
Project: 94325
Buggy source:
public void start(BundleContext context) throws Exception {
  this.context=context;
  final Properties cmProps=new Properties();
  cmProps.put(Constants.SERVICE_PID,NAME);
  context.registerService(ManagedServiceFactory.class.getName(),this,cmProps);
  final Properties props=new Properties();
  props.put("String_Node_Str",NAME);
  props.put(Constants.SERVICE_RANKING,new Integer(750));
  String[] clazzes=new String[]{IDiscoveryLocator.class.getName(),IDiscoveryAdvertiser.class.getName()};
  serviceRegistrations.put(null,context.registerService(clazzes,new ServiceFactory(){
    private volatile DnsSdDisocoveryLocator locator;
    public Object getService(    final Bundle bundle,    final ServiceRegistration registration){
      if (locator == null) {
        try {
          locator=new DnsSdDisocoveryLocator();
          locator.connect(null,null);
        }
 catch (        final ContainerConnectException e) {
          locator=null;
        }
      }
      return locator;
    }
    public void ungetService(    final Bundle bundle,    final ServiceRegistration registration,    final Object service){
    }
  }
,props));
}

Fixed version (ground truth):
public void start(BundleContext context) throws Exception {
  this.context=context;
  final Properties cmProps=new Properties();
  cmProps.put(Constants.SERVICE_PID,NAME);
  context.registerService(ManagedServiceFactory.class.getName(),this,cmProps);
  final Properties props=new Properties();
  props.put("String_Node_Str",NAME);
  props.put(Constants.SERVICE_RANKING,new Integer(750));
  String[] clazzes=new String[]{IDiscoveryLocator.class.getName(),IDiscoveryAdvertiser.class.getName()};
  serviceRegistrations.put(null,context.registerService(clazzes,new ServiceFactory(){
    private volatile DnsSdDiscoveryLocator locator;
    public Object getService(    final Bundle bundle,    final ServiceRegistration registration){
      if (locator == null) {
        try {
          locator=new DnsSdDiscoveryLocator();
          locator.connect(null,null);
        }
 catch (        final ContainerConnectException e) {
          locator=null;
        }
      }
      return locator;
    }
    public void ungetService(    final Bundle bundle,    final ServiceRegistration registration,    final Object service){
    }
  }
,props));
}
Program: 94326
Project: 94326
Buggy source:
public void updated(String pid,Dictionary properties) throws ConfigurationException {
  if (properties != null) {
    Properties props=new Properties();
    props.put(Constants.SERVICE_PID,pid);
    DnsSdDisocoveryLocator locator=new DnsSdDisocoveryLocator();
    DnsSdServiceTypeID targetID=new DnsSdServiceTypeID();
    try {
      final String[] searchPaths=(String[])properties.get(IDnsSdDiscoveryConstants.CA_SEARCH_PATH);
      if (searchPaths != null) {
        targetID.setSearchPath(searchPaths);
      }
      final String resolver=(String)properties.get(IDnsSdDiscoveryConstants.CA_RESOLVER);
      if (resolver != null) {
        locator.setResolver(resolver);
      }
      locator.connect(targetID,null);
      serviceRegistrations.put(pid,context.registerService(IDiscoveryLocator.class.getName(),locator,props));
    }
 catch (    ContainerConnectException e) {
      throw new ConfigurationException("String_Node_Str","String_Node_Str",e);
    }
catch (    ClassCastException cce) {
      throw new ConfigurationException("String_Node_Str","String_Node_Str",cce);
    }
  }
}

Fixed version (ground truth):
public void updated(String pid,Dictionary properties) throws ConfigurationException {
  if (properties != null) {
    Properties props=new Properties();
    props.put(Constants.SERVICE_PID,pid);
    DnsSdDiscoveryLocator locator=new DnsSdDiscoveryLocator();
    DnsSdServiceTypeID targetID=new DnsSdServiceTypeID();
    try {
      final String[] searchPaths=(String[])properties.get(IDnsSdDiscoveryConstants.CA_SEARCH_PATH);
      if (searchPaths != null) {
        targetID.setSearchPath(searchPaths);
      }
      final String resolver=(String)properties.get(IDnsSdDiscoveryConstants.CA_RESOLVER);
      if (resolver != null) {
        locator.setResolver(resolver);
      }
      locator.connect(targetID,null);
      serviceRegistrations.put(pid,context.registerService(IDiscoveryLocator.class.getName(),locator,props));
    }
 catch (    ContainerConnectException e) {
      throw new ConfigurationException("String_Node_Str","String_Node_Str",e);
    }
catch (    ClassCastException cce) {
      throw new ConfigurationException("String_Node_Str","String_Node_Str",cce);
    }
  }
}
Program: 94327
Project: 94327
Buggy source:
public Object getService(final Bundle bundle,final ServiceRegistration registration){
  if (locator == null) {
    try {
      locator=new DnsSdDisocoveryLocator();
      locator.connect(null,null);
    }
 catch (    final ContainerConnectException e) {
      locator=null;
    }
  }
  return locator;
}

Fixed version (ground truth):
public Object getService(final Bundle bundle,final ServiceRegistration registration){
  if (locator == null) {
    try {
      locator=new DnsSdDiscoveryLocator();
      locator.connect(null,null);
    }
 catch (    final ContainerConnectException e) {
      locator=null;
    }
  }
  return locator;
}
Program: 94328
Project: 94328
Buggy source:
public IContainer createInstance(ContainerTypeDescription description,Object[] parameters) throws ContainerCreateException {
  return new DnsSdDisocoveryLocator();
}

Fixed version (ground truth):
public IContainer createInstance(ContainerTypeDescription description,Object[] parameters) throws ContainerCreateException {
  return new DnsSdDiscoveryLocator();
}
Program: 94329
Project: 94329
Buggy source:
public synchronized void disconnect(){
  disconnecting=true;
  if (isStarted()) {
    stop();
  }
  if (connection != null) {
    connection.removePacketListener(packetListener);
    connection.removeConnectionListener(connectionListener);
    connection.disconnect();
    isConnected=false;
    connection=null;
  }
}

Fixed version (ground truth):
public synchronized void disconnect(){
  disconnecting=true;
  if (isStarted()) {
    stop();
  }
  if (connection != null) {
    connection.removePacketListener(packetListener);
    connection.removeConnectionListener(connectionListener);
    connection.disconnect();
    connection=null;
synchronized (bindLock) {
      jid=null;
      isConnected=false;
    }
  }
}
Program: 94331
Project: 94331
Buggy source:
protected void handlePacket(Packet arg0){
  try {
    final Object val=arg0.getProperty(OBJECT_PROPERTY_NAME);
    if (val != null) {
      handler.handleAsynchEvent(new ECFConnectionObjectPacketEvent(this,arg0,val));
    }
 else {
      handler.handleAsynchEvent(new ECFConnectionPacketEvent(this,arg0));
    }
  }
 catch (  final IOException e) {
    logException("String_Node_Str",e);
    try {
      disconnect();
    }
 catch (    final Exception e1) {
      logException("String_Node_Str",e1);
    }
  }
}

Fixed version (ground truth):
protected void handlePacket(Packet arg0){
  handleJidPacket(arg0);
  try {
    final Object val=arg0.getProperty(OBJECT_PROPERTY_NAME);
    if (val != null) {
      handler.handleAsynchEvent(new ECFConnectionObjectPacketEvent(this,arg0,val));
    }
 else {
      handler.handleAsynchEvent(new ECFConnectionPacketEvent(this,arg0));
    }
  }
 catch (  final IOException e) {
    logException("String_Node_Str",e);
    try {
      disconnect();
    }
 catch (    final Exception e1) {
      logException("String_Node_Str",e1);
    }
  }
}
Program: 94332
Project: 94332
Buggy source:
protected ID handleConnectResponse(ID originalTarget,Object serverData) throws Exception {
  if (originalTarget != null && !originalTarget.equals(getID())) {
    addNewRemoteMember(originalTarget,null);
    final ECFConnection conn=getECFConnection();
    accountManager.setConnection(conn.getXMPPConnection());
    chatRoomManager.setConnection(getConnectNamespace(),originalTarget,conn);
    searchManager.setConnection(getConnectNamespace(),originalTarget,conn);
    searchManager.setEnabled(!isGoogle(originalTarget));
    presenceHelper.setUser(new User(originalTarget));
    outgoingFileTransferContainerAdapter.setConnection(conn.getXMPPConnection());
    return originalTarget;
  }
 else   throw new ConnectException(Messages.XMPPContainer_EXCEPTION_INVALID_RESPONSE_FROM_SERVER);
}

Fixed version (ground truth):
protected ID handleConnectResponse(ID originalTarget,Object serverData) throws Exception {
  if (originalTarget != null && !originalTarget.equals(getID())) {
    resetTargetResource(originalTarget,serverData);
    addNewRemoteMember(originalTarget,null);
    final ECFConnection conn=getECFConnection();
    accountManager.setConnection(conn.getXMPPConnection());
    chatRoomManager.setConnection(getConnectNamespace(),originalTarget,conn);
    searchManager.setConnection(getConnectNamespace(),originalTarget,conn);
    searchManager.setEnabled(!isGoogle(originalTarget));
    presenceHelper.setUser(new User(originalTarget));
    outgoingFileTransferContainerAdapter.setConnection(conn.getXMPPConnection());
    return originalTarget;
  }
 else   throw new ConnectException(Messages.XMPPContainer_EXCEPTION_INVALID_RESPONSE_FROM_SERVER);
}
Program: 94333
Project: 94333
Buggy source:
public DnsSdDiscoveryServiceTest(String string,String scopes,String service,String protocol){
  super(ECF_DISCOVERY_DNSSD);
  setNamingAuthority("String_Node_Str");
  setScope(scopes);
  setServices(new String[]{service});
  setProtocol(protocol);
  setComparator(new DnsSdDiscoveryComparator());
  eventsToExpect=7;
}

Fixed version (ground truth):
public DnsSdDiscoveryServiceTest(String string,String scopes,String service,String protocol){
  super(ECF_DISCOVERY_DNSSD);
  setNamingAuthority(NAMING_AUTH);
  setScope(scopes);
  setServices(new String[]{service});
  setProtocol(protocol);
  setComparator(new DnsSdDiscoveryComparator());
  eventsToExpect=7;
}
Program: 94334
Project: 94334
Buggy source:
protected void setUp() throws Exception {
  super.setUp();
  final Properties props=new Properties();
  final URI uri=URI.create("String_Node_Str");
  Namespace namespace=discoveryLocator.getServicesNamespace();
  IServiceTypeID serviceTypeID=ServiceIDFactory.getDefault().createServiceTypeID(namespace,new String[]{"String_Node_Str"},new String[]{DOMAIN},new String[]{"String_Node_Str"},"String_Node_Str");
  assertNotNull(serviceTypeID);
  final ServiceProperties serviceProperties=new ServiceProperties(props);
  serviceProperties.setPropertyString("String_Node_Str","String_Node_Str");
  serviceProperties.setPropertyString("String_Node_Str","String_Node_Str");
  serviceInfo=new ServiceInfo(uri,"String_Node_Str",serviceTypeID,10,0,serviceProperties);
  assertNotNull(serviceInfo);
}

Fixed version (ground truth):
protected void setUp() throws Exception {
  super.setUp();
  final Properties props=new Properties();
  final URI uri=URI.create(SCHEME + "String_Node_Str" + DOMAIN_A_RECORD+ "String_Node_Str"+ PORT+ PATH);
  Namespace namespace=discoveryLocator.getServicesNamespace();
  IServiceTypeID serviceTypeID=ServiceIDFactory.getDefault().createServiceTypeID(namespace,new String[]{SCHEME},new String[]{DOMAIN},new String[]{PROTO},NAMING_AUTH);
  assertNotNull(serviceTypeID);
  final ServiceProperties serviceProperties=new ServiceProperties(props);
  serviceProperties.setPropertyString("String_Node_Str",PATH);
  serviceProperties.setPropertyString("String_Node_Str",SCHEME);
  serviceInfo=new ServiceInfo(uri,DOMAIN_A_RECORD,serviceTypeID,10,0,serviceProperties);
  assertNotNull(serviceInfo);
}
Program: 94335
Project: 94335
Buggy source:
private List getServiceInfos(List srvQueryResult){
  List infos=new ArrayList();
  for (Iterator iterator=srvQueryResult.iterator(); iterator.hasNext(); ) {
    SRVRecord srvRecord=(SRVRecord)iterator.next();
    int priority=srvRecord.getPriority();
    int weight=srvRecord.getWeight();
    int port=srvRecord.getPort();
    Name target=srvRecord.getTarget();
    String host=target.toString();
    host=host.substring(0,host.length() - 1);
    IServiceTypeID aServiceTypeID=new DnsSdServiceTypeID(getConnectNamespace(),srvRecord.getName());
    Properties props=new Properties();
    Lookup txtQuery=new Lookup(srvRecord.getName(),Type.TXT);
    Record[] txtQueryResults=txtQuery.run();
    for (int l=0; l < txtQueryResults.length; l++) {
      TXTRecord txtResult=(TXTRecord)txtQueryResults[l];
      List strings=txtResult.getStrings();
      for (Iterator itr=strings.iterator(); itr.hasNext(); ) {
        String str=(String)itr.next();
        String[] split=str.split("String_Node_Str");
        props.put(split[0],split[1]);
      }
    }
    String path=props.getProperty(DNS_SD_PATH);
    String proto=props.getProperty(DNS_SD_PTCL) == null ? aServiceTypeID.getProtocols()[0] : props.getProperty(DNS_SD_PTCL);
    URI uri=URI.create(proto + "String_Node_Str" + host+ "String_Node_Str"+ port+ (path == null ? "String_Node_Str" : path));
    IServiceInfo info=new ServiceInfo(uri,host,aServiceTypeID,priority,weight,new ServiceProperties(props));
    infos.add(info);
  }
  return infos;
}

Fixed version (ground truth):
private List getServiceInfos(List srvQueryResult){
  List infos=new ArrayList();
  for (Iterator iterator=srvQueryResult.iterator(); iterator.hasNext(); ) {
    SRVRecord srvRecord=(SRVRecord)iterator.next();
    int priority=srvRecord.getPriority();
    int weight=srvRecord.getWeight();
    int port=srvRecord.getPort();
    Name target=srvRecord.getTarget();
    String host=target.toString();
    host=host.substring(0,host.length() - 1);
    IServiceTypeID aServiceTypeID=new DnsSdServiceTypeID(getConnectNamespace(),srvRecord.getName());
    Properties props=new Properties();
    Lookup txtQuery=new Lookup(srvRecord.getName(),Type.TXT);
    txtQuery.setResolver(resolver);
    Record[] txtQueryResults=txtQuery.run();
    for (int l=0; l < txtQueryResults.length; l++) {
      TXTRecord txtResult=(TXTRecord)txtQueryResults[l];
      List strings=txtResult.getStrings();
      for (Iterator itr=strings.iterator(); itr.hasNext(); ) {
        String str=(String)itr.next();
        String[] split=str.split("String_Node_Str");
        props.put(split[0],split[1]);
      }
    }
    String path=props.getProperty(DNS_SD_PATH);
    String proto=props.getProperty(DNS_SD_PTCL) == null ? aServiceTypeID.getProtocols()[0] : props.getProperty(DNS_SD_PTCL);
    URI uri=URI.create(proto + "String_Node_Str" + host+ "String_Node_Str"+ port+ (path == null ? "String_Node_Str" : path));
    IServiceInfo info=new ServiceInfo(uri,host,aServiceTypeID,priority,weight,new ServiceProperties(props));
    infos.add(info);
  }
  return infos;
}
Program: 94336
Project: 94336
Buggy source:
/** 
 * This always returns the service type found for our local domain Use org.eclipse.ecf.provider.dnssrv.DnsSrvDisocoveryLocator.getServices(IServiceTypeID) with a wildcard query instead.
 * @see org.eclipse.ecf.discovery.IDiscoveryLocator#getServiceTypes()
 */
public IServiceTypeID[] getServiceTypes(){
  List result=new ArrayList();
  DnsSdServiceTypeID serviceTypeId=(DnsSdServiceTypeID)targetID;
  Lookup[] queries=serviceTypeId.getInternalQueries();
  for (int i=0; i < queries.length; i++) {
    Lookup query=queries[i];
    Record[] queryResult=query.run();
    int length=queryResult == null ? 0 : queryResult.length;
    for (int j=0; j < length; j++) {
      Record record=queryResult[j];
      if (record instanceof PTRRecord) {
        PTRRecord ptrRecord=(PTRRecord)record;
        result.add(new DnsSdServiceTypeID(getServicesNamespace(),ptrRecord.getTarget()));
      }
 else       if (record instanceof SRVRecord) {
        SRVRecord srvRecord=(SRVRecord)record;
        result.add(new DnsSdServiceTypeID(getServicesNamespace(),srvRecord.getName()));
      }
    }
  }
  return (IServiceTypeID[])result.toArray(new IServiceTypeID[result.size()]);
}

Fixed version (ground truth):
/** 
 * This always returns the service type found for our local domain Use org.eclipse.ecf.provider.dnssrv.DnsSrvDisocoveryLocator.getServices(IServiceTypeID) with a wildcard query instead.
 * @see org.eclipse.ecf.discovery.IDiscoveryLocator#getServiceTypes()
 */
public IServiceTypeID[] getServiceTypes(){
  List result=new ArrayList();
  DnsSdServiceTypeID serviceTypeId=(DnsSdServiceTypeID)targetID;
  Lookup[] queries=serviceTypeId.getInternalQueries();
  for (int i=0; i < queries.length; i++) {
    Lookup query=queries[i];
    query.setResolver(resolver);
    Record[] queryResult=query.run();
    int length=queryResult == null ? 0 : queryResult.length;
    for (int j=0; j < length; j++) {
      Record record=queryResult[j];
      if (record instanceof PTRRecord) {
        PTRRecord ptrRecord=(PTRRecord)record;
        result.add(new DnsSdServiceTypeID(getServicesNamespace(),ptrRecord.getTarget()));
      }
 else       if (record instanceof SRVRecord) {
        SRVRecord srvRecord=(SRVRecord)record;
        result.add(new DnsSdServiceTypeID(getServicesNamespace(),srvRecord.getName()));
      }
    }
  }
  return (IServiceTypeID[])result.toArray(new IServiceTypeID[result.size()]);
}
Program: 94337
Project: 94337
Buggy source:
public void connect(ID aTargetID,IConnectContext connectContext) throws ContainerConnectException {
  if (targetID != null || getConfig() == null) {
    throw new ContainerConnectException("String_Node_Str");
  }
  if (aTargetID == null || !(aTargetID instanceof DnsSdServiceTypeID)) {
    ResolverConfig config=new ResolverConfig();
    Name[] searchPaths=config.searchPath();
    if (searchPaths.length >= 0) {
      targetID=new DnsSdServiceTypeID();
      targetID.setScopes(searchPaths);
    }
 else {
      throw new ContainerConnectException("String_Node_Str");
    }
  }
 else {
    targetID=(DnsSdServiceTypeID)aTargetID;
  }
  fireContainerEvent(new ContainerConnectingEvent(this.getID(),targetID,connectContext));
  fireContainerEvent(new ContainerConnectedEvent(this.getID(),targetID));
}

Fixed version (ground truth):
public void connect(ID aTargetID,IConnectContext connectContext) throws ContainerConnectException {
  if (targetID != null || getConfig() == null) {
    throw new ContainerConnectException("String_Node_Str");
  }
  if (aTargetID == null || !(aTargetID instanceof DnsSdServiceTypeID)) {
    ResolverConfig config=new ResolverConfig();
    Name[] searchPaths=config.searchPath();
    if (searchPaths.length >= 0) {
      targetID=new DnsSdServiceTypeID();
      targetID.setScopes(searchPaths);
    }
 else {
      throw new ContainerConnectException("String_Node_Str");
    }
  }
 else {
    targetID=(DnsSdServiceTypeID)aTargetID;
  }
  try {
    resolver=new SimpleResolver();
  }
 catch (  UnknownHostException e) {
    throw new ContainerConnectException(e);
  }
  fireContainerEvent(new ContainerConnectingEvent(this.getID(),targetID,connectContext));
  fireContainerEvent(new ContainerConnectedEvent(this.getID(),targetID));
}
Program: 94338
Project: 94338
Buggy source:
private List getSRVRecords(Lookup[] queries){
  List srvRecords=new ArrayList();
  for (int i=0; i < queries.length; i++) {
    Lookup query=queries[i];
    Record[] queryResult=query.run();
    int length=queryResult == null ? 0 : queryResult.length;
    for (int j=0; j < length; j++) {
      Record[] srvQueryResult=null;
      Record record=queryResult[j];
      if (record instanceof PTRRecord) {
        PTRRecord ptrRecord=(PTRRecord)record;
        Name target=ptrRecord.getTarget();
        Lookup srvQuery=new Lookup(target,Type.SRV);
        srvQueryResult=srvQuery.run();
      }
 else       if (record instanceof SRVRecord) {
        srvQueryResult=new SRVRecord[]{(SRVRecord)record};
      }
      srvRecords.addAll(Arrays.asList(srvQueryResult));
    }
  }
  return srvRecords;
}

Fixed version (ground truth):
private List getSRVRecords(Lookup[] queries){
  List srvRecords=new ArrayList();
  for (int i=0; i < queries.length; i++) {
    Lookup query=queries[i];
    query.setResolver(resolver);
    Record[] queryResult=query.run();
    int length=queryResult == null ? 0 : queryResult.length;
    for (int j=0; j < length; j++) {
      Record[] srvQueryResult=null;
      Record record=queryResult[j];
      if (record instanceof PTRRecord) {
        PTRRecord ptrRecord=(PTRRecord)record;
        Name target=ptrRecord.getTarget();
        Lookup srvQuery=new Lookup(target,Type.SRV);
        srvQuery.setResolver(resolver);
        srvQueryResult=srvQuery.run();
      }
 else       if (record instanceof SRVRecord) {
        srvQueryResult=new SRVRecord[]{(SRVRecord)record};
      }
      srvRecords.addAll(Arrays.asList(srvQueryResult));
    }
  }
  return srvRecords;
}
Program: 94339
Project: 94339
Buggy source:
public void setScopes(Name[] searchPaths){
  String[] s=new String[searchPaths.length];
  for (int i=0; i < searchPaths.length; i++) {
    s[i]=searchPaths[i].toString();
  }
  scopes=s;
}

Fixed version (ground truth):
public void setScopes(String[] searchPaths){
  scopes=searchPaths;
}
Program: 94340
Project: 94340
Buggy source:
protected InputStream wrapTransferReadInputStream(InputStream inputStream,IProgressMonitor monitor){
  return new PollingInputStream(remoteFileContents,getRetryAttempts(),monitor);
}

Fixed version (ground truth):
protected InputStream wrapTransferReadInputStream(InputStream inputStream,IProgressMonitor monitor){
  return new PollingInputStream(remoteFileContents,getRetryAttempts(),monitor,readTimeoutMessage,closeTimeoutMessage);
}
Program: 94341
Project: 94341
Buggy source:
private void logError(String message,IOException e){
  Activator.getDefault().log(new Status(IStatus.ERROR,Activator.PLUGIN_ID,IStatus.ERROR,message,e));
}

Fixed version (ground truth):
private void logError(String message,IOException e){
  Activator a=Activator.getDefault();
  if (a != null)   a.log(new Status(IStatus.ERROR,Activator.PLUGIN_ID,IStatus.ERROR,message,e));
}
Program: 94342
Project: 94342
Buggy source:
/** 
 * Wraps the underlying stream's method.
 * @param buffer - the buffer into which the data is read.
 * @param off - the start offset of the data.
 * @param len - the maximum number of bytes read.
 * @return the total number of bytes read into the buffer, or -1 if there isno more data because the end of the stream has been reached.
 * @throws OperationCanceledException if the progress monitor is canceled
 * @throws InterruptedIOException if the underlying operation times out numAttempts times and no data was received, bytesTransferred will be zero
 * @throws IOException if an i/o error occurs
 */
public int read(byte[] buffer,int off,int len) throws IOException {
  int attempts=0;
  for (; ; ) {
    if (checkCancellation())     throw new OperationCanceledException();
    try {
      return in.read(buffer,off,len);
    }
 catch (    InterruptedIOException e) {
      if (e.bytesTransferred != 0)       return e.bytesTransferred;
      if (++attempts == numAttempts)       throw new InterruptedIOException("String_Node_Str");
    }
  }
}

Fixed version (ground truth):
/** 
 * Wraps the underlying stream's method.
 * @param buffer - the buffer into which the data is read.
 * @param off - the start offset of the data.
 * @param len - the maximum number of bytes read.
 * @return the total number of bytes read into the buffer, or -1 if there isno more data because the end of the stream has been reached.
 * @throws OperationCanceledException if the progress monitor is canceled
 * @throws InterruptedIOException if the underlying operation times out numAttempts times and no data was received, bytesTransferred will be zero
 * @throws IOException if an i/o error occurs
 */
public int read(byte[] buffer,int off,int len) throws IOException {
  int attempts=0;
  for (; ; ) {
    if (checkCancellation())     throw new OperationCanceledException();
    try {
      return in.read(buffer,off,len);
    }
 catch (    InterruptedIOException e) {
      if (e.bytesTransferred != 0)       return e.bytesTransferred;
      if (++attempts == numAttempts)       throw new InterruptedIOException(readTimeoutMessage);
    }
  }
}