nus-yam/ex-repair huggingface dataset:
Program: 8931
Project: 8931
Buggy source:
public BatteryMeterView(Context context,AttributeSet attrs,int defStyle){
  super(context,attrs,defStyle);
  mContext=context;
  TypedArray arr=context.obtainStyledAttributes(attrs,R.styleable.BatteryMeterView,defStyle,0);
  mBatteryHeight=arr.getDimensionPixelSize(R.styleable.BatteryMeterView_battery_height,0);
  mBatteryWidth=arr.getDimensionPixelSize(R.styleable.BatteryMeterView_battery_width,0);
  mBatteryPadding=arr.getDimensionPixelSize(R.styleable.BatteryMeterView_battery_padding,0);
  setPadding(getPaddingLeft(),getPaddingTop(),getPaddingRight(),getPaddingBottom());
  final Resources res=context.getResources();
  TypedArray levels=res.obtainTypedArray(R.array.batterymeter_color_levels);
  TypedArray colors=res.obtainTypedArray(R.array.batterymeter_color_values);
  final int n=levels.length();
  mColors=new int[2 * n];
  for (int i=0; i < n; i++) {
    mColors[2 * i]=levels.getInt(i,0);
    mColors[2 * i + 1]=colors.getColor(i,0);
  }
  levels.recycle();
  colors.recycle();
  mChargeColor=getResources().getColor(R.color.batterymeter_charge_color);
  mBatteryFormat=getResources().getString(R.string.batterymeter_precise);
  mWarningString=context.getString(R.string.batterymeter_very_low_overlay_symbol);
  setMode(BatteryMeterMode.BATTERY_METER_ICON_PORTRAIT);
  mBatteryDrawable.onSizeChanged(mBatteryWidth,mBatteryHeight,0,0);
  setLayerType(View.LAYER_TYPE_SOFTWARE,null);
}

Fixed version (ground truth):
public BatteryMeterView(Context context,AttributeSet attrs,int defStyle){
  super(context,attrs,defStyle);
  mContext=context;
  TypedArray arr=context.obtainStyledAttributes(attrs,R.styleable.BatteryMeterView,defStyle,0);
  mBatteryHeight=arr.getDimensionPixelSize(R.styleable.BatteryMeterView_battery_height,0);
  mBatteryWidth=arr.getDimensionPixelSize(R.styleable.BatteryMeterView_battery_width,0);
  mBatteryPadding=arr.getDimensionPixelSize(R.styleable.BatteryMeterView_battery_padding,0);
  setPadding(getPaddingLeft(),getPaddingTop(),getPaddingRight(),getPaddingBottom());
  final Resources res=context.getResources();
  if (!isInEditMode()) {
    TypedArray levels=res.obtainTypedArray(R.array.batterymeter_color_levels);
    TypedArray colors=res.obtainTypedArray(R.array.batterymeter_color_values);
    final int n=levels.length();
    mColors=new int[2 * n];
    for (int i=0; i < n; i++) {
      mColors[2 * i]=levels.getInt(i,0);
      mColors[2 * i + 1]=colors.getColor(i,0);
    }
    levels.recycle();
    colors.recycle();
  }
 else {
    mColors=new int[]{4,res.getColor(R.color.batterymeter_critical),15,res.getColor(R.color.batterymeter_low),100,res.getColor(R.color.batterymeter_full)};
  }
  mChargeColor=getResources().getColor(R.color.batterymeter_charge_color);
  mBatteryFormat=getResources().getString(R.string.batterymeter_precise);
  mWarningString=context.getString(R.string.batterymeter_very_low_overlay_symbol);
  setMode(BatteryMeterMode.BATTERY_METER_ICON_PORTRAIT);
  mBatteryDrawable.onSizeChanged(mBatteryWidth,mBatteryHeight,0,0);
  setLayerType(View.LAYER_TYPE_SOFTWARE,null);
}
Program: 8932
Project: 8932
Buggy source:
private float[] loadBoltPoints(Resources res){
  final int[] pts=res.getIntArray(getBoltPointsArrayResource());
  int maxX=0, maxY=0;
  for (int i=0; i < pts.length; i+=2) {
    maxX=Math.max(maxX,pts[i]);
    maxY=Math.max(maxY,pts[i + 1]);
  }
  final float[] ptsF=new float[pts.length];
  for (int i=0; i < pts.length; i+=2) {
    ptsF[i]=(float)pts[i] / maxX;
    ptsF[i + 1]=(float)pts[i + 1] / maxY;
  }
  return ptsF;
}

Fixed version (ground truth):
private float[] loadBoltPoints(Resources res){
  if (!isInEditMode()) {
    final int[] pts=res.getIntArray(getBoltPointsArrayResource());
    int maxX=0, maxY=0;
    for (int i=0; i < pts.length; i+=2) {
      maxX=Math.max(maxX,pts[i]);
      maxY=Math.max(maxY,pts[i + 1]);
    }
    final float[] ptsF=new float[pts.length];
    for (int i=0; i < pts.length; i+=2) {
      ptsF[i]=(float)pts[i] / maxX;
      ptsF[i + 1]=(float)pts[i + 1] / maxY;
    }
    return ptsF;
  }
 else {
    return new float[]{0,0,1,1};
  }
}
Program: 8933
Project: 8933
Buggy source:
@Override protected void onDetachedFromWindow(){
  super.onDetachedFromWindow();
  Config config=Config.getInstance();
  config.unregisterListener(this);
}

Fixed version (ground truth):
@Override protected void onDetachedFromWindow(){
  super.onDetachedFromWindow();
  if (!isInEditMode()) {
    Config config=Config.getInstance();
    config.unregisterListener(this);
  }
}
Program: 8934
Project: 8934
Buggy source:
@Override protected void onAttachedToWindow(){
  super.onAttachedToWindow();
  Config config=Config.getInstance();
  config.registerListener(this);
  updateBatteryVisibility();
}

Fixed version (ground truth):
@Override protected void onAttachedToWindow(){
  super.onAttachedToWindow();
  if (!isInEditMode()) {
    Config config=Config.getInstance();
    config.registerListener(this);
  }
  updateBatteryVisibility();
}
Program: 8935
Project: 8935
Buggy source:
/** 
 * Turns screen off and sends a test notification.
 * @param fake {@code true} if it simply starts {@link AcDisplayActivity},  {@code false} if it uses notification
 */
