nus-yam/ex-repair huggingface dataset:
Program: 152968
Project: 152968
Buggy source:
private URL checkBundleJarsForClass(Bundle bundle,String name){
  String cname=name.replace('.','/') + "String_Node_Str";
  for (Enumeration e=bundle.findEntries("String_Node_Str","String_Node_Str",true); e != null && e.hasMoreElements(); ) {
    URL url=(URL)e.nextElement();
    try {
      JarInputStream jin=new JarInputStream(url.openStream());
      for (JarEntry ze=jin.getNextJarEntry(); ze != null; ze=jin.getNextJarEntry()) {
        if (ze.getName().equals(cname)) {
          jin.close();
          return url;
        }
      }
      jin.close();
    }
 catch (    IOException e1) {
      if (log.isTraceEnabled())       log.trace("String_Node_Str" + url.toString() + "String_Node_Str"+ e1.getMessage());
    }
  }
  return null;
}

Fixed version (ground truth):
private static URL checkBundleJarsForClass(Bundle bundle,String name){
  String cname=name.replace('.','/') + "String_Node_Str";
  for (Enumeration e=bundle.findEntries("String_Node_Str","String_Node_Str",true); e != null && e.hasMoreElements(); ) {
    URL url=(URL)e.nextElement();
    try {
      JarInputStream jin=new JarInputStream(url.openStream());
      for (JarEntry ze=jin.getNextJarEntry(); ze != null; ze=jin.getNextJarEntry()) {
        if (ze.getName().equals(cname)) {
          jin.close();
          return url;
        }
      }
      jin.close();
    }
 catch (    IOException e1) {
      if (log.isTraceEnabled())       log.trace("String_Node_Str" + url.toString() + "String_Node_Str"+ e1.getMessage());
    }
  }
  return null;
}
Program: 152970
Project: 152970
Buggy source:
protected Class findClass(String name) throws ClassNotFoundException {
  try {
    return this.backingBundle.loadClass(name);
  }
 catch (  ClassNotFoundException cnfe) {
    if (log.isTraceEnabled()) {
      debugClassLoading(name,null);
    }
    ClassNotFoundException e=new ClassNotFoundException(name + "String_Node_Str" + backingBundle.getSymbolicName()+ "String_Node_Str",cnfe);
    throw e;
  }
catch (  NoClassDefFoundError ncdfe) {
    if (log.isTraceEnabled()) {
      String cname=ncdfe.getMessage().replace('/','.');
      debugClassLoading(cname,name);
    }
    NoClassDefFoundError e=new NoClassDefFoundError(name + "String_Node_Str" + backingBundle.getSymbolicName()+ "String_Node_Str");
    e.initCause(e);
    throw e;
  }
}

Fixed version (ground truth):
protected Class findClass(String name) throws ClassNotFoundException {
  try {
    return this.backingBundle.loadClass(name);
  }
 catch (  ClassNotFoundException cnfe) {
    if (log.isTraceEnabled()) {
      debugClassLoading(name,null);
    }
    throw new ClassNotFoundException(name + "String_Node_Str" + backingBundle.getSymbolicName()+ "String_Node_Str",cnfe);
  }
catch (  NoClassDefFoundError ncdfe) {
    if (log.isTraceEnabled()) {
      String cname=ncdfe.getMessage().replace('/','.');
      debugClassLoading(cname,name);
    }
    NoClassDefFoundError e=new NoClassDefFoundError(name + "String_Node_Str" + backingBundle.getSymbolicName()+ "String_Node_Str");
    e.initCause(e);
    throw e;
  }
}
Program: 152971
Project: 152971
Buggy source:
private Version hasImport(Bundle bundle,String packageName){
  Dictionary dict=bundle.getHeaders();
  String imports=(String)dict.get(Constants.IMPORT_PACKAGE);
  Version v=getVersion(imports,packageName);
  if (v != null) {
    return v;
  }
  String dynimports=(String)dict.get(Constants.DYNAMICIMPORT_PACKAGE);
  if (dynimports != null) {
    for (StringTokenizer strok=new StringTokenizer(dynimports,"String_Node_Str"); strok.hasMoreTokens(); ) {
      StringTokenizer parts=new StringTokenizer(strok.nextToken(),"String_Node_Str");
      String pkg=parts.nextToken().trim();
      if (pkg.endsWith("String_Node_Str") && packageName.startsWith(pkg.substring(0,pkg.length() - 2)) || pkg.equals("String_Node_Str")) {
        Version version=Version.emptyVersion;
        for (; parts.hasMoreTokens(); ) {
          String modifier=parts.nextToken().trim();
          if (modifier.startsWith("String_Node_Str")) {
            version=Version.parseVersion(modifier.substring(modifier.indexOf("String_Node_Str") + 1).trim());
          }
        }
        return version;
      }
    }
  }
  return null;
}

Fixed version (ground truth):
private static Version hasImport(Bundle bundle,String packageName){
  Dictionary dict=bundle.getHeaders();
  String imports=(String)dict.get(Constants.IMPORT_PACKAGE);
  Version v=getVersion(imports,packageName);
  if (v != null) {
    return v;
  }
  String dynimports=(String)dict.get(Constants.DYNAMICIMPORT_PACKAGE);
  if (dynimports != null) {
    for (StringTokenizer strok=new StringTokenizer(dynimports,"String_Node_Str"); strok.hasMoreTokens(); ) {
      StringTokenizer parts=new StringTokenizer(strok.nextToken(),"String_Node_Str");
      String pkg=parts.nextToken().trim();
      if (pkg.endsWith("String_Node_Str") && packageName.startsWith(pkg.substring(0,pkg.length() - 2)) || pkg.equals("String_Node_Str")) {
        Version version=Version.emptyVersion;
        for (; parts.hasMoreTokens(); ) {
          String modifier=parts.nextToken().trim();
          if (modifier.startsWith("String_Node_Str")) {
            version=Version.parseVersion(modifier.substring(modifier.indexOf("String_Node_Str") + 1).trim());
          }
        }
        return version;
      }
    }
  }
  return null;
}
Program: 152972
Project: 152972
Buggy source:
private Version hasExport(Bundle bundle,String packageName){
  Dictionary dict=bundle.getHeaders();
  return getVersion((String)dict.get(Constants.EXPORT_PACKAGE),packageName);
}

Fixed version (ground truth):
private static Version hasExport(Bundle bundle,String packageName){
  Dictionary dict=bundle.getHeaders();
  return getVersion((String)dict.get(Constants.EXPORT_PACKAGE),packageName);
}
Program: 152973
Project: 152973
Buggy source:
private String getBundleName(Bundle bundle){
  Dictionary dict=bundle.getHeaders();
  String name=(String)dict.get(Constants.BUNDLE_NAME);
  String sname=(String)dict.get(Constants.BUNDLE_SYMBOLICNAME);
  return (sname != null ? sname : name) + "String_Node_Str" + bundle.getLocation()+ "String_Node_Str";
}

