nus-yam/ex-repair huggingface dataset:
Program: 81434
Project: 81434
Buggy source:
private Sound[] transformSubsound(Sound[] subSound,int frequency,int length){
  int percent=(int)(frequency * 100.0 / this.frequency);
  Sound[] result=new Sound[subSound.length];
  PitchSoundTransformation pitcher=new PitchSoundTransformation(percent);
  if (percent < 98 || percent > 102) {
    for (int i=0; i < result.length; i++) {
      result[i]=pitcher.transform(subSound[i]);
    }
  }
  double factor=length / subSound.length;
  if (factor < 0.98 || factor > 1.02) {
    if (factor < 0.98) {
      SpeedUpSoundTransformation speedup=new SpeedUpSoundTransformation(100,percent);
      for (int i=0; i < result.length; i++) {
        result[i]=speedup.transform(subSound[i]);
      }
    }
 else     if (factor > 1.02) {
      SlowdownSoundTransformation slowdown=new SlowdownSoundTransformation(100,percent);
      for (int i=0; i < result.length; i++) {
        result[i]=slowdown.transform(subSound[i]);
      }
    }
  }
  return result;
}

Fixed version (ground truth):
private Sound transformSubsound(Sound[] subSound,int channelNum,int frequency,int length){
  int percent=(int)(frequency * 100.0 / this.frequency);
  Sound result=subSound[channelNum];
  PitchSoundTransformation pitcher=new PitchSoundTransformation(percent);
  if (percent < 98 || percent > 102) {
    result=pitcher.transform(result);
  }
  double factor=length / subSound.length;
  if (factor < 0.98 || factor > 1.02) {
    if (factor < 0.98) {
      SpeedUpSoundTransformation speedup=new SpeedUpSoundTransformation(100,percent);
      result=speedup.transform(result);
    }
 else     if (factor > 1.02) {
      SlowdownSoundTransformation slowdown=new SlowdownSoundTransformation(100,percent);
      result=slowdown.transform(result);
    }
  }
  return result;
}
Program: 81435
Project: 81435
Buggy source:
@Override public Sound[] getRelease(int frequency,int length){
  return this.transformSubsound(this.release,frequency,(int)(this.getRatio(this.release) * length));
}

Fixed version (ground truth):
@Override public Sound getRelease(int frequency,int channelnum,int length){
  return this.transformSubsound(this.release,channelnum,frequency,(int)(this.getRatio(this.release) * length));
}
Program: 81436
Project: 81436
Buggy source:
@Override public Sound transform(Sound sound){
  this.log(new LogEvent(LogLevel.VERBOSE,"String_Node_Str"));
  PacksList packsList=PacksList.getInstance();
  int threshold=100;
  int channelNum=sound.getChannelNum();
  Sound builtSound=new Sound(new long[0],sound.getNbBytesPerSample(),sound.getFreq(),channelNum);
  double[] freqs=new double[sound.getSamples().length / threshold + 1];
  this.log(new LogEvent(LogLevel.VERBOSE,"String_Node_Str"));
  Sound2Note.getSoundLoudestFreqs(freqs,sound,threshold);
  double lastFreq=freqs[0];
  int lastBegining=0;
  for (int i=0; i < freqs.length; i++) {
    this.log(new LogEvent(LogLevel.VERBOSE,"String_Node_Str" + i + "String_Node_Str"+ freqs.length));
    if (Math.abs(freqs[i] - lastFreq) > freqs[i] / 100) {
      int length=(i - 1 - lastBegining) * threshold;
      Note n=packsList.defaultPack.get("String_Node_Str").getNearestNote((int)lastFreq);
      builtSound.concat(n.getAttack((int)lastFreq,length)[channelNum],n.getDecay((int)lastFreq,length)[channelNum],n.getSustain((int)lastFreq,length)[channelNum],n.getRelease((int)lastFreq,length)[channelNum]);
      lastBegining=i;
      lastFreq=freqs[i];
    }
  }
  return builtSound;
}

Fixed version (ground truth):
@Override public Sound transform(Sound sound){
  this.log(new LogEvent(LogLevel.VERBOSE,"String_Node_Str"));
  PacksList packsList=PacksList.getInstance();
  int threshold=100;
  int channelNum=sound.getChannelNum();
  Sound builtSound=new Sound(new long[0],sound.getNbBytesPerSample(),sound.getFreq(),channelNum);
  double[] freqs=new double[sound.getSamples().length / threshold + 1];
  this.log(new LogEvent(LogLevel.VERBOSE,"String_Node_Str"));
  Sound2Note.getSoundLoudestFreqs(freqs,sound,threshold);
  double lastFreq=freqs[0];
  int lastBegining=0;
  for (int i=0; i < freqs.length; i++) {
    this.log(new LogEvent(LogLevel.VERBOSE,"String_Node_Str" + i + "String_Node_Str"+ freqs.length));
    if (Math.abs(freqs[i] - lastFreq) > freqs[i] / 100) {
      int length=(i - 1 - lastBegining) * threshold;
      Note n=packsList.defaultPack.get("String_Node_Str").getNearestNote((int)lastFreq);
      builtSound.concat(n.getAttack((int)lastFreq,channelNum,length),n.getDecay((int)lastFreq,channelNum,length),n.getSustain((int)lastFreq,channelNum,length),n.getRelease((int)lastFreq,channelNum,length));
      lastBegining=i;
      lastFreq=freqs[i];
    }
  }
  return builtSound;
}
Program: 81437
Project: 81437
Buggy source:
@Override protected FrequenciesState transformFrequencies(FrequenciesState fs,int offset,int powOf2NearestLength,int length,double maxfrequency){
  int total=(int)(this.sound.getSamples().length / factor);
  if (offset % ((total / 100 - (total / 100) % this.threshold)) == 0) {
    this.log(new LogEvent(LogLevel.VERBOSE,"String_Node_Str" + offset + "String_Node_Str"+ (int)(sound.getSamples().length * factor)));
  }
  if (this.writeIfGreaterEqThanFactor >= factor) {
    this.writeIfGreaterEqThanFactor-=factor;
    return fs;
  }
 else {
    this.writeIfGreaterEqThanFactor++;
    return null;
  }
}