private void startAcDisplayTest(boolean fake){
  if (fake) {
    sendTestNotification();
    startActivity(new Intent(this,AcDisplayActivity.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION));
    return;
  }
  int delay=getResources().getInteger(R.integer.config_test_notification_delay);
  PowerManager pm=(PowerManager)getSystemService(Context.POWER_SERVICE);
  PowerManager.WakeLock wakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"String_Node_Str");
  wakeLock.acquire(delay);
  try {
    DevicePolicyManager dpm=(DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE);
    dpm.lockNow();
    new Handler().postDelayed(new Runnable(){
      @Override public void run(){
        sendTestNotification();
      }
    }
,delay);
  }
 catch (  SecurityException e) {
    Log.wtf(TAG,"String_Node_Str");
    wakeLock.release();
  }
}

Fixed version (ground truth):
/** 
 * Turns screen off and sends a test notification.
 * @param fake {@code true} if it simply starts {@link AcDisplayActivity},  {@code false} if it uses notification
 */
private void startAcDisplayTest(boolean fake){
  if (fake) {
    sendTestNotification();
    startActivity(new Intent(this,AcDisplayActivity.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION).putExtra(KeyguardActivity.EXTRA_FINISH_ON_SCREEN_OFF,!mConfig.isKeyguardEnabled()));
    return;
  }
  int delay=getResources().getInteger(R.integer.config_test_notification_delay);
  PowerManager pm=(PowerManager)getSystemService(Context.POWER_SERVICE);
  PowerManager.WakeLock wakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"String_Node_Str");
  wakeLock.acquire(delay);
  try {
    DevicePolicyManager dpm=(DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE);
    dpm.lockNow();
    new Handler().postDelayed(new Runnable(){
      @Override public void run(){
        sendTestNotification();
      }
    }
,delay);
  }
 catch (  SecurityException e) {
    Log.wtf(TAG,"String_Node_Str");
    wakeLock.release();
  }
}
Program: 8936
Project: 8936
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override protected void onWidgetDismiss(Widget widget){
  if (widget instanceof NotifyWidget) {
    NotificationPresenter np=NotificationPresenter.getInstance();
    if (np.getList().size() <= 1 && mActivity.getConfig().isScreenOffAfterLastNotify()) {
      mActivity.lock();
    }
  }
  super.onWidgetDismiss(widget);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override protected void onWidgetDismiss(Widget widget){
  boolean lock=false;
  if (widget instanceof NotifyWidget) {
    NotificationPresenter np=NotificationPresenter.getInstance();
    lock=np.getList().size() <= 1 && mActivity.getConfig().isScreenOffAfterLastNotify();
  }
  super.onWidgetDismiss(widget);
  if (lock) {
    mActivity.lock();
  }
}
Program: 8937
Project: 8937
Buggy source:
public static void startService(Context context,Class<? extends ChildService> clazz){
synchronized (monitor) {
    if (sCreated) {
      Intent intent=new Intent(ACTION_ADD_SERVICE);
      intent.putExtra(EXTRA_SERVICE_CLASS,clazz);
      LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
    }
 else     if (!sServiceMap.containsKey(clazz)) {
      try {
        ChildService child=clazz.newInstance();
        sServiceMap.put(clazz,child);
      }
 catch (      InstantiationException|IllegalAccessException e) {
        throw new RuntimeException(e.getMessage());
      }
      context.startService(new Intent(context,BathService.class));
    }
  }
}

Fixed version (ground truth):
public static void startService(Context context,Class<? extends ChildService> clazz){
synchronized (monitor) {
    if (sCreated) {
      Intent intent=new Intent(ACTION_ADD_SERVICE);
      intent.putExtra(EXTRA_SERVICE_CLASS,clazz);
      LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
    }
 else     if (!sServiceMap.containsKey(clazz)) {
      try {
        sServiceMap.put(clazz,clazz.newInstance());
        context.startService(new Intent(context,BathService.class));
      }
 catch (      InstantiationException|IllegalAccessException e) {
        throw new RuntimeException(e.getMessage());
      }
    }
  }
}
Program: 8938
Project: 8938
Buggy source:
public static void stopService(Context context,Class<? extends ChildService> clazz){
synchronized (monitor) {
    if (sCreated) {
      Intent intent=new Intent(ACTION_REMOVE_SERVICE);
      intent.putExtra(EXTRA_SERVICE_CLASS,clazz);
      LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
    }
 else     if (sServiceMap.containsKey(clazz)) {
      ChildService child=sServiceMap.remove(clazz);
      child.onDestroy();
    }
  }
}

Fixed version (ground truth):
public static void stopService(Context context,Class<? extends ChildService> clazz){
synchronized (monitor) {
    if (sCreated) {
      Intent intent=new Intent(ACTION_REMOVE_SERVICE);
      intent.putExtra(EXTRA_SERVICE_CLASS,clazz);
      LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
    }
 else {
      sServiceMap.remove(clazz);
    }
  }
}
Program: 8939
Project: 8939
Buggy source:
@Override public void onReceive(Context context,Intent intent){
  boolean add=false;
switch (intent.getAction()) {
case ACTION_ADD_SERVICE:
    add=true;
case ACTION_REMOVE_SERVICE:
  break;
default :
return;
}
synchronized (monitor) {
Class clazz=(Class)intent.getSerializableExtra(EXTRA_SERVICE_CLASS);
boolean containsClazz=sServiceMap.containsKey(clazz);
if (containsClazz == add) {
if (Build.DEBUG) Log.e(TAG,"String_Node_Str");
return;
}
if (add) {
try {
  ChildService child=(ChildService)clazz.newInstance();
  child.setContext(BathService.this);
  child.onCreate();
  sServiceMap.put(clazz,child);
}
 catch (InstantiationException|IllegalAccessException e) {
  throw new RuntimeException(e.getMessage());
}
updateNotification();
return;
}
ChildService child=sServiceMap.remove(clazz);
child.onDestroy();
if (sServiceMap.isEmpty()) {
BathService.this.stopSelf();
}
 else {
updateNotification();
}
}
}

Fixed version (ground truth):
@Override public void onReceive(Context context,Intent intent){
  boolean add=false;
switch (intent.getAction()) {
case ACTION_ADD_SERVICE:
    add=true;
case ACTION_REMOVE_SERVICE:
  break;
default :
return;
}
synchronized (monitor) {
Class clazz=(Class)intent.getSerializableExtra(EXTRA_SERVICE_CLASS);
boolean containsClazz=mMap.containsKey(clazz);
if (containsClazz == add) {
return;
}
if (add) {
try {
  ChildService child=(ChildService)clazz.newInstance();
  child.setContext(BathService.this);
  child.onCreate();
  mMap.put(clazz,child);
}
 catch (InstantiationException|IllegalAccessException e) {
  throw new RuntimeException(e.getMessage());
}
updateNotification();
return;
}
ChildService child=mMap.remove(clazz);
child.onDestroy();
if (mMap.isEmpty()) {
stopSelf();
}
 else {
updateNotification();
}
}
}
Program: 8940
Project: 8940
Buggy source:
private Notification buildNotification(){
  boolean empty=true;
  StringBuilder builder=new StringBuilder();
  String divider=getString(R.string.settings_multi_list_divider);
  Enumeration<ChildService> elements=sServiceMap.elements();
  while (elements.hasMoreElements()) {
    if (!empty) {
      builder.append(divider);
    }
    ChildService child=elements.nextElement();
    builder.append(child.getName());
    empty=false;
  }
  String contentText=builder.toString();
  contentText=contentText.charAt(0) + contentText.substring(1).toLowerCase();
  PendingIntent pendingIntent=PendingIntent.getActivity(this,App.ID_NOTIFY_BATH,new Intent(this,MainActivity.class),PendingIntent.FLAG_UPDATE_CURRENT);
  return new Notification.Builder(this).setContentTitle(getString(R.string.service_bath)).setContentText(contentText).setContentIntent(pendingIntent).setSmallIcon(R.drawable.stat_acdisplay).setPriority(Notification.PRIORITY_MIN).build();
}

Fixed version (ground truth):
/** 
 * <p>NOT SYNCHRONIZED!</p> Builds fresh notification with all   {@link ChildService children services}'s  {@link com.achep.acdisplay.services.BathService.ChildService#getLabel() labels} in.Content intent starts  {@link com.achep.acdisplay.activities.MainActivity}.
 */
private Notification buildNotification(){
  boolean empty=true;
  StringBuilder builder=new StringBuilder();
  String divider=getString(R.string.settings_multi_list_divider);
  for (  ChildService child : mMap.values()) {
    if (!empty) {
      builder.append(divider);
    }
    builder.append(child.getLabel());
    empty=false;
  }
  String contentText=builder.toString();
  if (contentText.length() > 0) {
    contentText=contentText.charAt(0) + contentText.substring(1).toLowerCase();
  }
  PendingIntent pendingIntent=PendingIntent.getActivity(this,App.ID_NOTIFY_BATH,new Intent(this,MainActivity.class),PendingIntent.FLAG_UPDATE_CURRENT);
  return new Notification.Builder(this).setContentTitle(getString(R.string.service_bath)).setContentText(contentText).setContentIntent(pendingIntent).setSmallIcon(R.drawable.stat_acdisplay).setPriority(Notification.PRIORITY_MIN).build();
}
Program: 8941
Project: 8941
Buggy source:
public ChildService(){
  if (Build.DEBUG)   Log.d(TAG,"String_Node_Str");
}

Fixed version (ground truth):
public ChildService(){
  if (Build.DEBUG) {
    Log.d(TAG,"String_Node_Str" + getClass().getSimpleName() + "String_Node_Str");
  }
}
Program: 8942
Project: 8942
Buggy source:
@Override public void onCreate(){
  super.onCreate();
  IntentFilter intentFilter=new IntentFilter();
  intentFilter.addAction(Intent.ACTION_SCREEN_ON);
  intentFilter.addAction(Intent.ACTION_SCREEN_OFF);
  intentFilter.setPriority(Integer.MAX_VALUE);
  registerReceiver(mReceiver,intentFilter);
  int notificationId=NotificationIds.LOCKSCREEN_NOTIFICATION;
  PendingIntent pendingIntent=PendingIntent.getActivity(this,notificationId,new Intent(this,Settings.LockscreenSettingsActivity.class),PendingIntent.FLAG_UPDATE_CURRENT);
  Notification notification=new Notification.Builder(this).setSmallIcon(R.drawable.stat_lock).setContentTitle(getString(R.string.service_lockscreen,getString(R.string.app_name))).setContentText(getString(R.string.service_lockscreen_text)).setPriority(Notification.PRIORITY_MIN).setContentIntent(pendingIntent).setOngoing(true).build();
  startForeground(notificationId,notification);
}

Fixed version (ground truth):
@Override public void onCreate(){
  super.onCreate();
  IntentFilter intentFilter=new IntentFilter();
  intentFilter.addAction(Intent.ACTION_SCREEN_ON);
  intentFilter.addAction(Intent.ACTION_SCREEN_OFF);
  intentFilter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY - 1);
  registerReceiver(mReceiver,intentFilter);
  int notificationId=NotificationIds.LOCKSCREEN_NOTIFICATION;
  Intent intent=new Intent(this,Settings.LockscreenSettingsActivity.class);
  PendingIntent pendingIntent=PendingIntent.getActivity(this,notificationId,intent,PendingIntent.FLAG_UPDATE_CURRENT);
  Notification notification=new Notification.Builder(this).setSmallIcon(R.drawable.stat_lock).setContentTitle(getString(R.string.service_lockscreen,getString(R.string.app_name))).setContentText(getString(R.string.service_lockscreen_text)).setPriority(Notification.PRIORITY_MIN).setContentIntent(pendingIntent).setOngoing(true).build();
  startForeground(notificationId,notification);
}
Program: 8943
Project: 8943
Buggy source:
private void startGui(){
  startActivity(new Intent(Intent.ACTION_MAIN,null).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | Intent.FLAG_ACTIVITY_NO_USER_ACTION| Intent.FLAG_ACTIVITY_NO_ANIMATION| Intent.FLAG_FROM_BACKGROUND).setClass(this,AcDisplayActivity.class));
}