Fixed version (ground truth):
private static String getBundleName(Bundle bundle){
  Dictionary dict=bundle.getHeaders();
  String name=(String)dict.get(Constants.BUNDLE_NAME);
  String sname=(String)dict.get(Constants.BUNDLE_SYMBOLICNAME);
  return (sname != null ? sname : name) + "String_Node_Str" + bundle.getLocation()+ "String_Node_Str";
}
Program: 152974
Project: 152974
Buggy source:
/** 
 * Create a service proxy over the service reference. The proxy purpose is to transparently decouple the client from holding a strong reference to the service (which might go away).
 * @param ref
 * @return
 */
private Object createServiceProxy(ServiceReference ref){
  String[] classes=(String[])ref.getProperty(Constants.OBJECTCLASS);
  List intfs=new ArrayList();
  Class proxyClass=null;
  for (int i=0; i < classes.length; i++) {
    Bundle loader=ref.getBundle();
    try {
      Class clazz=loader.loadClass(classes[i]);
      if (clazz.isInterface())       intfs.add(clazz);
 else {
        proxyClass=clazz;
      }
    }
 catch (    ClassNotFoundException cnfex) {
      throw (RuntimeException)new IllegalArgumentException("String_Node_Str").initCause(cnfex);
    }
  }
  ProxyFactory factory=new ProxyFactory();
  if (!intfs.isEmpty())   factory.setInterfaces((Class[])intfs.toArray(new Class[intfs.size()]));
  if (proxyClass != null) {
    factory.setProxyTargetClass(true);
    factory.setTargetClass(proxyClass);
  }
  if (this.interceptors != null) {
    for (int i=0; i < this.interceptors.length; i++) {
      factory.addAdvisor(this.advisorAdapterRegistry.wrap(this.interceptors[i]));
    }
  }
  factory.addAdvice(new OsgiServiceStaticInterceptor(context,ref,contextClassLoader));
  return factory.getProxy(BundleDelegatingClassLoader.createBundleClassLoaderFor(ref.getBundle(),ProxyFactory.class.getClassLoader()));
}

Fixed version (ground truth):
/** 
 * Create a service proxy over the service reference. The proxy purpose is to transparently decouple the client from holding a strong reference to the service (which might go away).
 * @param ref
 */
private Object createServiceProxy(ServiceReference ref){
  String[] classes=(String[])ref.getProperty(Constants.OBJECTCLASS);
  List intfs=new ArrayList();
  Class proxyClass=null;
  for (int i=0; i < classes.length; i++) {
    Bundle loader=ref.getBundle();
    try {
      Class clazz=loader.loadClass(classes[i]);
      if (clazz.isInterface())       intfs.add(clazz);
 else {
        proxyClass=clazz;
      }
    }
 catch (    ClassNotFoundException cnfex) {
      throw (RuntimeException)new IllegalArgumentException("String_Node_Str").initCause(cnfex);
    }
  }
  ProxyFactory factory=new ProxyFactory();
  if (!intfs.isEmpty())   factory.setInterfaces((Class[])intfs.toArray(new Class[intfs.size()]));
  if (proxyClass != null) {
    factory.setProxyTargetClass(true);
    factory.setTargetClass(proxyClass);
  }
  if (this.interceptors != null) {
    for (int i=0; i < this.interceptors.length; i++) {
      factory.addAdvisor(this.advisorAdapterRegistry.wrap(this.interceptors[i]));
    }
  }
  factory.addAdvice(new OsgiServiceStaticInterceptor(context,ref,contextClassLoader));
  return factory.getProxy(BundleDelegatingClassLoader.createBundleClassLoaderFor(ref.getBundle(),ProxyFactory.class.getClassLoader()));
}
Program: 152975
Project: 152975
Buggy source:
/** 
 * Create the dynamic storage used internally.
 * @return
 */
protected Collection createInternalDynamicStorage(){
  return new DynamicCollection();
}

Fixed version (ground truth):
/** 
 * Create the dynamic storage used internally.
 */
protected Collection createInternalDynamicStorage(){
  return new DynamicCollection();
}
Program: 152976
Project: 152976
Buggy source:
public void serviceChanged(ServiceEvent event){
  ServiceReference ref=event.getServiceReference();
  Long serviceId=(Long)ref.getProperty(Constants.SERVICE_ID);
  boolean found=false;
switch (event.getType()) {
case (ServiceEvent.REGISTERED):
case (ServiceEvent.MODIFIED):
synchronized (serviceReferences) {
      if (!serviceReferences.containsKey(serviceId)) {
        found=true;
        serviceReferences.put(serviceId,createServiceProxy(ref));
        serviceIDs.add(serviceId);
      }
    }
  if (found)   OsgiServiceBindingUtils.callListenersBind(context,ref,listeners);
break;
case (ServiceEvent.UNREGISTERING):
synchronized (serviceReferences) {
Object proxy=serviceReferences.remove(serviceId);
found=serviceIDs.remove(serviceId);
if (proxy != null) {
  invalidateProxy(proxy);
}
}
if (found) OsgiServiceBindingUtils.callListenersUnbind(context,ref,listeners);
break;
default :
throw new IllegalArgumentException("String_Node_Str");
}
}

Fixed version (ground truth):
public void serviceChanged(ServiceEvent event){
  try {
    ServiceReference ref=event.getServiceReference();
    Long serviceId=(Long)ref.getProperty(Constants.SERVICE_ID);
    boolean found=false;
switch (event.getType()) {
case (ServiceEvent.REGISTERED):
case (ServiceEvent.MODIFIED):
synchronized (serviceReferences) {
        if (!serviceReferences.containsKey(serviceId)) {
          found=true;
          serviceReferences.put(serviceId,createServiceProxy(ref));
          serviceIDs.add(serviceId);
        }
      }
    if (found)     OsgiServiceBindingUtils.callListenersBind(context,ref,listeners);
  break;
case (ServiceEvent.UNREGISTERING):
synchronized (serviceReferences) {
  Object proxy=serviceReferences.remove(serviceId);
  found=serviceIDs.remove(serviceId);
  if (proxy != null) {
    invalidateProxy(proxy);
  }
}
if (found) OsgiServiceBindingUtils.callListenersUnbind(context,ref,listeners);
break;
default :
throw new IllegalArgumentException("String_Node_Str");
}
}
 catch (Error e) {
if (log.isErrorEnabled()) {
log.error("String_Node_Str",e);
}
throw e;
}
catch (RuntimeException re) {
if (log.isWarnEnabled()) {
log.warn("String_Node_Str",re);
}
throw re;
}
}
Program: 152977
Project: 152977
Buggy source:
public String toString(){
  return "String_Node_Str" + filter;
}

Fixed version (ground truth):
public String toString(){
  return filter;
}
Program: 152978
Project: 152978
Buggy source:
protected Object doInvoke(Object service,MethodInvocation invocation) throws Throwable {
  if (!canCacheClassLoader)   tccl=determineClassLoader(context,serviceReference,contextClassLoader);
  ClassLoader oldCL=null;
  if (tccl != null) {
    if (log.isTraceEnabled())     log.trace("String_Node_Str" + tccl);
    try {
      oldCL=Thread.currentThread().getContextClassLoader();
      Thread.currentThread().setContextClassLoader(tccl);
      return super.doInvoke(service,invocation);
    }
  finally {
      if (log.isTraceEnabled())       log.trace("String_Node_Str" + tccl);
      Thread.currentThread().setContextClassLoader(oldCL);
    }
  }
  return super.doInvoke(service,invocation);
}