Fixed version (ground truth):
@Override protected FrequenciesState transformFrequencies(FrequenciesState fs,int offset,int powOf2NearestLength,int length,double maxfrequency){
  int total=(int)(this.sound.getSamples().length / factor);
  if (total != 0 && offset % ((total / 100 - (total / 100) % this.threshold)) == 0) {
    this.log(new LogEvent(LogLevel.VERBOSE,"String_Node_Str" + offset + "String_Node_Str"+ (int)(sound.getSamples().length * factor)));
  }
  if (this.writeIfGreaterEqThanFactor >= factor) {
    this.writeIfGreaterEqThanFactor-=factor;
    return fs;
  }
 else {
    this.writeIfGreaterEqThanFactor++;
    return null;
  }
}
Program: 81438
Project: 81438
Buggy source:
protected static double computeLoudestFreq(FrequenciesState fs){
  double max=0;
  for (int i=0; i < fs.getState().length; i++) {
    double val=fs.getState()[i].abs();
    max=(max < val ? val : max);
  }
  return max;
}

Fixed version (ground truth):
protected static double computeLoudestFreq(FrequenciesState fs){
  double max=0;
  double freq=0;
  for (int i=0; i < fs.getState().length; i++) {
    double val=fs.getState()[i].abs();
    freq=(max < val ? i : freq);
    max=(max < val ? val : max);
  }
  return freq;
}
Program: 81439
Project: 81439
Buggy source:
private static int findFrequency(Sound channel1){
  final int threshold=100;
  double sum=0;
  final double[] magnitude=new double[channel1.getSamples().length / threshold + threshold];
  SoundTransformation magnFreqTransform=new NoOpFrequencySoundTransformation(){
    int index=0;
    @Override public Sound initSound(    Sound input){
      return super.initSound(input);
    }
    @Override protected double getLowThreshold(    double defaultValue){
      return threshold;
    }
    @Override public FrequenciesState transformFrequencies(    FrequenciesState fs,    int offset,    int powOf2NearestLength,    int length,    double maxFrequency){
      index++;
      magnitude[index]+=Sound2Note.computeLoudestFreq(fs);
      return super.transformFrequencies(fs,offset,powOf2NearestLength,length,maxFrequency);
    }
  }
;
  magnFreqTransform.transform(channel1);
  for (int i=0; i < magnitude.length; i++) {
    sum+=magnitude[i];
  }
  return (int)(sum / magnitude.length);
}