Fixed version (ground truth):
private void startGui(){
  startActivity(new Intent(this,AcDisplayActivity.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | Intent.FLAG_ACTIVITY_NO_ANIMATION));
}
Program: 8944
Project: 8944
Buggy source:
private void stopMonitoringActivities(){
  if (mActivityMonitorThread != null) {
    if (Project.DEBUG)     Log.d(TAG,"String_Node_Str");
    mActivityMonitorThread.running=false;
  }
}

Fixed version (ground truth):
private void stopMonitoringActivities(){
  if (mActivityMonitorThread != null) {
    if (Project.DEBUG)     Log.d(TAG,"String_Node_Str");
    mActivityMonitorThread.running=false;
    mActivityMonitorThread.interrupt();
  }
}
Program: 8945
Project: 8945
Buggy source:
@Override public void run(){
  super.run();
  while (running) {
    monitor();
    try {
      Thread.sleep(MONITORING_PERIOD);
    }
 catch (    InterruptedException e) {
      e.printStackTrace();
    }
  }
}

Fixed version (ground truth):
@Override public void run(){
  super.run();
  while (running) {
    monitor();
    try {
      Thread.sleep(MONITORING_PERIOD);
    }
 catch (    InterruptedException e) {
    }
  }
}
Program: 8946
Project: 8946
Buggy source:
/** 
 * Checks what activity is on the latest.
 */