Fixed version (ground truth):
protected Object doInvoke(Object service,MethodInvocation invocation) throws Throwable {
  if (!canCacheClassLoader)   tccl=determineClassLoader(context,serviceReference,contextClassLoader);
  ClassLoader oldCL=null;
  boolean trace=log.isTraceEnabled();
  if ((tccl != null && canCacheClassLoader) || !canCacheClassLoader) {
    if (trace)     log.trace("String_Node_Str" + tccl);
    try {
      oldCL=Thread.currentThread().getContextClassLoader();
      Thread.currentThread().setContextClassLoader(tccl);
      return super.doInvoke(service,invocation);
    }
  finally {
      if (trace)       log.trace("String_Node_Str" + tccl);
      Thread.currentThread().setContextClassLoader(oldCL);
    }
  }
  return super.doInvoke(service,invocation);
}
Program: 152979
Project: 152979
Buggy source:
public OsgiServiceClassLoaderInvoker(BundleContext context,ServiceReference reference,int contextClassLoader){
  this.context=context;
  this.serviceReference=reference;
  canCacheClassLoader=!(contextClassLoader == ReferenceClassLoadingOptions.SERVICE_PROVIDER);
  if (canCacheClassLoader)   this.tccl=determineClassLoader(context,null,contextClassLoader);
}

Fixed version (ground truth):
public OsgiServiceClassLoaderInvoker(BundleContext context,ServiceReference reference,int contextClassLoader){
  this.context=context;
  this.serviceReference=reference;
  canCacheClassLoader=!(contextClassLoader == ReferenceClassLoadingOptions.SERVICE_PROVIDER);
  if (canCacheClassLoader) {
    this.tccl=determineClassLoader(context,null,contextClassLoader);
  }
}
Program: 152980
Project: 152980
Buggy source:
public void serviceChanged(ServiceEvent event){
  ServiceReference ref=event.getServiceReference();
  log.debug("String_Node_Str" + ref);
  long serviceId=((Long)ref.getProperty(Constants.SERVICE_ID)).longValue();
  Integer rank=(Integer)ref.getProperty(Constants.SERVICE_RANKING);
  int ranking=(rank == null ? 0 : rank.intValue());
switch (event.getType()) {
case (ServiceEvent.REGISTERED):
    if (updateWrapperIfNecessary(ref,serviceId,ranking)) {
      callListenersBind(ref);
    }
  break;
case (ServiceEvent.MODIFIED):
if (updateWrapperIfNecessary(ref,serviceId,ranking)) {
  callListenersBind(ref);
}
break;
case (ServiceEvent.UNREGISTERING):
boolean updated=false;
synchronized (OsgiServiceDynamicInterceptor.class) {
if (wrapper != null) {
if (serviceId == wrapper.getServiceId()) {
updated=true;
wrapper.cleanup();
wrapper=null;
}
}
}
if (updated) callListenersUnbind(ref);
break;
default :
throw new IllegalArgumentException("String_Node_Str");
}
}

Fixed version (ground truth):
public void serviceChanged(ServiceEvent event){
  ServiceReference ref=event.getServiceReference();
  long serviceId=((Long)ref.getProperty(Constants.SERVICE_ID)).longValue();
  Integer rank=(Integer)ref.getProperty(Constants.SERVICE_RANKING);
  int ranking=(rank == null ? 0 : rank.intValue());
switch (event.getType()) {
case (ServiceEvent.REGISTERED):
    if (updateWrapperIfNecessary(ref,serviceId,ranking)) {
      callListenersBind(ref);
    }
  break;
case (ServiceEvent.MODIFIED):
if (updateWrapperIfNecessary(ref,serviceId,ranking)) {
  callListenersBind(ref);
}
break;
case (ServiceEvent.UNREGISTERING):
boolean updated=false;
synchronized (OsgiServiceDynamicInterceptor.class) {
if (wrapper != null) {
if (serviceId == wrapper.getServiceId()) {
updated=true;
wrapper.cleanup();
wrapper=null;
}
}
}
if (updated) callListenersUnbind(ref);
try {
ServiceReference refs[]=context.getServiceReferences(clazz,filter);
if (refs != null && refs.length > 0) {
serviceChanged(new ServiceEvent(ServiceEvent.REGISTERED,refs[0]));
}
}
 catch (InvalidSyntaxException ise) {
throw new IllegalArgumentException("String_Node_Str");
}
break;
default :
throw new IllegalArgumentException("String_Node_Str");
}
}
Program: 152982
Project: 152982
Buggy source:
/** 
 * The simple service should have been exported as an OSGi service, which we can verify using the OSGi service APIs. In a Spring bundle, using osgi:reference is a much easier way to get a reference to a published service.
 */
public void testWeatherServiceExported(){
  waitOnContextCreation("String_Node_Str");
  waitOnContextCreation("String_Node_Str");
  BundleContext context=getBundleContext();
  ServiceReference ref=context.getServiceReference("String_Node_Str");
  assertNotNull("String_Node_Str",ref);
  try {
    Object weather=context.getService(ref);
    assertNotNull("String_Node_Str",weather);
  }
  finally {
    context.ungetService(ref);
  }
}

Fixed version (ground truth):
/** 
 * The simple service should have been exported as an OSGi service, which we can verify using the OSGi service APIs. <p/> In a Spring bundle, using osgi:reference is a much easier way to get a reference to a published service.
 */
public void testWeatherServiceExported(){
  waitOnContextCreation("String_Node_Str");
  waitOnContextCreation("String_Node_Str");
  BundleContext context=getBundleContext();
  ServiceReference ref=context.getServiceReference("String_Node_Str");
  assertNotNull("String_Node_Str",ref);
  try {
    WeatherService weather=(WeatherService)context.getService(ref);
    assertNotNull("String_Node_Str",weather);
    assertEquals(new Double(15.0),weather.getHistoricalHigh(new GregorianCalendar(2004,0,1).getTime()));
  }
  finally {
    context.ungetService(ref);
  }
}
Program: 152983
Project: 152983
Buggy source:
/** 
 * The location of the packaged OSGi bundles to be installed for this test. Values are Spring resource paths. The bundles we want to use are part of the same multi-project maven build as this project is. Hence we use the localMavenArtifact helper method to find the bundles produced by the package phase of the maven build (these tests will run after the packaging phase, in the integration-test phase).  JUnit, commons-logging, spring-core and the spring OSGi test bundle are automatically included so do not need to be specified here.
 */