Fixed version (ground truth):
private static int findFrequency(Sound channel1){
  final int threshold=100;
  double sum=0;
  final double[] magnitude=new double[channel1.getSamples().length / threshold + 1];
  SoundTransformation magnFreqTransform=new NoOpFrequencySoundTransformation(){
    int index=0;
    @Override public Sound initSound(    Sound input){
      return super.initSound(input);
    }
    @Override protected double getLowThreshold(    double defaultValue){
      return threshold;
    }
    @Override public FrequenciesState transformFrequencies(    FrequenciesState fs,    int offset,    int powOf2NearestLength,    int length,    double maxFrequency){
      magnitude[index++]+=Sound2Note.computeLoudestFreq(fs);
      return super.transformFrequencies(fs,offset,powOf2NearestLength,length,maxFrequency);
    }
  }
;
  magnFreqTransform.transform(channel1);
  for (int i=0; i < magnitude.length; i++) {
    sum+=magnitude[i];
  }
  return (int)(sum / magnitude.length);
}
Program: 81440
Project: 81440
Buggy source:
public static void main(String[] args){
  try {
    File fParam=new File(args[0]);
    File fOrigin=new File("String_Node_Str");
    File fDest=new File("String_Node_Str");
    TestTransformMain.copyFile(fParam,fOrigin);
    new TransformSound(new PrintlnTransformObserver()).transformWav(fOrigin,fDest,new NoOpSoundTransformation());
  }
 catch (  FileNotFoundException e) {
    e.printStackTrace();
  }
catch (  UnsupportedAudioFileException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
public static void main(String[] args){
  try {
    File fParam=new File(args[0]);
    File fOrigin=new File("String_Node_Str");
    File fDest=new File("String_Node_Str");
    TestTransformMain.copyFile(fParam,fOrigin);
    new TransformSound(new PrintlnTransformObserver()).transformWav(fOrigin,fDest,new ReverseSoundTransformation());
  }
 catch (  FileNotFoundException e) {
    e.printStackTrace();
  }
catch (  UnsupportedAudioFileException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
}
Program: 81441
Project: 81441
Buggy source:
private Sound[] fromAudioInputStream(AudioInputStream ais) throws IOException {
  this.notifyAll("String_Node_Str");
  int channels=ais.getFormat().getChannels();
  int currentChannel=0;
  Sound[] ret=new Sound[channels];
  int length=(int)ais.getFrameLength();
  for (int channel=0; channel < channels; channel++) {
    ret[channel]=new Sound(new double[length],ais.getFormat().getFrameSize());
  }
  for (int position=0; position < length; ) {
    byte[] frame=new byte[ais.getFormat().getFrameSize()];
    ais.read(frame);
    this.byteArrayToFrame(frame,ret[currentChannel],position,ais.getFormat().isBigEndian());
    currentChannel=(currentChannel + 1) % channels;
    if (currentChannel == 0) {
      position++;
    }
  }
  this.notifyAll("String_Node_Str");
  return ret;
}

Fixed version (ground truth):
private Sound[] fromAudioInputStream(AudioInputStream ais) throws IOException {
  this.notifyAll("String_Node_Str");
  int channels=ais.getFormat().getChannels();
  int currentChannel=0;
  Sound[] ret=new Sound[channels];
  int length=(int)(ais.getFrameLength() / channels);
  for (int channel=0; channel < channels; channel++) {
    ret[channel]=new Sound(new double[length],ais.getFormat().getFrameSize());
  }
  for (int position=0; position < length; ) {
    byte[] frame=new byte[ais.getFormat().getFrameSize()];
    ais.read(frame);
    this.byteArrayToFrame(frame,ret[currentChannel],position,ais.getFormat().isBigEndian());
    currentChannel=(currentChannel + 1) % channels;
    if (currentChannel == 0) {
      position++;
    }
  }
  this.notifyAll("String_Node_Str");
  return ret;
}
Program: 81442
Project: 81442
Buggy source:
private AudioInputStream toStream(Sound[] channels,AudioFormat audioFormat){
  int length=audioFormat.getFrameSize() * channels[0].getSamples().length;
  byte[] data=new byte[length];
  for (int i=0; i < data.length; i++) {
    int currentFrameByte=i % audioFormat.getFrameSize();
    int currentChannel=(i / audioFormat.getFrameSize()) % channels.length;
    int currentFrame=i / (audioFormat.getFrameSize() * channels.length);
    if (!audioFormat.isBigEndian()) {
      data[i]=(byte)((int)(channels[currentChannel].getSamples()[currentFrame]) >> (8 * currentFrameByte));
    }
 else {
      data[i]=(byte)((int)(channels[currentChannel].getSamples()[currentFrame]) >> (8 * (audioFormat.getFrameSize() - 1 - currentFrameByte)));
    }
  }
  this.notifyAll("String_Node_Str");
  ByteArrayInputStream bais=new ByteArrayInputStream(data);
  return new AudioInputStream(bais,audioFormat,channels[0].getSamples().length);
}

Fixed version (ground truth):
private AudioInputStream toStream(Sound[] channels,AudioFormat audioFormat){
  int length=channels.length * audioFormat.getFrameSize() * channels[0].getSamples().length;
  byte[] data=new byte[length];
  for (int i=0; i < data.length; i++) {
    int currentFrameByte=i % audioFormat.getFrameSize();
    int currentChannel=(i / audioFormat.getFrameSize()) % channels.length;
    int currentFrame=i / (audioFormat.getFrameSize() * channels.length);
    if (!audioFormat.isBigEndian()) {
      data[i]=(byte)((int)(channels[currentChannel].getSamples()[currentFrame]) >> (8 * currentFrameByte));
    }
 else {
      data[i]=(byte)((int)(channels[currentChannel].getSamples()[currentFrame]) >> (8 * (audioFormat.getFrameSize() - 1 - currentFrameByte)));
    }
  }
  this.notifyAll("String_Node_Str");
  ByteArrayInputStream bais=new ByteArrayInputStream(data);
  return new AudioInputStream(bais,audioFormat,channels[0].getSamples().length * channels.length);
}
Program: 81443
Project: 81443
Buggy source:
@Test public void test8bits(){
  try {
    ClassLoader classLoader=Thread.currentThread().getContextClassLoader();
    new TransformSound(new PrintlnTransformObserver()).transformWav(new File(classLoader.getResource("String_Node_Str").getFile()),new File(classLoader.getResource("String_Node_Str").getFile()),new EightBitsSoundTransformation(25));
  }
 catch (  UnsupportedAudioFileException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
@Test public void test8bits(){
  try {
    ClassLoader classLoader=Thread.currentThread().getContextClassLoader();
    new TransformSound(new PrintlnTransformObserver()).transformWav(new File(classLoader.getResource("String_Node_Str").getFile()),new File(classLoader.getResource("String_Node_Str").getPath() + "String_Node_Str"),new EightBitsSoundTransformation(25));
  }
 catch (  UnsupportedAudioFileException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
}
Program: 81444
Project: 81444
Buggy source:
@Override public Sound transform(Sound input){
  SplineInterpolator reg=new SplineInterpolator();
  double[] x=new double[input.getSamples().length / step];
  double[] y=new double[input.getSamples().length / step];
  for (int i=0; i < input.getSamples().length; i+=step) {
    if (i / step < x.length) {
      x[i / step]=i;
      y[i / step]=input.getSamples()[i];
    }
  }
  PolynomialSplineFunction psf=reg.interpolate(x,y);
  Sound outputSound=new Sound(new double[input.getSamples().length],input.getNbBytesPerFrame());
  for (int i=0; i < input.getSamples().length; i+=step) {
    outputSound.getSamples()[i]=psf.value(i);
  }
  return outputSound;
}

Fixed version (ground truth):
@Override public Sound transform(Sound input){
  SplineInterpolator reg=new SplineInterpolator();
  double[] x=new double[input.getSamples().length / step];
  double[] y=new double[input.getSamples().length / step];
  for (int i=0; i < input.getSamples().length; i+=step) {
    if (i / step < x.length) {
      x[i / step]=i;
      y[i / step]=input.getSamples()[i];
    }
  }
  PolynomialSplineFunction psf=reg.interpolate(x,y);
  Sound outputSound=new Sound(new double[input.getSamples().length],input.getNbBytesPerFrame());
  for (int i=0; i < input.getSamples().length; i+=step) {
    if (i / step < x.length) {
      outputSound.getSamples()[i]=psf.value(i);
    }
 else {
      outputSound.getSamples()[i]=input.getSamples()[i];
    }
  }
  return outputSound;
}
Program: 81445
Project: 81445
Buggy source:
public static void main(String[] args){
  try {
    File fParam=new File(args[0]);
    File fOrigin=new File("String_Node_Str");
    File fDest=new File("String_Node_Str");
    TestTransformMain.copyFile(fParam,fOrigin);
    new TransformSound(new PrintlnTransformObserver()).transformWav(fOrigin,fDest,new LinearRegressionSoundTransformation(1));
  }
 catch (  FileNotFoundException e) {
    e.printStackTrace();
  }
catch (  UnsupportedAudioFileException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
public static void main(String[] args){
  try {
    File fParam=new File(args[0]);
    File fOrigin=new File("String_Node_Str");
    File fDest=new File("String_Node_Str");
    TestTransformMain.copyFile(fParam,fOrigin);
    new TransformSound(new PrintlnTransformObserver()).transformWav(fOrigin,fDest,new LinearRegressionSoundTransformation(25));
  }
 catch (  FileNotFoundException e) {
    e.printStackTrace();
  }
catch (  UnsupportedAudioFileException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
}
Program: 81446
Project: 81446
Buggy source:
@Override public Sound transform(Sound input){
  Sound fs=input;
  UnivariateFunction function=this.getFunction(fs);
  return DownsampleSoundTransformation.buildSoundFromFunction(function,fs.getSamples().length,input.getNbBytesPerFrame(),input.getFreq());
}

Fixed version (ground truth):
@Override public Sound transform(Sound input){
  Sound fs=input;
  UnivariateFunction function=this.getFunction(fs);
  return DownsampleSoundTransformation.buildSoundFromFunction(function,this.times,fs.getSamples().length,input.getNbBytesPerFrame(),input.getFreq());
}
Program: 81447
Project: 81447
Buggy source:
public DownsampleSoundTransformation(){
}

Fixed version (ground truth):
public DownsampleSoundTransformation(int times){
  this.times=times;
}
Program: 81448
Project: 81448
Buggy source:
private static Sound buildSoundFromFunction(UnivariateFunction function,int length,int nbBytesPerFrame,int freq){
  double[] result=new double[length];
  for (int i=0; i < length; i++) {
    result[i]=function.value(i);
  }
  return new Sound(result,nbBytesPerFrame,freq);
}

Fixed version (ground truth):
private static Sound buildSoundFromFunction(UnivariateFunction function,int times,int length,int nbBytesPerFrame,int freq){
  double[] result=new double[length * times];
  for (int i=0; i < length * times; i++) {
    result[i]=function.value(i / times);
  }
  return new Sound(result,nbBytesPerFrame,freq);
}
Program: 81449
Project: 81449
Buggy source:
@Test public void test8bits(){
  try {
    ClassLoader classLoader=Thread.currentThread().getContextClassLoader();
    new TransformSound(new PrintlnTransformObserver()).transformWav(new File(classLoader.getResource("String_Node_Str").getFile()),new File(classLoader.getResource("String_Node_Str").getPath() + "String_Node_Str"),new EightBitsSoundTransformation(25));
  }
 catch (  UnsupportedAudioFileException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
@Test public void test8bits(){
  try {
    new TransformSound(new PrintlnTransformObserver()).transformWav(input,output,new EightBitsSoundTransformation(25));
  }
 catch (  UnsupportedAudioFileException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
}
Program: 81450
Project: 81450
Buggy source:
@Override public Sound transform(Sound input){
  Sound fs=input;
  UnivariateFunction function=this.getFunction(fs);
  return DownsampleSoundTransformation.buildSoundFromFunction(function,(int)fs.getTime()[fs.getTime().length - 1],input.getNbBytesPerFrame());
}

Fixed version (ground truth):
@Override public Sound transform(Sound input){
  Sound fs=input;
  UnivariateFunction function=this.getFunction(fs);
  return DownsampleSoundTransformation.buildSoundFromFunction(function,fs.getSamples().length,input.getNbBytesPerFrame());
}
Program: 81451
Project: 81451
Buggy source:
protected UnivariateFunction getFunction(Sound fs){
  return new SplineInterpolator().interpolate(fs.getTime(),fs.getSamples());
}

Fixed version (ground truth):
protected UnivariateFunction getFunction(Sound fs){
  double[] time=new double[fs.getSamples().length];
  for (int i=0; i < time.length; i++) {
    time[i]=i;
  }
  return new SplineInterpolator().interpolate(time,fs.getSamples());
}
Program: 81452
Project: 81452
Buggy source:
public FilteredSound(double[] samples,double[] time,int nbBytesPerFrame){
  super(samples,nbBytesPerFrame);
  this.time=time;
}

Fixed version (ground truth):
public FilteredSound(double[] samples,int division,int nbBytesPerFrame){
  super(samples,nbBytesPerFrame);
  this.division=division;
}
Program: 81453
Project: 81453
Buggy source:
private static Sound precisionFilter(Sound sound,float percent){
  float total=100;
  if (percent == total) {
    return new Sound(sound.getSamples(),sound.getNbBytesPerFrame());
  }
  float nbSamples=sound.getSamples().length;
  float nbFiltered=percent / total * nbSamples;
  float incr=nbSamples / nbFiltered;
  double[] data=sound.getSamples();
  double[] ret=new double[(int)(nbFiltered)];
  double[] time=new double[(int)(nbFiltered)];
  for (float i=0; i < incr * nbFiltered; i+=incr) {
    int j=(int)(i / incr);
    if (j < ret.length) {
      ret[j]=data[(int)i];
      time[j]=i;
    }
  }
  return new FilteredSound(ret,time,sound.getNbBytesPerFrame());
}

Fixed version (ground truth):
private static Sound precisionFilter(Sound sound,float percent){
  float total=100;
  if (percent == total) {
    return new Sound(sound.getSamples(),sound.getNbBytesPerFrame());
  }
  float nbSamples=sound.getSamples().length;
  float nbFiltered=percent / total * nbSamples;
  float incr=nbSamples / nbFiltered;
  double[] data=sound.getSamples();
  double[] ret=new double[(int)(nbFiltered)];
  for (float i=0; i < incr * nbFiltered; i+=incr) {
    int j=(int)(i / incr);
    if (j < ret.length) {
      ret[j]=data[(int)i];
    }
  }
  return new FilteredSound(ret,(int)incr,sound.getNbBytesPerFrame());
}
Program: 81454
Project: 81454
Buggy source:
public static void main(String[] args){
  try {
    File fParam=new File(args[0]);
    File fOrigin=new File("String_Node_Str");
    File fDest=new File("String_Node_Str");
    TestTransformMain.copyFile(fParam,fOrigin);
    new TransformSound(new PrintlnTransformObserver()).transformWav(fOrigin,fDest,new NormalizeSoundTransformation());
  }
 catch (  FileNotFoundException e) {
    e.printStackTrace();
  }
catch (  UnsupportedAudioFileException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
public static void main(String[] args){
  try {
    File fParam=new File(args[0]);
    File fOrigin=new File("String_Node_Str");
    File fDest=new File("String_Node_Str");
    TestTransformMain.copyFile(fParam,fOrigin);
    new TransformSound(new PrintlnTransformObserver()).transformWav(fOrigin,fDest,new NoOpSoundTransformation());
  }
 catch (  FileNotFoundException e) {
    e.printStackTrace();
  }
catch (  UnsupportedAudioFileException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
}
Program: 81455
Project: 81455
Buggy source:
public AudioInputStream transformAudioStream(AudioInputStream ais,SoundTransformation... sts) throws IOException {
  Sound[] input=this.fromAudioInputStream(ais);
  Sound[] output=Arrays.copyOf(input,input.length);
  int transformNumber=0;
  for (  SoundTransformation st : sts) {
    for (int i=0; i < input.length; i++) {
      this.notifyAll("String_Node_Str" + (transformNumber + 1) + "String_Node_Str"+ (i + 1)+ "String_Node_Str"+ input.length);
      output[i]=st.transform(output[i]);
    }
    transformNumber++;
  }
  if (sts.length == 0) {
    output=input;
  }
  this.notifyAll("String_Node_Str");
  return this.toStream(output,ais.getFormat());
}

Fixed version (ground truth):
public AudioInputStream transformAudioStream(AudioInputStream ais,SoundTransformation... sts) throws IOException {
  Sound[] input=this.fromAudioInputStream(ais);
  Sound[] output=Arrays.copyOf(input,input.length);
  int transformNumber=0;
  for (  SoundTransformation st : sts) {
    for (int i=0; i < input.length; i++) {
      this.notifyAll("String_Node_Str" + (transformNumber + 1) + "String_Node_Str"+ sts.length+ "String_Node_Str"+ st.getClass().getSimpleName()+ "String_Node_Str"+ (i + 1)+ "String_Node_Str"+ input.length);
      output[i]=st.transform(output[i]);
    }
    transformNumber++;
  }
  if (sts.length == 0) {
    output=input;
  }
  this.notifyAll("String_Node_Str");
  return this.toStream(output,ais.getFormat());
}
Program: 81456
Project: 81456
Buggy source:
private Sound[] fromAudioInputStream(AudioInputStream ais) throws IOException {
  this.notifyAll("String_Node_Str");
  int channels=ais.getFormat().getChannels();
  int currentChannel=0;
  Sound[] ret=new Sound[channels];
  for (int channel=0; channel < channels; channel++) {
    ret[channel]=new Sound(new double[(int)ais.getFrameLength()],ais.getFormat().getFrameSize());
  }
  for (int position=0; position < ais.getFrameLength(); ) {
    byte[] frame=new byte[ais.getFormat().getFrameSize()];
    ais.read(frame);
    this.byteArrayToFrame(frame,ret[currentChannel],position,ais.getFormat().isBigEndian());
    currentChannel=(currentChannel + 1) % channels;
    if (currentChannel == 0) {
      position++;
    }
  }
  this.notifyAll("String_Node_Str");
  return ret;
}

Fixed version (ground truth):
private Sound[] fromAudioInputStream(AudioInputStream ais) throws IOException {
  this.notifyAll("String_Node_Str");
  int channels=ais.getFormat().getChannels();
  int currentChannel=0;
  Sound[] ret=new Sound[channels];
  int length=(int)(ais.getFrameLength() / ais.getFormat().getFrameSize());
  for (int channel=0; channel < channels; channel++) {
    ret[channel]=new Sound(new double[length],ais.getFormat().getFrameSize());
  }
  for (int position=0; position < length; ) {
    byte[] frame=new byte[ais.getFormat().getFrameSize()];
    ais.read(frame);
    this.byteArrayToFrame(frame,ret[currentChannel],position,ais.getFormat().isBigEndian());
    currentChannel=(currentChannel + 1) % channels;
    if (currentChannel == 0) {
      position++;
    }
  }
  this.notifyAll("String_Node_Str");
  return ret;
}
Program: 81457
Project: 81457
Buggy source:
private Sound[] fromAudioInputStream(AudioInputStream ais) throws IOException {
  this.notifyAll("String_Node_Str");
  int channels=ais.getFormat().getChannels();
  int currentChannel=0;
  Sound[] ret=new Sound[channels];
  int length=(int)(ais.getFrameLength() / channels);
  for (int channel=0; channel < channels; channel++) {
    ret[channel]=new Sound(new double[length],ais.getFormat().getFrameSize(),ais.getFormat().getFrameSize());
  }
  for (int position=0; position < length; ) {
    byte[] frame=new byte[ais.getFormat().getFrameSize()];
    ais.read(frame);
    this.byteArrayToFrame(frame,ret[currentChannel],position,ais.getFormat().isBigEndian());
    currentChannel=(currentChannel + 1) % channels;
    if (currentChannel == 0) {
      position++;
    }
  }
  this.notifyAll("String_Node_Str");
  return ret;
}

Fixed version (ground truth):
private Sound[] fromAudioInputStream(AudioInputStream ais) throws IOException {
  this.notifyAll("String_Node_Str");
  int channels=ais.getFormat().getChannels();
  int currentChannel=0;
  Sound[] ret=new Sound[channels];
  int length=(int)(ais.getFrameLength() / channels);
  for (int channel=0; channel < channels; channel++) {
    ret[channel]=new Sound(new double[length],ais.getFormat().getFrameSize(),(int)ais.getFormat().getSampleRate());
  }
  for (int position=0; position < length; ) {
    byte[] frame=new byte[ais.getFormat().getFrameSize()];
    ais.read(frame);
    this.byteArrayToFrame(frame,ret[currentChannel],position,ais.getFormat().isBigEndian());
    currentChannel=(currentChannel + 1) % channels;
    if (currentChannel == 0) {
      position++;
    }
  }
  this.notifyAll("String_Node_Str");
  return ret;
}
Program: 81458
Project: 81458
Buggy source:
private Sound[] fromAudioInputStream(AudioInputStream ais) throws IOException {
  this.notifyAll("String_Node_Str");
  int channels=ais.getFormat().getChannels();
  int currentChannel=0;
  Sound[] ret=new Sound[channels];
  int length=(int)(ais.getFrameLength() / ais.getFormat().getFrameSize());
  for (int channel=0; channel < channels; channel++) {
    ret[channel]=new Sound(new double[length],ais.getFormat().getFrameSize());
  }
  for (int position=0; position < length; ) {
    byte[] frame=new byte[ais.getFormat().getFrameSize()];
    ais.read(frame);
    this.byteArrayToFrame(frame,ret[currentChannel],position,ais.getFormat().isBigEndian());
    currentChannel=(currentChannel + 1) % channels;
    if (currentChannel == 0) {
      position++;
    }
  }
  this.notifyAll("String_Node_Str");
  return ret;
}

Fixed version (ground truth):
private Sound[] fromAudioInputStream(AudioInputStream ais) throws IOException {
  this.notifyAll("String_Node_Str");
  int channels=ais.getFormat().getChannels();
  int currentChannel=0;
  Sound[] ret=new Sound[channels];
  int length=(int)ais.getFrameLength();
  for (int channel=0; channel < channels; channel++) {
    ret[channel]=new Sound(new double[length],ais.getFormat().getFrameSize());
  }
  for (int position=0; position < length; ) {
    byte[] frame=new byte[ais.getFormat().getFrameSize()];
    ais.read(frame);
    this.byteArrayToFrame(frame,ret[currentChannel],position,ais.getFormat().isBigEndian());
    currentChannel=(currentChannel + 1) % channels;
    if (currentChannel == 0) {
      position++;
    }
  }
  this.notifyAll("String_Node_Str");
  return ret;
}
Program: 81459
Project: 81459
Buggy source:
private AudioInputStream toStream(Sound[] channels,AudioFormat audioFormat){
  byte[] data=new byte[audioFormat.getFrameSize() * channels.length * channels[0].getSamples().length];
  for (int i=0; i < data.length; i++) {
    int currentFrameByte=i % audioFormat.getFrameSize();
    int currentChannel=(i / audioFormat.getFrameSize()) % channels.length;
    int currentFrame=i / (audioFormat.getFrameSize() * channels.length);
    if (!audioFormat.isBigEndian()) {
      data[i]=(byte)((int)(channels[currentChannel].getSamples()[currentFrame]) >> (8 * currentFrameByte));
    }
 else {
      data[i]=(byte)((int)(channels[currentChannel].getSamples()[currentFrame]) >> (8 * (audioFormat.getFrameSize() - 1 - currentFrameByte)));
    }
  }
  this.notifyAll("String_Node_Str");
  ByteArrayInputStream bais=new ByteArrayInputStream(data);
  return new AudioInputStream(bais,audioFormat,2 * channels.length * channels[0].getSamples().length);
}

Fixed version (ground truth):
private AudioInputStream toStream(Sound[] channels,AudioFormat audioFormat){
  int length=audioFormat.getFrameSize() * channels[0].getSamples().length;
  byte[] data=new byte[length];
  for (int i=0; i < data.length; i++) {
    int currentFrameByte=i % audioFormat.getFrameSize();
    int currentChannel=(i / audioFormat.getFrameSize()) % channels.length;
    int currentFrame=i / (audioFormat.getFrameSize() * channels.length);
    if (!audioFormat.isBigEndian()) {
      data[i]=(byte)((int)(channels[currentChannel].getSamples()[currentFrame]) >> (8 * currentFrameByte));
    }
 else {
      data[i]=(byte)((int)(channels[currentChannel].getSamples()[currentFrame]) >> (8 * (audioFormat.getFrameSize() - 1 - currentFrameByte)));
    }
  }
  this.notifyAll("String_Node_Str");
  ByteArrayInputStream bais=new ByteArrayInputStream(data);
  return new AudioInputStream(bais,audioFormat,channels[0].getSamples().length);
}
Program: 81460
Project: 81460
Buggy source:
private static Sound noop(Sound sound){
  double[] data=sound.getSamples();
  return new Sound(data,sound.getNbBytesPerFrame(),sound.getFreq());
}

Fixed version (ground truth):
private static Sound noop(Sound sound){
  double[] data=sound.getSamples();
  double[] newdata=new double[data.length];
  for (int i=0; i < data.length; i++) {
    newdata[i]=data[i];
  }
  return new Sound(newdata,sound.getNbBytesPerFrame(),sound.getFreq());
}
Program: 81461
Project: 81461
Buggy source:
private static Sound normalize(Sound sound){
  double[] data=sound.getSamples();
  double[] newdata=new double[sound.getSamples().length];
  double max=0;
  for (int i=0; i < data.length; i++) {
    if (Math.abs(data[i]) > max)     max=Math.abs(data[i]);
  }
  double maxValue=Math.pow(256,sound.getNbBytesPerFrame() - 1) / 2;
  System.out.println(max);
  System.out.println(maxValue);
  for (int i=0; i < data.length; i++) {
    double underOne=data[i] / max;
    double rescaled=underOne * maxValue;
    newdata[i]=rescaled;
  }
  return new Sound(newdata,sound.getNbBytesPerFrame(),sound.getFreq());
}

Fixed version (ground truth):
private static Sound normalize(Sound sound){
  double[] data=sound.getSamples();
  double[] newdata=new double[sound.getSamples().length];
  double max=0;
  for (int i=0; i < data.length; i++) {
    if (Math.abs(data[i]) > max)     max=Math.abs(data[i]);
  }
  double maxValue=Math.pow(256,sound.getNbBytesPerFrame() - 1) / 2;
  for (int i=0; i < data.length; i++) {
    double underOne=data[i] / max;
    double rescaled=underOne * maxValue;
    newdata[i]=Math.floor(rescaled);
  }
  return new Sound(newdata,sound.getNbBytesPerFrame(),sound.getFreq());
}
Program: 81462
Project: 81462
Buggy source:
public static void main(String[] args){
  try {
    File fParam=new File(args[0]);
    File fOrigin=new File("String_Node_Str");
    File fDest=new File("String_Node_Str");
    TestTransformMain.copyFile(fParam,fOrigin);
    new TransformSound(new PrintlnTransformObserver()).transformWav(fOrigin,fDest,new EqualizerSoundTransformation(new double[]{0,10000,22050},new double[]{1,1,1}),new EightBitsSoundTransformation(25));
  }
 catch (  FileNotFoundException e) {
    e.printStackTrace();
  }
catch (  UnsupportedAudioFileException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
public static void main(String[] args){
  try {
    File fParam=new File(args[0]);
    File fOrigin=new File("String_Node_Str");
    File fDest=new File("String_Node_Str");
    TestTransformMain.copyFile(fParam,fOrigin);
    new TransformSound(new PrintlnTransformObserver()).transformWav(fOrigin,fDest,new EightBitsSoundTransformation(25));
  }
 catch (  FileNotFoundException e) {
    e.printStackTrace();
  }
catch (  UnsupportedAudioFileException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
}
Program: 81463
Project: 81463
Buggy source:
private AudioInputStream toStream(Sound[] channels,AudioFormat audioFormat){
  int length=channels.length * audioFormat.getFrameSize() * channels[0].getSamples().length;
  byte[] data=new byte[length];
  for (int i=0; i < data.length; i++) {
    int currentFrameByte=i % audioFormat.getFrameSize();
    int currentChannel=(i / audioFormat.getFrameSize()) % channels.length;
    int currentFrame=i / (audioFormat.getFrameSize() * channels.length);
    if (audioFormat.isBigEndian()) {
      data[i]=(byte)((int)(channels[currentChannel].getSamples()[currentFrame]) >> (8 * currentFrameByte));
    }
 else {
      data[i]=(byte)((int)(channels[currentChannel].getSamples()[currentFrame]) >> (8 * (audioFormat.getFrameSize() - 1 - currentFrameByte)));
    }
  }
  this.notifyAll("String_Node_Str");
  ByteArrayInputStream bais=new ByteArrayInputStream(data);
  return new AudioInputStream(bais,audioFormat,channels[0].getSamples().length * channels.length);
}

Fixed version (ground truth):
private AudioInputStream toStream(Sound[] channels,AudioFormat audioFormat){
  int length=channels.length * audioFormat.getFrameSize() * channels[0].getSamples().length;
  byte[] data=new byte[length];
  for (int i=0; i < data.length; i++) {
    int currentFrameByte=i % audioFormat.getFrameSize();
    int currentChannel=(i / audioFormat.getFrameSize()) % channels.length;
    int currentFrame=i / (audioFormat.getFrameSize() * channels.length);
    if (audioFormat.isBigEndian()) {
      data[i]=(byte)((int)(channels[currentChannel].getSamples()[currentFrame]) >> (8 * currentFrameByte));
    }
 else {
      data[i]=(byte)((int)(channels[currentChannel].getSamples()[currentFrame]) >> (8 * (audioFormat.getFrameSize() - 1 - currentFrameByte)));
    }
  }
  this.notifyAll("String_Node_Str");
  ByteArrayInputStream bais=new ByteArrayInputStream(data);
  return new AudioInputStream(bais,audioFormat,length / audioFormat.getFrameSize());
}
Program: 81464
Project: 81464
Buggy source:
@Override public Sound transform(Sound input){
  SimpleRegression reg=new SimpleRegression();
  for (int i=0; i < input.getSamples().length; i+=step) {
    reg.addData(i,input.getSamples()[i]);
  }
  reg.regress();
  Sound outputSound=new Sound(new double[input.getSamples().length],input.getNbBytesPerFrame());
  for (int i=0; i < input.getSamples().length; i+=step) {
    outputSound.getSamples()[i]=reg.predict(i);
  }
  return outputSound;
}

Fixed version (ground truth):
@Override public Sound transform(Sound input){
  SplineInterpolator reg=new SplineInterpolator();
  double[] x=new double[input.getSamples().length / step + 1];
  double[] y=new double[input.getSamples().length / step + 1];
  for (int i=0; i < input.getSamples().length; i+=step) {
    x[i / step]=i;
    y[i / step]=input.getSamples()[i];
  }
  PolynomialSplineFunction psf=reg.interpolate(x,y);
  Sound outputSound=new Sound(new double[input.getSamples().length],input.getNbBytesPerFrame());
  for (int i=0; i < input.getSamples().length; i+=step) {
    outputSound.getSamples()[i]=psf.value(i);
  }
  return outputSound;
}
Program: 81465
Project: 81465
Buggy source:
private static Sound normalize(Sound sound){
  double[] data=sound.getSamples();
  double[] newdata=new double[sound.getSamples().length];
  double max=0;
  for (int i=0; i < data.length; i++) {
    if (Math.abs(data[i]) > max)     max=Math.abs(data[i]);
  }
  double maxValue=Math.pow(256,sound.getNbBytesPerFrame());
  for (int i=0; i < data.length; i++) {
    newdata[i]=Math.round(maxValue * (data[i]) / max);
  }
  return new Sound(newdata,sound.getNbBytesPerFrame());
}

Fixed version (ground truth):
private static Sound normalize(Sound sound){
  double[] data=sound.getSamples();
  double[] newdata=new double[sound.getSamples().length];
  double max=0;
  for (int i=0; i < data.length; i++) {
    if (Math.abs(data[i]) > max)     max=Math.abs(data[i]);
  }
  double maxValue=Math.pow(256,sound.getNbBytesPerFrame() - 1) / 2;
  System.out.println(max);
  System.out.println(maxValue);
  for (int i=0; i < data.length; i++) {
    double underOne=data[i] / max;
    double rescaled=underOne * maxValue;
    newdata[i]=rescaled;
  }
  return new Sound(newdata,sound.getNbBytesPerFrame());
}
Program: 81466
Project: 81466
Buggy source:
public static void main(String[] args){
  try {
    File fParam=new File(args[0]);
    File fOrigin=new File("String_Node_Str");
    File fDest=new File("String_Node_Str");
    TestTransformMain.copyFile(fParam,fOrigin);
    new TransformSound(new PrintlnTransformObserver()).transformWav(fOrigin,fDest,new ReverseSoundTransformation());
  }
 catch (  FileNotFoundException e) {
    e.printStackTrace();
  }
catch (  UnsupportedAudioFileException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
public static void main(String[] args){
  try {
    File fParam=new File(args[0]);
    File fOrigin=new File("String_Node_Str");
    File fDest=new File("String_Node_Str");
    TestTransformMain.copyFile(fParam,fOrigin);
    new TransformSound(new PrintlnTransformObserver()).transformWav(fOrigin,fDest,new LinearRegressionSoundTransformation(5));
  }
 catch (  FileNotFoundException e) {
    e.printStackTrace();
  }
catch (  UnsupportedAudioFileException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
}
Program: 81467
Project: 81467
Buggy source:
public static void main(String[] args){
  try {
    File fParam=new File(args[0]);
    File fOrigin=new File("String_Node_Str");
    File fDest=new File("String_Node_Str");
    TestTransformMain.copyFile(fParam,fOrigin);
    new TransformSound(new PrintlnTransformObserver()).transformWav(fOrigin,fDest,new LinearRegressionSoundTransformation(20));
  }
 catch (  FileNotFoundException e) {
    e.printStackTrace();
  }
catch (  UnsupportedAudioFileException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
public static void main(String[] args){
  try {
    File fParam=new File(args[0]);
    File fOrigin=new File("String_Node_Str");
    File fDest=new File("String_Node_Str");
    TestTransformMain.copyFile(fParam,fOrigin);
    new TransformSound(new PrintlnTransformObserver()).transformWav(fOrigin,fDest,new PrecisionFilterSoundTransformation(115));
  }
 catch (  FileNotFoundException e) {
    e.printStackTrace();
  }
catch (  UnsupportedAudioFileException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
}
Program: 81468
Project: 81468
Buggy source:
@Override public Sound transform(Sound input){
  SplineInterpolator reg=new SplineInterpolator();
  double[] x=new double[input.getSamples().length / step + 1];
  double[] y=new double[input.getSamples().length / step + 1];
  for (int i=0; i < input.getSamples().length; i+=step) {
    x[i / step]=i;
    y[i / step]=input.getSamples()[i];
  }
  PolynomialSplineFunction psf=reg.interpolate(x,y);
  Sound outputSound=new Sound(new double[input.getSamples().length],input.getNbBytesPerFrame());
  for (int i=0; i < input.getSamples().length; i+=step) {
    outputSound.getSamples()[i]=psf.value(i);
  }
  return outputSound;
}

Fixed version (ground truth):
@Override public Sound transform(Sound input){
  SplineInterpolator reg=new SplineInterpolator();
  double[] x=new double[input.getSamples().length / step];
  double[] y=new double[input.getSamples().length / step];
  for (int i=0; i < input.getSamples().length; i+=step) {
    if (i / step < x.length) {
      x[i / step]=i;
      y[i / step]=input.getSamples()[i];
    }
  }
  PolynomialSplineFunction psf=reg.interpolate(x,y);
  Sound outputSound=new Sound(new double[input.getSamples().length],input.getNbBytesPerFrame());
  for (int i=0; i < input.getSamples().length; i+=step) {
    outputSound.getSamples()[i]=psf.value(i);
  }
  return outputSound;
}
Program: 81469
Project: 81469
Buggy source:
public static void main(String[] args){
  try {
    File fParam=new File(args[0]);
    File fOrigin=new File("String_Node_Str");
    File fDest=new File("String_Node_Str");
    TestTransformMain.copyFile(fParam,fOrigin);
    new TransformSound(new PrintlnTransformObserver()).transformWav(fOrigin,fDest,new LinearRegressionSoundTransformation(5));
  }
 catch (  FileNotFoundException e) {
    e.printStackTrace();
  }
catch (  UnsupportedAudioFileException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
public static void main(String[] args){
  try {
    File fParam=new File(args[0]);
    File fOrigin=new File("String_Node_Str");
    File fDest=new File("String_Node_Str");
    TestTransformMain.copyFile(fParam,fOrigin);
    new TransformSound(new PrintlnTransformObserver()).transformWav(fOrigin,fDest,new LinearRegressionSoundTransformation(1));
  }
 catch (  FileNotFoundException e) {
    e.printStackTrace();
  }
catch (  UnsupportedAudioFileException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
}
Program: 81470
Project: 81470
Buggy source:
public void addSheetReader(XLSSheetReader reader){
  addSheetReader(reader.getSheetName(),reader);
  addSheetReader(new Integer(reader.getSheetIdx()),reader);
}

Fixed version (ground truth):
public void addSheetReader(XLSSheetReader reader){
  addSheetReader(reader.getSheetName(),reader);
  if (reader.getSheetIdx() >= 0) {
    addSheetReader(new Integer(reader.getSheetIdx()),reader);
  }
}
Program: 81471
Project: 81471
Buggy source:
public static void clearCache(){
  if (cache.get() != null) {
    cache.get().clear();
  }
}

Fixed version (ground truth):
public static void clearCache(){
  cache.remove();
}
Program: 81472
Project: 81472
Buggy source:
public static void clearCache(){
  if (cache.get() != null) {
    cache.get().clear();
  }
}

Fixed version (ground truth):
public static void clearCache(){
  cache.remove();
}
Program: 81473
Project: 81473
Buggy source:
private FormulaPartInfo(final List parts,final FormulaPart parentFormula){
  this.parts=new LinkedList();
  for (int i=0, c=parts.size(); i < c; i++) {
    Object part=parts.get(i);
    if (part instanceof String) {
      this.parts.add(part);
    }
 else     if (part instanceof CellRef) {
      this.parts.add(new CellRef((CellRef)part,parentFormula));
    }
  }
}

Fixed version (ground truth):
private FormulaPartInfo(final List parts,final FormulaPart parentFormula){
  this.defaultValue=parentFormula.defaultValue;
  this.parts=new LinkedList();
  for (int i=0, c=parts.size(); i < c; i++) {
    Object part=parts.get(i);
    if (part instanceof String) {
      this.parts.add(part);
    }
 else     if (part instanceof CellRef) {
      this.parts.add(new CellRef((CellRef)part,parentFormula));
    }
  }
}
Program: 81476
Project: 81476
Buggy source:
private void parseFormula(){
  final String poiCellValue=cell.getPoiCellValue();
  int i=poiCellValue.lastIndexOf(configuration.getEndFormulaToken());
  String expr=poiCellValue.substring(2,i);
  cell.setFormula(new Formula(expr));
  cell.getFormula().setRowNum(cell.getRow().getPoiRow().getRowNum());
  cell.getFormula().setCellNum(cell.getPoiCell().getColumnIndex());
  if (i + 1 < poiCellValue.length()) {
    String tail=poiCellValue.substring(i + 1);
    int j=tail.indexOf(configuration.getMetaInfoToken());
    if (j >= 0) {
      cell.setMetaInfo(tail.substring(j));
      if (j > 0) {
        cell.setLabel(tail.substring(0,j));
      }
      cell.setCollectionName(tail.substring(j + 2));
    }
 else {
      cell.setLabel(tail);
    }
  }
  cell.setStringCellValue(poiCellValue.substring(0,i + 1));
}

Fixed version (ground truth):
private void parseFormula(){
  final String poiCellValue=cell.getPoiCellValue();
  int i=poiCellValue.lastIndexOf(configuration.getEndFormulaToken());
  String expr=poiCellValue.substring(2,i);
  cell.setFormula(new Formula(expr,cell.getRow().getSheet()));
  cell.getFormula().setRowNum(cell.getRow().getPoiRow().getRowNum());
  cell.getFormula().setCellNum(cell.getPoiCell().getColumnIndex());
  if (i + 1 < poiCellValue.length()) {
    String tail=poiCellValue.substring(i + 1);
    int j=tail.indexOf(configuration.getMetaInfoToken());
    if (j >= 0) {
      cell.setMetaInfo(tail.substring(j));
      if (j > 0) {
        cell.setLabel(tail.substring(0,j));
      }
      cell.setCollectionName(tail.substring(j + 2));
    }
 else {
      cell.setLabel(tail);
    }
  }
  cell.setStringCellValue(poiCellValue.substring(0,i + 1));
}
Program: 81477
Project: 81477
Buggy source:
public void testFindRefCells(){
  String formulaValue="String_Node_Str";
  Formula formula=new Formula(formulaValue);
  Set refCells=formula.findRefCells();
  assertEquals("String_Node_Str",refCells.size(),7);
  assertTrue(contains(refCells,"String_Node_Str"));
  assertTrue(contains(refCells,"String_Node_Str"));
  assertTrue(contains(refCells,"String_Node_Str"));
  assertTrue(contains(refCells,"String_Node_Str"));
  assertTrue(contains(refCells,"String_Node_Str"));
  assertTrue(contains(refCells,"String_Node_Str"));
  assertTrue(contains(refCells,"String_Node_Str"));
}

Fixed version (ground truth):
public void testFindRefCells(){
  String formulaValue="String_Node_Str";
  Formula formula=new Formula(formulaValue,null);
  Set refCells=formula.findRefCells();
  assertEquals("String_Node_Str",refCells.size(),7);
  assertTrue(contains(refCells,"String_Node_Str"));
  assertTrue(contains(refCells,"String_Node_Str"));
  assertTrue(contains(refCells,"String_Node_Str"));
  assertTrue(contains(refCells,"String_Node_Str"));
  assertTrue(contains(refCells,"String_Node_Str"));
  assertTrue(contains(refCells,"String_Node_Str"));
  assertTrue(contains(refCells,"String_Node_Str"));
}