public synchronized void monitor(){
}

Fixed version (ground truth):
/** 
 * Checks what activity is the latest.
 */
public synchronized void monitor(){
}
Program: 8947
Project: 8947
Buggy source:
/** 
 * @deprecated hopefully the bug with it is fixed now, so no need to use it. Just in cause...
 */
@Deprecated public static void ignoreCurrentTurningOn(){
  sIgnoreTillTime=SystemClock.elapsedRealtime() + 2000;
}

Fixed version (ground truth):
/** 
 * @deprecated hopefully the bug with it is fixed now, so no need to use it. Just in case...
 */
@Deprecated public static void ignoreCurrentTurningOn(){
  sIgnoreTillTime=SystemClock.elapsedRealtime() + 2000;
}
Program: 8948
Project: 8948
Buggy source:
@Test(dataProvider="String_Node_Str") public void referenceLink(@NotNull ReferenceLink referenceLink,@NotNull ReferenceLink.Lang lang) throws IOException {
  try (InputStream stream=new URL(referenceLink.getLink(lang)).openStream()){
    ByteStreams.toByteArray(stream);
  }
 }

Fixed version (ground truth):
@Test(dataProvider="String_Node_Str") public void referenceLink(@NotNull ReferenceLink referenceLink,@NotNull ReferenceLink.Lang lang) throws IOException {
  if (System.getenv("String_Node_Str") != null)   return;
  try (InputStream stream=new URL(referenceLink.getLink(lang)).openStream()){
    ByteStreams.toByteArray(stream);
  }
 }
Program: 8951
Project: 8951
Buggy source:
@Override public boolean isMatch(@NotNull String name,boolean isDir){
  return isDir;
}

Fixed version (ground truth):
@Override public boolean isMatch(@NotNull String name,boolean isDir){
  return true;
}
Program: 8952
Project: 8952
Buggy source:
@Nullable @Override public PathMatcher createChild(@NotNull String name,boolean isDir){
  if (matcher.isMatch(name,isDir)) {
    return AlwaysMatcher.INSTANCE;
  }
  return this;
}

Fixed version (ground truth):
@Nullable @Override public PathMatcher createChild(@NotNull String name,boolean isDir){
  if (matcher.isMatch(name,isDir)) {
    return AlwaysMatcher.INSTANCE;
  }
  if (!isDir) {
    return null;
  }
  return this;
}
Program: 8953
Project: 8953
Buggy source:
@Nullable @Override public PathMatcher createChild(@NotNull String name,boolean isDir){
  final int[] childs=new int[indexes.length * 2];
  boolean changed=false;
  boolean childMatch=false;
  int count=0;
  for (  int index : indexes) {
    if (nameMatchers[index].isMatch(name,isDir)) {
      if (nameMatchers[index].isRecursive()) {
        childs[count++]=index;
        if (index + 1 < nameMatchers.length && nameMatchers[index + 1].isMatch(name,isDir)) {
          if (index + 2 == nameMatchers.length) {
            return AlwaysMatcher.INSTANCE;
          }
          childs[count++]=index + 2;
          changed=true;
        }
      }
 else {
        if (index + 1 == nameMatchers.length) {
          return AlwaysMatcher.INSTANCE;
        }
 else         if (index + 2 == nameMatchers.length && nameMatchers[index + 1].isRecursive()) {
          childMatch=true;
        }
        childs[count++]=index + 1;
        changed=true;
      }
    }
 else {
      changed=true;
    }
  }
  if (!changed) {
    return this;
  }
  return count == 0 ? null : new RecursivePathMatcher(nameMatchers,Arrays.copyOf(childs,count),childMatch);
}

Fixed version (ground truth):
@Nullable @Override public PathMatcher createChild(@NotNull String name,boolean isDir){
  final int[] childs=new int[indexes.length * 2];
  boolean changed=false;
  int count=0;
  for (  int index : indexes) {
    if (nameMatchers[index].isMatch(name,isDir)) {
      if (nameMatchers[index].isRecursive()) {
        childs[count++]=index;
        if (nameMatchers[index + 1].isMatch(name,isDir)) {
          if (index + 2 == nameMatchers.length) {
            return AlwaysMatcher.INSTANCE;
          }
          childs[count++]=index + 2;
          changed=true;
        }
      }
 else {
        if (index + 1 == nameMatchers.length) {
          return AlwaysMatcher.INSTANCE;
        }
        childs[count++]=index + 1;
        changed=true;
      }
    }
 else {
      changed=true;
    }
  }
  if (!isDir) {
    return null;
  }
  if (!changed) {
    return this;
  }
  return count == 0 ? null : new RecursivePathMatcher(nameMatchers,Arrays.copyOf(childs,count));
}
Program: 8954
Project: 8954
Buggy source:
private RecursivePathMatcher(@NotNull NameMatcher[] nameMatchers,@NotNull int[] indexes,boolean selfMatch){
  this.nameMatchers=nameMatchers;
  this.indexes=indexes;
  this.selfMatch=selfMatch;
}

Fixed version (ground truth):
private RecursivePathMatcher(@NotNull NameMatcher[] nameMatchers,@NotNull int[] indexes){
  this.nameMatchers=nameMatchers;
  this.indexes=indexes;
}
Program: 8955
Project: 8955
Buggy source:
@Override public boolean isMatch(){
  return selfMatch;
}

Fixed version (ground truth):
@Override public boolean isMatch(){
  return false;
}
Program: 8958
Project: 8958
Buggy source:
@NotNull public LfsStorage createStorage(@NotNull LocalContext context){
  File dataRoot=new File(context.getShared().getBasePath(),path);
  File metaRoot=isSaveMeta() ? new File(context.sure(GitLocation.class).getFullPath(),"String_Node_Str") : null;
  return new LfsLocalStorage(getLayout(),dataRoot,metaRoot,isCompress());
}

Fixed version (ground truth):
@NotNull public LfsStorage createStorage(@NotNull LocalContext context){
  File dataRoot=ConfigHelper.joinPath(context.getShared().getBasePath(),getPath());
  File metaRoot=isSaveMeta() ? new File(context.sure(GitLocation.class).getFullPath(),"String_Node_Str") : null;
  return new LfsLocalStorage(getLayout(),dataRoot,metaRoot,isCompress());
}
Program: 8959
Project: 8959
Buggy source:
public GitLabAccess(@NotNull LocalContext local,@NotNull GitLabMappingConfig config,int projectId){
  this.cache=CacheBuilder.newBuilder().maximumSize(config.getCacheMaximumSize()).expireAfterWrite(config.getCacheTimeSec(),TimeUnit.SECONDS).build(new CacheLoader<String,GitlabProject>(){
    @Override public GitlabProject load(    @NotNull String userId) throws Exception {
      final GitlabAPI api=GitLabContext.sure(local.getShared()).connect();
      String tailUrl=GitlabProject.URL + "String_Node_Str" + projectId;
      if (userId.isEmpty()) {
        tailUrl+="String_Node_Str" + userId;
      }
      return api.retrieve().to(tailUrl,GitlabProject.class);
    }
  }
);
}