protected String[] getBundleLocations(){
  return new String[]{localMavenArtifact("String_Node_Str","String_Node_Str","String_Node_Str"),localMavenArtifact("String_Node_Str","String_Node_Str","String_Node_Str"),localMavenArtifact("String_Node_Str","String_Node_Str","String_Node_Str"),localMavenArtifact("String_Node_Str","String_Node_Str","String_Node_Str"),localMavenArtifact("String_Node_Str","String_Node_Str","String_Node_Str"),localMavenArtifact("String_Node_Str","String_Node_Str","String_Node_Str"),localMavenArtifact("String_Node_Str","String_Node_Str","String_Node_Str"),localMavenArtifact("String_Node_Str","String_Node_Str","String_Node_Str"),localMavenArtifact("String_Node_Str","String_Node_Str","String_Node_Str")};
}

Fixed version (ground truth):
/** 
 * The location of the packaged OSGi bundles to be installed for this test. Values are Spring resource paths. The bundles we want to use are part of the same multi-project maven build as this project is. Hence we use the localMavenArtifact helper method to find the bundles produced by the package phase of the maven build (these tests will run after the packaging phase, in the integration-test phase). <p/> JUnit, commons-logging, spring-core and the spring OSGi test bundle are automatically included so do not need to be specified here.
 */
protected String[] getBundleLocations(){
  return new String[]{localMavenArtifact("String_Node_Str","String_Node_Str","String_Node_Str"),localMavenArtifact("String_Node_Str","String_Node_Str","String_Node_Str"),localMavenArtifact("String_Node_Str","String_Node_Str","String_Node_Str"),localMavenArtifact("String_Node_Str","String_Node_Str","String_Node_Str"),localMavenArtifact("String_Node_Str","String_Node_Str","String_Node_Str"),localMavenArtifact("String_Node_Str","String_Node_Str","String_Node_Str"),localMavenArtifact("String_Node_Str","String_Node_Str","String_Node_Str"),localMavenArtifact("String_Node_Str","String_Node_Str","String_Node_Str"),localMavenArtifact("String_Node_Str","String_Node_Str","String_Node_Str")};
}
Program: 152985
Project: 152985
Buggy source:
public void release(){
  _mediaPlayer.release();
}

Fixed version (ground truth):
public void release(){
  if (_state != RELEASED) {
    _mediaPlayer.release();
    _state=RELEASED;
  }
}
Program: 152986
Project: 152986
Buggy source:
public void setOnCompletionListener(final OnCompletionListener listener){
  _mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener(){
    @Override public void onCompletion(    MediaPlayer mp){
      listener.onCompletion(MusicPlayer.this);
    }
  }
);
}

Fixed version (ground truth):
public void setOnCompletionListener(final OnCompletionListener listener){
  if (_state != RELEASED) {
    _mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener(){
      @Override public void onCompletion(      MediaPlayer mp){
        listener.onCompletion(MusicPlayer.this);
      }
    }
);
  }
}
Program: 152987
Project: 152987
Buggy source:
public void setVolume(float volume){
  _mediaPlayer.setVolume(volume,volume);
}

Fixed version (ground truth):
public void setVolume(float volume){
  if (_state != RELEASED) {
    _mediaPlayer.setVolume(volume,volume);
  }
}
Program: 152988
Project: 152988
Buggy source:
public void seekToPosition(int positionMillis){
  _mediaPlayer.seekTo(positionMillis);
  _startTime=System.currentTimeMillis() - positionMillis;
}

Fixed version (ground truth):
public void seekToPosition(int positionMillis){
  if (_state == PLAYING || _state == PAUSED) {
    _mediaPlayer.seekTo(positionMillis);
    _startTime=System.currentTimeMillis() - positionMillis;
  }
}
Program: 152989
Project: 152989
Buggy source:
public int getSongLength(){
  return _mediaPlayer.getDuration();
}

Fixed version (ground truth):
public int getSongLength(){
  if (_state == PLAYING || _state == PAUSED || _state == STOPPED) {
    return _mediaPlayer.getDuration();
  }
  return 0;
}
Program: 152990
Project: 152990
Buggy source:
public void stop(){
  if (_state != STOPPED) {
    _mediaPlayer.stop();
    _state=STOPPED;
  }
}

Fixed version (ground truth):
public void stop(){
  if (_state == PLAYING || _state == PAUSED || _state == STOPPED) {
    _mediaPlayer.stop();
    _state=STOPPED;
  }
}
Program: 152991
Project: 152991
Buggy source:
public void loop(){
  _mediaPlayer.setLooping(true);
  play();
}

Fixed version (ground truth):
public void loop(){
  if (_state == IDLE || _state == PAUSED) {
    _mediaPlayer.setLooping(true);
    play();
  }
}
Program: 152992
Project: 152992
Buggy source:
public boolean isLooping(){
  return _mediaPlayer.isLooping();
}

Fixed version (ground truth):
public boolean isLooping(){
  if (_state != RELEASED) {
    return _mediaPlayer.isLooping();
  }
  return false;
}
Program: 152993
Project: 152993
Buggy source:
public BeatTrack(OnCompletionListener listener){
  loadSong(Song.RETRO);
  beatsInRange=new ArrayList<Beat>();
  last_combo_time=0;
  display_uber_brag=false;
  musicPlayer.setOnCompletionListener(new OnCompletionListener(){
    public void onCompletion(    MusicPlayer mp){
      mp.stop();
    }
  }
);
  musicPlayer.setOnCompletionListener(listener);
  isHolding=false;
  combo=0;
  comboStr="String_Node_Str" + String.valueOf(combo);
  paint=new Paint();
  paint.setTextSize(20.0f);
  paint.setFakeBoldText(true);
  paint.setStrokeCap(Cap.ROUND);
  paint.setAntiAlias(true);
  brag_text_pos=BBTHGame.WIDTH / 2.0f + BEAT_TRACK_WIDTH / 2.0f - paint.measureText("String_Node_Str" + comboStr + "String_Node_Str") / 2.0f;
}

Fixed version (ground truth):
public BeatTrack(OnCompletionListener listener){
  loadSong(Song.RETRO);
  beatsInRange=new ArrayList<Beat>();
  onCompletionListener=listener;
  stopped=false;
  last_combo_time=0;
  display_uber_brag=false;
  isHolding=false;
  combo=0;
  comboStr="String_Node_Str" + String.valueOf(combo);
  paint=new Paint();
  paint.setTextSize(20.0f);
  paint.setFakeBoldText(true);
  paint.setStrokeCap(Cap.ROUND);
  paint.setAntiAlias(true);
  brag_text_pos=BBTHGame.WIDTH / 2.0f + BEAT_TRACK_WIDTH / 2.0f - paint.measureText("String_Node_Str" + comboStr + "String_Node_Str") / 2.0f;
}
Program: 152994
Project: 152994
Buggy source:
public void stopMusic(){
  musicPlayer.stop();
}

Fixed version (ground truth):
public void stopMusic(){
  if (musicPlayer != null) {
    musicPlayer.stop();
    musicPlayer.release();
  }
}
Program: 152995
Project: 152995
Buggy source:
public final void loadSong(Song song){
  musicPlayer=new MusicPlayer(GameActivity.instance,song.songId);
  beatTracker=new BeatTracker(musicPlayer,song.trackId);
}