Fixed version (ground truth):
public GitLabAccess(@NotNull LocalContext local,@NotNull GitLabMappingConfig config,int projectId){
  this.cache=CacheBuilder.newBuilder().maximumSize(config.getCacheMaximumSize()).expireAfterWrite(config.getCacheTimeSec(),TimeUnit.SECONDS).build(new CacheLoader<String,GitlabProject>(){
    @Override public GitlabProject load(    @NotNull String userId) throws Exception {
      final GitlabAPI api=GitLabContext.sure(local.getShared()).connect();
      String tailUrl=GitlabProject.URL + "String_Node_Str" + projectId;
      if (!userId.isEmpty()) {
        tailUrl+="String_Node_Str" + userId;
      }
      return api.retrieve().to(tailUrl,GitlabProject.class);
    }
  }
);
}
Program: 8960
Project: 8960
Buggy source:
@Override public GitlabProject load(@NotNull String userId) throws Exception {
  final GitlabAPI api=GitLabContext.sure(local.getShared()).connect();
  String tailUrl=GitlabProject.URL + "String_Node_Str" + projectId;
  if (userId.isEmpty()) {
    tailUrl+="String_Node_Str" + userId;
  }
  return api.retrieve().to(tailUrl,GitlabProject.class);
}

Fixed version (ground truth):
@Override public GitlabProject load(@NotNull String userId) throws Exception {
  final GitlabAPI api=GitLabContext.sure(local.getShared()).connect();
  String tailUrl=GitlabProject.URL + "String_Node_Str" + projectId;
  if (!userId.isEmpty()) {
    tailUrl+="String_Node_Str" + userId;
  }
  return api.retrieve().to(tailUrl,GitlabProject.class);
}
Program: 8961
Project: 8961
Buggy source:
private boolean isProjectOwner(@NotNull GitlabProject project,@NotNull User user){
  GitlabUser owner=project.getOwner();
  if (owner == null) {
    return false;
  }
  return owner.getId().toString().equals(user.getExternalId()) || owner.getEmail().equals(user.getEmail()) || owner.getName().equals(user.getUserName());
}

Fixed version (ground truth):
private boolean isProjectOwner(@NotNull GitlabProject project,@NotNull User user){
  if (user.isAnonymous()) {
    return false;
  }
  GitlabUser owner=project.getOwner();
  if (owner == null) {
    return false;
  }
  return owner.getId().toString().equals(user.getExternalId()) || owner.getName().equals(user.getUserName());
}
Program: 8962
Project: 8962
Buggy source:
@Override public void checkWrite(@NotNull User user,@Nullable String path) throws SVNException, IOException {
  if (user.isAnonymous()) {
    throw new SVNException(SVNErrorMessage.create(SVNErrorCode.RA_NOT_AUTHORIZED,"String_Node_Str"));
  }
  try {
    final GitlabProject project=getProjectViaSudo(user);
    if (isProjectOwner(project,user))     return;
    final GitlabPermission permissions=project.getPermissions();
    if (permissions != null) {
      if (hasAccess(permissions.getProjectAccess(),GitlabAccessLevel.Developer) || hasAccess(permissions.getProjectGroupAccess(),GitlabAccessLevel.Developer)) {
        return;
      }
    }
    throw new SVNException(SVNErrorMessage.create(SVNErrorCode.RA_NOT_AUTHORIZED,"String_Node_Str"));
  }
 catch (  FileNotFoundException ignored) {
    throw new SVNException(SVNErrorMessage.create(SVNErrorCode.RA_NOT_AUTHORIZED,"String_Node_Str"));
  }
}

Fixed version (ground truth):
@Override public void checkWrite(@NotNull User user,@Nullable String path) throws SVNException, IOException {
  if (user.isAnonymous()) {
    throw new SVNException(SVNErrorMessage.create(SVNErrorCode.RA_NOT_AUTHORIZED,"String_Node_Str"));
  }
  try {
    final GitlabProject project=getProjectViaSudo(user);
    if (isProjectOwner(project,user)) {
      return;
    }
    final GitlabPermission permissions=project.getPermissions();
    if (permissions != null) {
      if (hasAccess(permissions.getProjectAccess(),GitlabAccessLevel.Developer) || hasAccess(permissions.getProjectGroupAccess(),GitlabAccessLevel.Developer)) {
        return;
      }
    }
    throw new SVNException(SVNErrorMessage.create(SVNErrorCode.RA_NOT_AUTHORIZED,"String_Node_Str"));
  }
 catch (  FileNotFoundException ignored) {
    throw new SVNException(SVNErrorMessage.create(SVNErrorCode.RA_NOT_AUTHORIZED,"String_Node_Str"));
  }
}
Program: 8963
Project: 8963
Buggy source:
@Override public GitLogPair next(){
  final int compare;
  if (newItem == null) {
    compare=-1;
  }
 else   if (oldItem == null) {
    compare=1;
  }
 else {
    final GitTreeEntry oldTreeEntry=oldItem.getTreeEntry();
    final GitTreeEntry newTreeEntry=newItem.getTreeEntry();
    if (oldTreeEntry == null || newTreeEntry == null) {
      throw new IllegalStateException("String_Node_Str");
    }
    compare=oldItem.getTreeEntry().compareTo(newItem.getTreeEntry());
  }
  final GitFile oldEntry;
  final GitFile newEntry;
  if (compare <= 0) {
    oldEntry=oldItem;
    oldItem=nextItem(oldIter);
  }
 else {
    oldEntry=null;
  }
  if (compare >= 0) {
    newEntry=newItem;
    newItem=nextItem(newIter);
  }
 else {
    newEntry=null;
  }
  return new GitLogPair(oldEntry,newEntry);
}

Fixed version (ground truth):
@Override public GitLogPair next(){
  final int compare;
  if (newItem == null) {
    compare=-1;
  }
 else   if (oldItem == null) {
    compare=1;
  }
 else {
    final GitTreeEntry oldTreeEntry=oldItem.getTreeEntry();
    final GitTreeEntry newTreeEntry=newItem.getTreeEntry();
    if (oldTreeEntry == null || newTreeEntry == null) {
      throw new IllegalStateException("String_Node_Str");
    }
    compare=oldTreeEntry.compareTo(newTreeEntry);
  }
  final GitFile oldEntry;
  final GitFile newEntry;
  if (compare <= 0) {
    oldEntry=oldItem;
    oldItem=nextItem(oldIter);
  }
 else {
    oldEntry=null;
  }
  if (compare >= 0) {
    newEntry=newItem;
    newItem=nextItem(newIter);
  }
 else {
    newEntry=null;
  }
  return new GitLogPair(oldEntry,newEntry);
}
Program: 8964
Project: 8964
Buggy source:
@NotNull private static Iterable<GitFile> getIterable(@Nullable GitFile tree) throws IOException, SVNException {
  return tree != null ? tree.getEntries() : Collections.emptyList();
}

Fixed version (ground truth):
@NotNull private static Iterable<GitFile> getIterable(@Nullable GitFile tree) throws IOException, SVNException {
  try {
    return tree != null ? tree.getEntries() : Collections.emptyList();
  }
 catch (  SvnForbiddenException e) {
    return Collections.emptyList();
  }
}
Program: 8966
Project: 8966
Buggy source:
private void openFile(@NotNull SessionContext context,@NotNull OpenParams args) throws SVNException, IOException {
  final EntryUpdater parent=getParent(args.parentToken);
  final int rev=args.rev.length > 0 ? args.rev[0] : -1;
  log.debug("String_Node_Str",args.name,rev);
  VcsFile vcsFile=parent.getEntry(StringHelper.baseName(args.name));
  final VcsDeltaConsumer deltaConsumer=writer.modifyFile(parent.entry,vcsFile.getFileName(),vcsFile);
  files.put(args.token,new FileUpdater(deltaConsumer));
  if (parent.head && (rev >= 0)) {
    checkUpToDate(vcsFile,rev,true);
  }
  parent.changes.add(treeBuilder -> treeBuilder.saveFile(StringHelper.baseName(args.name),deltaConsumer,true));
}

Fixed version (ground truth):
private void openFile(@NotNull SessionContext context,@NotNull OpenParams args) throws SVNException, IOException {
  final EntryUpdater parent=getParent(args.parentToken);
  final int rev=args.rev.length > 0 ? args.rev[0] : -1;
  context.checkWrite(StringHelper.joinPath(parent.entry.getFullPath(),args.name));
  log.debug("String_Node_Str",args.name,rev);
  VcsFile vcsFile=parent.getEntry(StringHelper.baseName(args.name));
  final VcsDeltaConsumer deltaConsumer=writer.modifyFile(parent.entry,vcsFile.getFileName(),vcsFile);
  files.put(args.token,new FileUpdater(deltaConsumer));
  if (parent.head && (rev >= 0)) {
    checkUpToDate(vcsFile,rev,true);
  }
  parent.changes.add(treeBuilder -> treeBuilder.saveFile(StringHelper.baseName(args.name),deltaConsumer,true));
}
Program: 8967
Project: 8967
Buggy source:
private void editorCommand(@NotNull SessionContext context) throws IOException, SVNException {
  final SvnServerParser parser=context.getParser();
  final SvnServerWriter writer=context.getWriter();
  parser.readToken(ListBeginToken.class);
  final String cmd=parser.readText();
  log.debug("String_Node_Str",cmd);
  BaseCmd command=exitCommands.get(cmd);
  if (command == null) {
    context.push(this::editorCommand);
    command=commands.get(cmd);
  }
  if ((command != null) && (!aborted)) {
    try {
      Object param=MessageParser.parse(command.getArguments(),parser);
      parser.readToken(ListEndToken.class);
      command.process(context,param);
    }
 catch (    Throwable e) {
      log.warn("String_Node_Str" + cmd,e);
      aborted=true;
      throw e;
    }
  }
 else   if (command != null) {
    parser.skipItems();
  }
 else {
    log.error("String_Node_Str",cmd);
    BaseCmd.sendError(writer,SVNErrorMessage.create(SVNErrorCode.RA_SVN_UNKNOWN_CMD,"String_Node_Str" + cmd));
    parser.skipItems();
  }
}

Fixed version (ground truth):
private void editorCommand(@NotNull SessionContext context) throws IOException, SVNException {
  final SvnServerParser parser=context.getParser();
  final SvnServerWriter writer=context.getWriter();
  parser.readToken(ListBeginToken.class);
  final String cmd=parser.readText();
  log.debug("String_Node_Str",cmd);
  BaseCmd command=exitCommands.get(cmd);
  if (command == null) {
    context.push(this::editorCommand);
    command=commands.get(cmd);
  }
  if ((command != null) && (!aborted)) {
    try {
      Object param=MessageParser.parse(command.getArguments(),parser);
      parser.readToken(ListEndToken.class);
      command.process(context,param);
    }
 catch (    SVNException e) {
      if (e.getErrorMessage().getErrorCode() != SVNErrorCode.RA_NOT_AUTHORIZED) {
        log.warn("String_Node_Str" + cmd,e);
      }
      aborted=true;
      throw e;
    }
catch (    Throwable e) {
      log.warn("String_Node_Str" + cmd,e);
      aborted=true;
      throw e;
    }
  }
 else   if (command != null) {
    parser.skipItems();
  }
 else {
    log.error("String_Node_Str",cmd);
    BaseCmd.sendError(writer,SVNErrorMessage.create(SVNErrorCode.RA_SVN_UNKNOWN_CMD,"String_Node_Str" + cmd));
    parser.skipItems();
  }
}
Program: 8968
Project: 8968
Buggy source:
@Override protected void processCommand(@NotNull SessionContext context,@NotNull Params args) throws IOException, SVNException {
  final int rev=getRevision(args.rev,() -> context.getRepository().getLatestRevision().getId());
  final String path=context.getRepositoryPath(args.path);
  final LockTarget lockTarget=new LockTarget(path,rev);
  final String comment=args.comment.length == 0 ? null : args.comment[0];
  final LockDesc[] lockDescs=context.getRepository().wrapLockWrite((lockManager) -> lockManager.lock(context,comment,args.stealLock,new LockTarget[]{lockTarget}));
  if (lockDescs.length != 1) {
    throw new IllegalStateException();
  }
  final SvnServerWriter writer=context.getWriter();
  writer.listBegin().word("String_Node_Str").listBegin();
  LockCmd.writeLock(writer,lockDescs[0]);
  writer.listEnd().listEnd();
}