Fixed version (ground truth):
public final void loadSong(Song song){
  stopMusic();
  musicPlayer=new MusicPlayer(GameActivity.instance,song.songId);
  beatTracker=new BeatTracker(musicPlayer,song.trackId);
  musicPlayer.setOnCompletionListener(onCompletionListener);
  stopped=false;
}
Program: 152996
Project: 152996
Buggy source:
@Override public void onCompletion(MusicPlayer mp){
  mp.stop();
  if (singlePlayer) {
    sim.simulateCustomEvent(0,0,BBTHSimulation.MUSIC_STOPPED_EVENT,true);
  }
 else {
    sim.recordCustomEvent(0,0,BBTHSimulation.MUSIC_STOPPED_EVENT);
  }
}

Fixed version (ground truth):
@Override public void onCompletion(MusicPlayer mp){
  mp.stop();
  mp.release();
  if (singlePlayer) {
    sim.simulateCustomEvent(0,0,BBTHSimulation.MUSIC_STOPPED_EVENT,true);
  }
 else {
    sim.recordCustomEvent(0,0,BBTHSimulation.MUSIC_STOPPED_EVENT);
  }
}
Program: 152997
Project: 152997
Buggy source:
@Override protected void simulateCustomEvent(float x,float y,int code,boolean isServer){
  if (code < 0) {
    this.song=Song.fromInt(code);
    setupEvents();
  }
 else {
    Player player=playerMap.get(isServer);
    UnitType type=UnitType.fromInt(code);
    if (type != null) {
      player.setUnitType(type);
    }
 else     if (code == TUTORIAL_DONE_EVENT) {
      if (isServer) {
        serverReady=true;
      }
 else {
        clientReady=true;
      }
      if (serverReady && clientReady) {
        Unit.resetNextHashCodeID();
      }
    }
 else     if ((gameState == GameState.IN_PROGRESS || gameState == GameState.WAITING_TO_START) && code == MUSIC_STOPPED_EVENT) {
      endTheGame();
    }
  }
}

Fixed version (ground truth):
@Override protected void simulateCustomEvent(float x,float y,int code,boolean isServer){
  if (code < 0) {
    this.song=Song.fromInt(code);
    setupEvents();
  }
 else {
    Player player=playerMap.get(isServer);
    UnitType type=UnitType.fromInt(code);
    if (type != null) {
      player.setUnitType(type);
    }
 else     if (code == TUTORIAL_DONE_EVENT) {
      if (isServer) {
        serverReady=true;
      }
 else {
        clientReady=true;
      }
      if (serverReady && clientReady) {
        Unit.resetNextHashCodeID();
        Wall.resetNextHashCodeID();
      }
    }
 else     if ((gameState == GameState.IN_PROGRESS || gameState == GameState.WAITING_TO_START) && code == MUSIC_STOPPED_EVENT) {
      endTheGame();
    }
  }
}
Program: 152998
Project: 152998
Buggy source:
public void setBothPlayersReady(){
  clientReady=serverReady=true;
  Unit.resetNextHashCodeID();
}

Fixed version (ground truth):
public void setBothPlayersReady(){
  clientReady=serverReady=true;
  Unit.resetNextHashCodeID();
  Wall.resetNextHashCodeID();
}
Program: 152999
Project: 152999
Buggy source:
@Override protected void simulateCustomEvent(float x,float y,int code,boolean isServer){
  if (code < 0) {
    this.song=Song.fromInt(code);
  }
 else {
    Player player=playerMap.get(isServer);
    UnitType type=UnitType.fromInt(code);
    if (type != null) {
      player.setUnitType(type);
    }
 else     if (code == TUTORIAL_DONE_EVENT) {
      if (isServer) {
        serverReady=true;
      }
 else {
        clientReady=true;
      }
      if (serverReady && clientReady) {
        Unit.resetNextHashCodeID();
      }
    }
 else     if (code == MUSIC_STOPPED_EVENT) {
      endTheGame();
    }
  }
}

Fixed version (ground truth):
@Override protected void simulateCustomEvent(float x,float y,int code,boolean isServer){
  if (code < 0) {
    this.song=Song.fromInt(code);
    setupEvents();
  }
 else {
    Player player=playerMap.get(isServer);
    UnitType type=UnitType.fromInt(code);
    if (type != null) {
      player.setUnitType(type);
    }
 else     if (code == TUTORIAL_DONE_EVENT) {
      if (isServer) {
        serverReady=true;
      }
 else {
        clientReady=true;
      }
      if (serverReady && clientReady) {
        Unit.resetNextHashCodeID();
      }
    }
 else     if (code == MUSIC_STOPPED_EVENT) {
      endTheGame();
    }
  }
}
Program: 153000
Project: 153000
Buggy source:
@Override public void registerAchievements(){
  AchievementInfo info;
  info=infoMap.get(0);
  if (info != null) {
    achievements.add(new SongAchievement(info,Song.MISTAKE_THE_GETAWAY));
  }
  info=infoMap.get(1);
  if (info != null) {
    achievements.add(new SongAchievement(info,Song.MIGHT_AND_MAGIC));
  }
  info=infoMap.get(2);
  if (info != null) {
    achievements.add(new SongAchievement(info,Song.RETRO));
  }
  info=infoMap.get(3);
  if (info != null) {
    achievements.add(new SongAchievement(info,Song.JAVLA_SLADDAR));
  }
  info=infoMap.get(4);
  if (info != null) {
    achievements.add(new SongAchievement(info,Song.ODINS_KRAFT));
  }
  info=infoMap.get(100);
  if (info != null)   achievements.add(new DesperateTimes(info));
  info=infoMap.get(200);
  if (info != null)   achievements.add(new BetterNotToMash(info));
  postRegisterAchievements();
}

Fixed version (ground truth):
@Override public void registerAchievements(){
  AchievementInfo info;
  info=infoMap.get(0);
  if (info != null) {
    achievements.add(new SongAchievement(info,Song.MISTAKE_THE_GETAWAY));
  }
  info=infoMap.get(1);
  if (info != null) {
    achievements.add(new SongAchievement(info,Song.MIGHT_AND_MAGIC));
  }
  info=infoMap.get(2);
  if (info != null) {
    achievements.add(new SongAchievement(info,Song.RETRO));
  }
  info=infoMap.get(3);
  if (info != null) {
    achievements.add(new SongAchievement(info,Song.JAVLA_SLADDAR));
  }
  info=infoMap.get(4);
  if (info != null) {
    achievements.add(new SongAchievement(info,Song.ODINS_KRAFT));
  }
  info=infoMap.get(100);
  if (info != null)   achievements.add(new DesperateTimes(info));
  info=infoMap.get(200);
  if (info != null)   achievements.add(new BetterNotToMash(info));
  info=infoMap.get(500);
  if (info != null)   achievements.add(new AnythingYouCanDo(info));
  postRegisterAchievements();
}
Program: 153001
Project: 153001
Buggy source:
@Override public void onTouchMove(float x,float y){
  if (!tutorial.isFinished()) {
    tutorial.touchMove(x,y);
    return;
  }
  x-=BBTHSimulation.GAME_X;
  y-=BBTHSimulation.GAME_Y;
  if (x < 0 || y < 0) {
    simulateWallGeneration();
  }
 else   if (currentWall != null) {
    currentWall.b.set(x,y);
  }
  if (BBTHGame.IS_SINGLE_PLAYER) {
    sim.simulateTapMove(x,y,true);
  }
 else {
    sim.recordTapMove(x,y);
  }
}

Fixed version (ground truth):
@Override public void onTouchMove(float x,float y){
  if (!BBTHGame.DEBUG && !tutorial.isFinished()) {
    tutorial.touchMove(x,y);
    return;
  }
  x-=BBTHSimulation.GAME_X;
  y-=BBTHSimulation.GAME_Y;
  if (x < 0 || y < 0) {
    simulateWallGeneration();
  }
 else   if (currentWall != null) {
    currentWall.b.set(x,y);
  }
  if (BBTHGame.IS_SINGLE_PLAYER) {
    sim.simulateTapMove(x,y,true);
  }
 else {
    sim.recordTapMove(x,y);
  }
}
Program: 153002
Project: 153002
Buggy source:
@Override public void onTouchUp(float x,float y){
  if (!tutorial.isFinished()) {
    tutorial.touchUp(x,y);
    return;
  }
  beatTrack.onTouchUp(x,y);
  if (userScrolling) {
    userScrolling=false;
    return;
  }
  x-=BBTHSimulation.GAME_X;
  y-=BBTHSimulation.GAME_Y;
  simulateWallGeneration();
  if (BBTHGame.IS_SINGLE_PLAYER) {
    sim.simulateTapUp(x,y,true);
  }
 else {
    sim.recordTapUp(x,y);
  }
}

Fixed version (ground truth):
@Override public void onTouchUp(float x,float y){
  if (!BBTHGame.DEBUG && !tutorial.isFinished()) {
    tutorial.touchUp(x,y);
    return;
  }
  beatTrack.onTouchUp(x,y);
  if (userScrolling) {
    userScrolling=false;
    return;
  }
  x-=BBTHSimulation.GAME_X;
  y-=BBTHSimulation.GAME_Y;
  simulateWallGeneration();
  if (BBTHGame.IS_SINGLE_PLAYER) {
    sim.simulateTapUp(x,y,true);
  }
 else {
    sim.recordTapUp(x,y);
  }
}
Program: 153003
Project: 153003
Buggy source:
public BBTHSimulation(Team localTeam,LockStepProtocol protocol,boolean isServer){
  super(3,0.1f,2,protocol,isServer);
  random.setSeed(0);
  serverReady=true;
  clientReady=false;
  aiController=new AIController();
  accel=new GridAcceleration(GAME_WIDTH,GAME_HEIGHT,GAME_WIDTH / 10);
  team=localTeam;
  serverPlayer=new Player(Team.SERVER,aiController,this);
  clientPlayer=new Player(Team.CLIENT,aiController,this);
  localPlayer=(team == Team.SERVER) ? serverPlayer : clientPlayer;
  remotePlayer=(team == Team.SERVER) ? clientPlayer : serverPlayer;
  playerMap=new HashMap<Boolean,Player>();
  playerMap.put(true,serverPlayer);
  playerMap.put(false,clientPlayer);
  graphGen=new FastGraphGenerator(15.0f,GAME_WIDTH,GAME_HEIGHT);
  accel.insertWalls(graphGen.walls);
  pathFinder=new Pathfinder(graphGen.graph);
  tester=new FastLineOfSightTester(15.f,accel);
  aiController.setPathfinder(pathFinder,graphGen.graph,tester,accel);
  aiController.setUpdateFraction(.1f);
  cachedUnits=new HashSet<Unit>();
}

Fixed version (ground truth):
public BBTHSimulation(Team localTeam,LockStepProtocol protocol,boolean isServer){
  super(3,0.1f,2,protocol,isServer);
  random.setSeed(0);
  serverReady=true;
  clientReady=false;
  aiController=new AIController();
  accel=new GridAcceleration(GAME_WIDTH,GAME_HEIGHT,GAME_WIDTH / 10);
  team=localTeam;
  serverPlayer=new Player(Team.SERVER,aiController,this);
  clientPlayer=new Player(Team.CLIENT,aiController,this);
  localPlayer=(team == Team.SERVER) ? serverPlayer : clientPlayer;
  remotePlayer=(team == Team.SERVER) ? clientPlayer : serverPlayer;
  playerMap=new HashMap<Boolean,Player>();
  playerMap.put(true,serverPlayer);
  playerMap.put(false,clientPlayer);
  graphGen=new FastGraphGenerator(15.0f,GAME_WIDTH,GAME_HEIGHT);
  accel.insertWalls(graphGen.walls);
  pathFinder=new Pathfinder(graphGen.graph);
  tester=new FastLineOfSightTester(15.f,accel);
  aiController.setPathfinder(pathFinder,graphGen.graph,tester,accel);
  aiController.setUpdateFraction(.10f);
  cachedUnits=new HashSet<Unit>();
}
Program: 153004
Project: 153004
Buggy source:
@Override public void onUpdate(float seconds){
  entireUpdateTimer.start();
  if (bluetooth.getState() != State.CONNECTED) {
    beatTrack.stopMusic();
    nextScreen=new GameStatusMessageScreen.DisconnectScreen();
  }
  simUpdateTimer.start();
  sim.onUpdate(seconds);
  simUpdateTimer.stop();
  if (!tutorial.isFinished()) {
    tutorial.update(seconds);
    if (tutorial.isFinished()) {
      sim.recordCustomEvent(0,0,BBTHSimulation.TUTORIAL_DONE);
    }
  }
  if (sim.isReady() && !beatTrack.isPlaying()) {
    beatTrack.startMusic();
  }
  clientHealthRect.right=MathUtils.scale(0,100,minimapRect.left + 1,minimapRect.right - 1,sim.clientPlayer.getHealth());
  serverHealthRect.right=MathUtils.scale(0,100,minimapRect.left + 1,minimapRect.right - 1,sim.serverPlayer.getHealth());
  if (sim.localPlayer.getHealth() <= 0.f) {
    this.nextScreen=new GameStatusMessageScreen.LoseScreen();
  }
  if (sim.remotePlayer.getHealth() <= 0.f) {
    this.nextScreen=new GameStatusMessageScreen.WinScreen();
  }
  beatTrack.refreshBeats();
  if (cameraInteraction == SNAP_TO_MOST_ADVANCED) {
    Unit mostAdvanced=sim.getOpponentsMostAdvancedUnit();
    if (mostAdvanced != null) {
      this.scrollTo(mostAdvanced.getX(),mostAdvanced.getY() - BBTHGame.HEIGHT / 2);
    }
  }
  particles.tick(seconds);
  entireUpdateTimer.stop();
}