Fixed version (ground truth):
@Override protected void processCommand(@NotNull SessionContext context,@NotNull Params args) throws IOException, SVNException {
  final int rev=getRevision(args.rev,() -> context.getRepository().getLatestRevision().getId());
  final String path=context.getRepositoryPath(args.path);
  final LockTarget lockTarget=new LockTarget(path,rev);
  final String comment=args.comment.length == 0 ? null : args.comment[0];
  context.checkWrite(path);
  final LockDesc[] lockDescs=context.getRepository().wrapLockWrite((lockManager) -> lockManager.lock(context,comment,args.stealLock,new LockTarget[]{lockTarget}));
  if (lockDescs.length != 1) {
    throw new IllegalStateException();
  }
  final SvnServerWriter writer=context.getWriter();
  writer.listBegin().word("String_Node_Str").listBegin();
  LockCmd.writeLock(writer,lockDescs[0]);
  writer.listEnd().listEnd();
}
Program: 8969
Project: 8969
Buggy source:
@Override protected void processCommand(@NotNull SessionContext context,@NotNull Params args) throws IOException, SVNException {
  final SvnServerWriter writer=context.getWriter();
  final int latestRev=context.getRepository().getLatestRevision().getId();
  final String comment=args.comment.length == 0 ? null : args.comment[0];
  final LockTarget[] targets=new LockTarget[args.paths.length];
  for (int i=0; i < args.paths.length; ++i) {
    final String path=context.getRepositoryPath(args.paths[i].path);
    final int rev=getRevision(args.paths[i].rev,latestRev);
    targets[i]=new LockTarget(path,rev);
  }
  final LockDesc[] locks;
  try {
    locks=context.getRepository().wrapLockWrite((lockManager) -> lockManager.lock(context,comment,args.stealLock,targets));
    for (    LockDesc lock : locks) {
      writer.listBegin().word("String_Node_Str");
      LockCmd.writeLock(writer,lock);
      writer.listEnd();
    }
  }
 catch (  SVNException e) {
    sendError(writer,e.getErrorMessage());
  }
  writer.word("String_Node_Str");
  writer.listBegin().word("String_Node_Str").listBegin().listEnd().listEnd();
}

Fixed version (ground truth):
@Override protected void processCommand(@NotNull SessionContext context,@NotNull Params args) throws IOException, SVNException {
  final SvnServerWriter writer=context.getWriter();
  final int latestRev=context.getRepository().getLatestRevision().getId();
  final String comment=args.comment.length == 0 ? null : args.comment[0];
  final LockTarget[] targets=new LockTarget[args.paths.length];
  for (int i=0; i < args.paths.length; ++i) {
    final String path=context.getRepositoryPath(args.paths[i].path);
    context.checkWrite(path);
    final int rev=getRevision(args.paths[i].rev,latestRev);
    targets[i]=new LockTarget(path,rev);
  }
  final LockDesc[] locks;
  try {
    locks=context.getRepository().wrapLockWrite((lockManager) -> lockManager.lock(context,comment,args.stealLock,targets));
    for (    LockDesc lock : locks) {
      writer.listBegin().word("String_Node_Str");
      LockCmd.writeLock(writer,lock);
      writer.listEnd();
    }
  }
 catch (  SVNException e) {
    sendError(writer,e.getErrorMessage());
  }
  writer.word("String_Node_Str");
  writer.listBegin().word("String_Node_Str").listBegin().listEnd().listEnd();
}
Program: 8970
Project: 8970
Buggy source:
@Override public void filter(ContainerRequestContext requestContext) throws IOException {
  final WebServer server=context.getShared().sure(WebServer.class);
  User user=server.getAuthInfo(requestContext.getHeaderString(HttpHeaders.AUTHORIZATION));
  try {
    checkAccess(context,user,checker);
    requestContext.setProperty(User.class.getName(),user);
  }
 catch (  ClientErrorException e) {
    requestContext.abortWith(e.getResponse());
  }
}

Fixed version (ground truth):
@Override public void filter(ContainerRequestContext requestContext) throws IOException {
  final WebServer server=context.getShared().sure(WebServer.class);
  User user=server.getAuthInfo(requestContext.getHeaderString(HttpHeaders.AUTHORIZATION));
  try {
    if (user == null) {
      user=User.getAnonymous();
    }
    checkAccess(context,user,checker);
    requestContext.setProperty(User.class.getName(),user);
  }
 catch (  ClientErrorException e) {
    requestContext.abortWith(e.getResponse());
  }
}
Program: 8971
Project: 8971
Buggy source:
@Nullable public static Response checkAccess(@NotNull LocalContext context,@Nullable User user,@NotNull Checker checker) throws IOException, ClientErrorException {
  final VcsAccess access=context.sure(VcsAccess.class);
  if (user == null) {
    user=User.getAnonymous();
  }
  try {
    checker.check(access,user);
    return null;
  }
 catch (  SVNException ignored) {
    if (user.isAnonymous()) {
      final WebServer server=context.getShared().sure(WebServer.class);
      throw new NotAuthorizedException(Response.status(Response.Status.UNAUTHORIZED).header("String_Node_Str","String_Node_Str" + server.getRealm() + "String_Node_Str").entity("String_Node_Str").build());
    }
 else {
      throw new ForbiddenException(Response.status(Response.Status.FORBIDDEN).entity("String_Node_Str").build());
    }
  }
}

Fixed version (ground truth):
@Nullable public static Response checkAccess(@NotNull LocalContext context,@NotNull User user,@NotNull Checker checker) throws IOException, ClientErrorException {
  final VcsAccess access=context.sure(VcsAccess.class);
  try {
    checker.check(access,user);
    return null;
  }
 catch (  SVNException ignored) {
    if (user.isAnonymous()) {
      final WebServer server=context.getShared().sure(WebServer.class);
      throw new NotAuthorizedException(Response.status(Response.Status.UNAUTHORIZED).header("String_Node_Str","String_Node_Str" + server.getRealm() + "String_Node_Str").entity("String_Node_Str").build());
    }
 else {
      throw new ForbiddenException(Response.status(Response.Status.FORBIDDEN).entity("String_Node_Str").build());
    }
  }
}
Program: 8972
Project: 8972
Buggy source:
/** 
 * Check for deny modify locking file.
 * @throws Exception
 */