Fixed version (ground truth):
@Override public void onUpdate(float seconds){
  entireUpdateTimer.start();
  if (bluetooth.getState() != State.CONNECTED) {
    beatTrack.stopMusic();
    nextScreen=new GameStatusMessageScreen.DisconnectScreen();
  }
  simUpdateTimer.start();
  sim.onUpdate(seconds);
  simUpdateTimer.stop();
  if (!tutorial.isFinished()) {
    tutorial.update(seconds);
    if (tutorial.isFinished()) {
      sim.recordCustomEvent(0,0,BBTHSimulation.TUTORIAL_DONE);
    }
  }
  if (sim.isReady() && !beatTrack.isPlaying()) {
    beatTrack.startMusic();
  }
  clientHealthRect.right=MathUtils.scale(0,100,minimapRect.left + 1,minimapRect.right - 1,sim.clientPlayer.getHealth());
  serverHealthRect.right=MathUtils.scale(0,100,minimapRect.left + 1,minimapRect.right - 1,sim.serverPlayer.getHealth());
  if (sim.localPlayer.getHealth() <= 0.f) {
    beatTrack.stopMusic();
    this.nextScreen=new GameStatusMessageScreen.LoseScreen();
  }
  if (sim.remotePlayer.getHealth() <= 0.f) {
    beatTrack.stopMusic();
    this.nextScreen=new GameStatusMessageScreen.WinScreen();
  }
  beatTrack.refreshBeats();
  if (cameraInteraction == SNAP_TO_MOST_ADVANCED) {
    Unit mostAdvanced=sim.getOpponentsMostAdvancedUnit();
    if (mostAdvanced != null) {
      this.scrollTo(mostAdvanced.getX(),mostAdvanced.getY() - BBTHGame.HEIGHT / 2);
    }
  }
  particles.tick(seconds);
  entireUpdateTimer.stop();
}
Program: 153006
Project: 153006
Buggy source:
@Override public int compareTo(Event other){
  return fineTime - other.fineTime;
}

Fixed version (ground truth):
/** 
 * Complicated comparison is to avoid race condition by ensuring the same ordering of events on both the client and the server.
 */
@Override public int compareTo(Event other){
  if (fineTime > other.fineTime) {
    return 1;
  }
 else   if (fineTime < other.fineTime) {
    return -1;
  }
 else   if (id > other.id) {
    return 1;
  }
 else   if (id < other.id) {
    return -1;
  }
 else {
    boolean isServer=((flags & IS_SERVER) != 0);
    boolean otherIsServer=((other.flags & IS_SERVER) != 0);
    if (isServer && !otherIsServer) {
      return 1;
    }
 else     if (!isServer && otherIsServer) {
      return -1;
    }
    return 0;
  }
}
Program: 153007
Project: 153007
Buggy source:
@Override public void writeTo(DataOutputStream out) throws IOException, InterruptedException {
  LockStep step=outgoing.take();
  out.writeByte(step.events.size());
  out.writeInt(step.coarseTime);
  for (int i=0, count=step.events.size(); i < count; i++) {
    Event event=step.events.get(i);
    out.writeByte(event.type | event.flags);
    out.writeInt(event.fineTime);
    out.writeFloat(event.x);
    out.writeFloat(event.y);
    out.writeByte(event.code);
  }
}

Fixed version (ground truth):
@Override public void writeTo(DataOutputStream out) throws IOException, InterruptedException {
  LockStep step=outgoing.take();
  out.writeByte(step.events.size());
  out.writeInt(step.coarseTime);
  for (int i=0, count=step.events.size(); i < count; i++) {
    Event event=step.events.get(i);
    out.writeInt(event.id);
    out.writeByte(event.type | event.flags);
    out.writeInt(event.fineTime);
    out.writeFloat(event.x);
    out.writeFloat(event.y);
    out.writeByte(event.code);
  }
}
Program: 153008
Project: 153008
Buggy source:
@Override public void readFrom(DataInputStream in) throws IOException, InterruptedException {
  LockStep step=new LockStep();
  int count=in.readByte();
  step.coarseTime=in.readInt();
  for (int i=0; i < count; i++) {
    Event event=new Event();
    int type=in.readByte();
    event.type=type & 0x03;
    event.flags=type & 0xF8;
    event.fineTime=in.readInt();
    event.x=in.readFloat();
    event.y=in.readFloat();
    event.code=in.readByte();
    step.events.add(event);
  }
  incoming.put(step);
}

Fixed version (ground truth):
@Override public void readFrom(DataInputStream in) throws IOException, InterruptedException {
  LockStep step=new LockStep();
  int count=in.readByte();
  step.coarseTime=in.readInt();
  for (int i=0; i < count; i++) {
    Event event=new Event();
    event.id=in.readInt();
    int type=in.readByte();
    event.type=type & 0x03;
    event.flags=type & 0xF8;
    event.fineTime=in.readInt();
    event.x=in.readFloat();
    event.y=in.readFloat();
    event.code=in.readByte();
    step.events.add(event);
  }
  incoming.put(step);
}
Program: 153009
Project: 153009
Buggy source:
/** 
 * Helper function for recordTap*() functions.
 */
private final Event makeEvent(float x,float y,int type,boolean isHold,boolean isOnBeat,int code){
  Event event=new Event();
  event.type=type;
  event.flags=(isServer ? Event.IS_SERVER : 0) | (isHold ? Event.IS_HOLD : 0) | (isOnBeat ? Event.IS_ON_BEAT : 0);
  event.fineTime=currentFineTimestep + coarseLag * finePerCoarse;
  event.x=x;
  event.y=y;
  event.code=code;
  return event;
}

Fixed version (ground truth):
/** 
 * Helper function for recordTap*() functions.
 */
private final Event makeEvent(float x,float y,int type,boolean isHold,boolean isOnBeat,int code){
  Event event=new Event();
  event.id=nextID++;
  event.type=type;
  event.flags=(isServer ? Event.IS_SERVER : 0) | (isHold ? Event.IS_HOLD : 0) | (isOnBeat ? Event.IS_ON_BEAT : 0);
  event.fineTime=currentFineTimestep + coarseLag * finePerCoarse;
  event.x=x;
  event.y=y;
  event.code=code;
  return event;
}
Program: 153010
Project: 153010
Buggy source:
public final void onUpdate(float seconds){
  accumulatedSeconds+=seconds;
  LockStep step;
  while ((step=protocol.readLockStep()) != null) {
    incomingRemoteSteps.add(step);
  }
  for (int i=0; i < 10 && accumulatedSeconds > 0; i++) {
    boolean isCoarse=(currentFineTimestep % finePerCoarse) == 0;
    if (isCoarse) {
      LockStep nextRemoteStep=incomingRemoteSteps.peek();
      LockStep nextLocalStep=incomingLocalSteps.peek();
      if (nextLocalStep == null || nextRemoteStep == null || nextLocalStep.coarseTime != currentCoarseTimestep || nextRemoteStep.coarseTime != currentCoarseTimestep) {
        return;
      }
      nextLocalStep=incomingLocalSteps.remove();
      nextRemoteStep=incomingRemoteSteps.remove();
      if (isServer) {
        nextLocalStep.addEventsToQueue(incomingEvents);
        nextRemoteStep.addEventsToQueue(incomingEvents);
      }
 else {
        nextRemoteStep.addEventsToQueue(incomingEvents);
        nextLocalStep.addEventsToQueue(incomingEvents);
      }
    }
    Event event;
    while ((event=incomingEvents.peek()) != null && event.fineTime == currentFineTimestep) {
      dispatchEvent(incomingEvents.remove());
    }
    if (event != null && event.fineTime < currentFineTimestep) {
      Log.e("String_Node_Str","String_Node_Str" + event.fineTime + "String_Node_Str"+ currentFineTimestep);
      System.exit(0);
    }
    update(secondsPerFine);
    if ((++currentFineTimestep % finePerCoarse) == 0) {
      endCurrentTimestep();
      currentCoarseTimestep++;
    }
    accumulatedSeconds-=secondsPerFine;
  }
}

Fixed version (ground truth):
public final void onUpdate(float seconds){
  accumulatedSeconds+=seconds;
  LockStep step;
  while ((step=protocol.readLockStep()) != null) {
    incomingRemoteSteps.add(step);
  }
  for (int i=0; i < 10 && accumulatedSeconds > 0; i++) {
    boolean isCoarse=(currentFineTimestep % finePerCoarse) == 0;
    if (isCoarse) {
      LockStep nextRemoteStep=incomingRemoteSteps.peek();
      LockStep nextLocalStep=incomingLocalSteps.peek();
      if (nextLocalStep == null || nextRemoteStep == null || nextLocalStep.coarseTime != currentCoarseTimestep || nextRemoteStep.coarseTime != currentCoarseTimestep) {
        return;
      }
      nextLocalStep=incomingLocalSteps.remove();
      nextRemoteStep=incomingRemoteSteps.remove();
      nextLocalStep.addEventsToQueue(incomingEvents);
      nextRemoteStep.addEventsToQueue(incomingEvents);
    }
    Event event;
    while ((event=incomingEvents.peek()) != null && event.fineTime == currentFineTimestep) {
      dispatchEvent(incomingEvents.remove());
    }
    if (event != null && event.fineTime < currentFineTimestep) {
      Log.e("String_Node_Str","String_Node_Str" + event.fineTime + "String_Node_Str"+ currentFineTimestep);
      System.exit(0);
    }
    update(secondsPerFine);
    if ((++currentFineTimestep % finePerCoarse) == 0) {
      endCurrentTimestep();
      currentCoarseTimestep++;
    }
    accumulatedSeconds-=secondsPerFine;
  }
}
Program: 153011
Project: 153011
Buggy source:
@Override protected void update(float seconds){
  entireTickTimer.start();
  timestep++;
  accelTickTimer.start();
  accel.clearUnits();
  accel.insertUnits(serverPlayer.units);
  accel.insertUnits(clientPlayer.units);
  accelTickTimer.stop();
  aiTickTimer.start();
  aiControllerTimer.start();
  aiController.update();
  aiControllerTimer.stop();
  serverPlayerTimer.start();
  serverPlayer.update(seconds);
  serverPlayerTimer.stop();
  clientPlayerTimer.start();
  clientPlayer.update(seconds);
  clientPlayerTimer.stop();
  aiTickTimer.stop();
  PARTICLES.tick(seconds);
  RectF sr=serverPlayer.base.getRect();
  RectF cr=clientPlayer.base.getRect();
  accel.getUnitsInAABB(sr.left,sr.top,sr.right,sr.bottom,cachedUnits);
  for (  Unit u : cachedUnits) {
    if (u.getTeam() == Team.CLIENT) {
      serverPlayer.adjustHealth(-10);
    }
    this.notifyUnitDead(u);
  }
  accel.getUnitsInAABB(cr.left,cr.top,cr.right,cr.bottom,cachedUnits);
  for (  Unit u : cachedUnits) {
    if (u.getTeam() == Team.SERVER) {
      clientPlayer.adjustHealth(-10);
    }
    this.notifyUnitDead(u);
  }
  entireTickTimer.stop();
}

Fixed version (ground truth):
@Override protected void update(float seconds){
  if (!self_ready) {
    tutorial.update();
    if (tutorial.isFinished()) {
      recordCustomEvent(0,0,TUTORIAL_DONE);
    }
  }
 else   if (!other_ready) {
    tutorial.displayWait();
  }
 else {
    tutorial.hide();
  }
  if (other_ready && self_ready) {
    entireTickTimer.start();
    timestep++;
    accelTickTimer.start();
    accel.clearUnits();
    accel.insertUnits(serverPlayer.units);
    accel.insertUnits(clientPlayer.units);
    accelTickTimer.stop();
    aiTickTimer.start();
    aiControllerTimer.start();
    aiController.update();
    aiControllerTimer.stop();
    serverPlayerTimer.start();
    serverPlayer.update(seconds);
    serverPlayerTimer.stop();
    clientPlayerTimer.start();
    clientPlayer.update(seconds);
    clientPlayerTimer.stop();
    aiTickTimer.stop();
    PARTICLES.tick(seconds);
    RectF sr=serverPlayer.base.getRect();
    RectF cr=clientPlayer.base.getRect();
    accel.getUnitsInAABB(sr.left,sr.top,sr.right,sr.bottom,cachedUnits);
    for (    Unit u : cachedUnits) {
      if (u.getTeam() == Team.CLIENT) {
        serverPlayer.adjustHealth(-10);
      }
      this.notifyUnitDead(u);
    }
    accel.getUnitsInAABB(cr.left,cr.top,cr.right,cr.bottom,cachedUnits);
    for (    Unit u : cachedUnits) {
      if (u.getTeam() == Team.SERVER) {
        clientPlayer.adjustHealth(-10);
      }
      this.notifyUnitDead(u);
    }
    entireTickTimer.stop();
  }
}
Program: 153012
Project: 153012
Buggy source:
public void draw(Canvas canvas){
  drawGrid(canvas);
  localPlayer.draw(canvas);
  remotePlayer.draw(canvas);
  PARTICLES.draw(canvas,PARTICLE_PAINT);
}

Fixed version (ground truth):
public void draw(Canvas canvas){
  drawGrid(canvas);
  localPlayer.draw(canvas);
  remotePlayer.draw(canvas);
  PARTICLES.draw(canvas,PARTICLE_PAINT);
  localPlayer.postDraw(canvas);
  remotePlayer.postDraw(canvas);
}
Program: 153013
Project: 153013
Buggy source:
@Override protected void simulateCustomEvent(float x,float y,int code,boolean isServer){
  Player player=playerMap.get(isServer);
  UnitType type=UnitType.fromInt(code);
  if (type != null)   player.setUnitType(type);
}

Fixed version (ground truth):
@Override protected void simulateCustomEvent(float x,float y,int code,boolean isServer){
  Player player=playerMap.get(isServer);
  UnitType type=UnitType.fromInt(code);
  if (type != null) {
    player.setUnitType(type);
  }
 else   if (code == TUTORIAL_DONE) {
    if (player == remotePlayer) {
      other_ready=true;
    }
 else {
      self_ready=true;
    }
  }
}