@Test(dataProvider="String_Node_Str",dataProviderClass=SvnTesterDataProvider.class) public void modifyLockedInvalidLock(@NotNull SvnTesterFactory factory) throws Exception {
  try (SvnTester server=factory.create()){
    final SVNRepository repo=server.openSvnRepository();
    createFile(repo,"String_Node_Str","String_Node_Str",null);
    final long latestRevision=repo.getLatestRevision();
    final SVNLock oldLock=lock(repo,"String_Node_Str",latestRevision,false,null);
    Assert.assertNotNull(oldLock);
    unlock(repo,oldLock,false,null);
    final SVNLock newLock=lock(repo,"String_Node_Str",latestRevision,false,null);
    try {
      final Map<String,String> locks=new HashMap<>();
      locks.put(oldLock.getPath(),oldLock.getID());
      final ISVNEditor editor=repo.getCommitEditor("String_Node_Str",locks,false,null);
      editor.openRoot(-1);
      editor.openFile("String_Node_Str",latestRevision);
      sendDeltaAndClose(editor,"String_Node_Str","String_Node_Str","String_Node_Str");
      editor.closeDir();
      editor.closeEdit();
      Assert.fail();
    }
 catch (    SVNException e) {
      Assert.assertEquals(e.getErrorMessage().getErrorCode(),SVNErrorCode.FS_BAD_LOCK_TOKEN);
    }
    compareLock(server.openSvnRepository().getLock("String_Node_Str"),newLock);
  }
 }

Fixed version (ground truth):
/** 
 * Check for deny modify locking file.
 * @throws Exception
 */
@Test(dataProvider="String_Node_Str",dataProviderClass=SvnTesterDataProvider.class) public void modifyLockedInvalidLock(@NotNull SvnTesterFactory factory) throws Exception {
  try (SvnTester server=factory.create()){
    final SVNRepository repo=server.openSvnRepository();
    createFile(repo,"String_Node_Str","String_Node_Str",null);
    final long latestRevision=repo.getLatestRevision();
    final SVNLock oldLock=lock(repo,"String_Node_Str",latestRevision,false,null);
    Assert.assertNotNull(oldLock);
    unlock(repo,oldLock,false,null);
    SVNLock newLock;
    for (int pass=0; ; ++pass) {
      Assert.assertTrue(pass < MAX_RELOCK_COUNT);
      newLock=lock(repo,"String_Node_Str",latestRevision,false,null);
      Assert.assertNotNull(newLock);
      if (!newLock.getID().equals(oldLock.getID())) {
        break;
      }
      unlock(repo,newLock,false,null);
    }
    try {
      final Map<String,String> locks=new HashMap<>();
      locks.put(oldLock.getPath(),oldLock.getID());
      final ISVNEditor editor=repo.getCommitEditor("String_Node_Str",locks,false,null);
      editor.openRoot(-1);
      editor.openFile("String_Node_Str",latestRevision);
      sendDeltaAndClose(editor,"String_Node_Str","String_Node_Str","String_Node_Str");
      editor.closeDir();
      editor.closeEdit();
      Assert.fail();
    }
 catch (    SVNException e) {
      Assert.assertEquals(e.getErrorMessage().getErrorCode(),SVNErrorCode.FS_BAD_LOCK_TOKEN);
    }
    compareLock(server.openSvnRepository().getLock("String_Node_Str"),newLock);
  }
 }
Program: 8973
Project: 8973
Buggy source:
@NotNull private FileOutputStream ensureFile() throws IOException {
  if (fileOutputStream == null) {
    tempFile=new FileHolder();
    fileOutputStream=new FileOutputStream(tempFile.file);
  }
  return fileOutputStream;
}

Fixed version (ground truth):
@NotNull private FileOutputStream ensureFile() throws IOException {
  if (fileOutputStream == null) {
    file=File.createTempFile("String_Node_Str","String_Node_Str");
    file.deleteOnExit();
    fileOutputStream=new FileOutputStream(file);
  }
  return fileOutputStream;
}
Program: 8974
Project: 8974
Buggy source:
public TemporaryOutputStream(int maxMemorySize){
  this.maxMemorySize=maxMemorySize;
}

Fixed version (ground truth):
public TemporaryOutputStream(int maxMemorySize){
  this.maxMemorySize=maxMemorySize;
  this.holder=new FileHolder(this::cleanup);
}
Program: 8975
Project: 8975
Buggy source:
private TemporaryInputStream(@NotNull byte[] memoryBytes,@NotNull FileHolder holder) throws FileNotFoundException {
  this.memoryBytes=memoryBytes;
  this.holder=holder.copy();
  this.fileStream=new FileInputStream(holder.file);
}

Fixed version (ground truth):
private TemporaryInputStream(@NotNull byte[] memoryBytes,@NotNull File file,@NotNull Holder holder) throws FileNotFoundException {
  this.memoryBytes=memoryBytes;
  this.holder=holder.copy();
  this.fileStream=new FileInputStream(file);
}
Program: 8976
Project: 8976
Buggy source:
@TestOnly @Nullable File tempFile(){
  return tempFile != null ? tempFile.file : null;
}

Fixed version (ground truth):
@TestOnly @Nullable File tempFile(){
  return file;
}
Program: 8977
Project: 8977
Buggy source:
@NotNull public FileHolder copy(){
  usages.incrementAndGet();
  return new FileHolder(file,usages);
}

Fixed version (ground truth):
@NotNull public FileHolder copy(){
  usages.incrementAndGet();
  return new FileHolder(action,usages);
}
Program: 8978
Project: 8978
Buggy source:
@NotNull public InputStream toInputStream() throws IOException {
  if (fileOutputStream != null) {
    flush();
  }
  if (tempFile != null) {
    return new TemporaryInputStream(memoryStream.toByteArray(),tempFile);
  }
 else {
    return new ByteArrayInputStream(memoryStream.toByteArray());
  }
}

Fixed version (ground truth):
@NotNull public InputStream toInputStream() throws IOException {
  if (fileOutputStream != null) {
    flush();
  }
  if (file != null) {
    return new TemporaryInputStream(memoryStream.toByteArray(),file,holder);
  }
 else {
    return new ByteArrayInputStream(memoryStream.toByteArray());
  }
}
Program: 8979
Project: 8979
Buggy source:
public void close() throws IOException {
  if (closed.compareAndSet(false,true)) {
    if (usages.decrementAndGet() == 0) {
      if (!file.delete()) {
        throw new IOException("String_Node_Str" + file.getAbsolutePath());
      }
    }
  }
}

Fixed version (ground truth):
@Override public void close() throws IOException {
  if (closed.compareAndSet(false,true)) {
    if (usages.decrementAndGet() == 0) {
      action.close();
    }
  }
}
Program: 8980
Project: 8980
Buggy source:
private FileHolder(@NotNull File file,@NotNull AtomicInteger usages){
  this.file=file;
  this.usages=usages;
}

Fixed version (ground truth):
private FileHolder(@NotNull CloseAction action,@NotNull AtomicInteger usages){
  this.action=action;
  this.usages=usages;
}