Program: 107632
Project: 107632
Buggy source:
@Override protected boolean runOnceInPlayThread(){
  InputStream audioStream=null;
  try {
    audioStream=audioSystem.getAudioInputStream(uri);
  }
 catch (  IOException ioex) {
    logger.error("String_Node_Str" + uri,ioex);
  }
  if (audioStream == null)   return false;
  Codec resampler=null;
  try {
    Format rendererFormat=audioSystem.getFormat(audioStream);
    if (rendererFormat == null)     return false;
    Format resamplerFormat=null;
    if (renderer.setInputFormat(rendererFormat) == null) {
      resampler=new SpeexResampler();
      resamplerFormat=rendererFormat;
      resampler.setInputFormat(resamplerFormat);
      Format[] supportedResamplerFormats=resampler.getSupportedOutputFormats(resamplerFormat);
      for (      Format supportedRendererFormat : renderer.getSupportedInputFormats()) {
        for (        Format supportedResamplerFormat : supportedResamplerFormats) {
          if (supportedRendererFormat.matches(supportedResamplerFormat)) {
            rendererFormat=supportedRendererFormat;
            resampler.setOutputFormat(rendererFormat);
            renderer.setInputFormat(rendererFormat);
            break;
          }
        }
      }
    }
    Buffer rendererBuffer=buffer;
    Buffer resamplerBuffer;
    rendererBuffer.setFormat(rendererFormat);
    if (resampler == null)     resamplerBuffer=null;
 else {
      resamplerBuffer=new Buffer();
      int bufferDataLength=DEFAULT_BUFFER_DATA_LENGTH;
      if (resamplerFormat instanceof AudioFormat) {
        AudioFormat af=(AudioFormat)resamplerFormat;
        int frameSize=af.getSampleSizeInBits() / 8 * af.getChannels();
        bufferDataLength=bufferDataLength / frameSize * frameSize;
      }
      bufferData=new byte[bufferDataLength];
      resamplerBuffer.setData(bufferData);
      resamplerBuffer.setFormat(resamplerFormat);
      resampler.open();
    }
    try {
      renderer.open();
      renderer.start();
      int bufferLength;
      while (isStarted() && ((bufferLength=audioStream.read(bufferData)) != -1)) {
        if (resampler == null) {
          rendererBuffer.setLength(bufferLength);
          rendererBuffer.setOffset(0);
        }
 else {
          resamplerBuffer.setLength(bufferLength);
          resamplerBuffer.setOffset(0);
          rendererBuffer.setLength(0);
          rendererBuffer.setOffset(0);
          resampler.process(resamplerBuffer,rendererBuffer);
        }
        while ((renderer.process(rendererBuffer) & Renderer.INPUT_BUFFER_NOT_CONSUMED) == Renderer.INPUT_BUFFER_NOT_CONSUMED)         ;
      }
    }
 catch (    IOException ioex) {
      logger.error("String_Node_Str" + uri,ioex);
      return false;
    }
catch (    ResourceUnavailableException ruex) {
      logger.error("String_Node_Str" + renderer.getClass().getName(),ruex);
      return false;
    }
  }
 catch (  ResourceUnavailableException ruex) {
    if (resampler != null) {
      logger.error("String_Node_Str" + resampler.getClass().getName(),ruex);
      return false;
    }
  }
 finally {
    try {
      audioStream.close();
    }
 catch (    IOException ioex) {
    }
    if (resampler != null)     resampler.close();
  }
  return true;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
protected boolean runOnceInPlayThread(){
  InputStream audioStream=null;
  try {
    audioStream=audioSystem.getAudioInputStream(uri);
  }
 catch (  IOException ioex) {
    logger.error("String_Node_Str" + uri,ioex);
  }
  if (audioStream == null)   return false;
  Codec resampler=null;
  boolean success=true;
  AudioFormat audioStreamFormat=null;
  int audioStreamLength=0;
  long rendererProcessStartTime=0;
  try {
    Format rendererFormat=audioStreamFormat=audioSystem.getFormat(audioStream);
    if (rendererFormat == null)     return false;
    Format resamplerFormat=null;
    if (renderer.setInputFormat(rendererFormat) == null) {
      resampler=new SpeexResampler();
      resamplerFormat=rendererFormat;
      resampler.setInputFormat(resamplerFormat);
      Format[] supportedResamplerFormats=resampler.getSupportedOutputFormats(resamplerFormat);
      for (      Format supportedRendererFormat : renderer.getSupportedInputFormats()) {
        for (        Format supportedResamplerFormat : supportedResamplerFormats) {
          if (supportedRendererFormat.matches(supportedResamplerFormat)) {
            rendererFormat=supportedRendererFormat;
            resampler.setOutputFormat(rendererFormat);
            renderer.setInputFormat(rendererFormat);
            break;
          }
        }
      }
    }
    Buffer rendererBuffer=buffer;
    Buffer resamplerBuffer;
    rendererBuffer.setFormat(rendererFormat);
    if (resampler == null)     resamplerBuffer=null;
 else {
      resamplerBuffer=new Buffer();
      int bufferDataLength=DEFAULT_BUFFER_DATA_LENGTH;
      if (resamplerFormat instanceof AudioFormat) {
        AudioFormat af=(AudioFormat)resamplerFormat;
        int frameSize=af.getSampleSizeInBits() / 8 * af.getChannels();
        bufferDataLength=bufferDataLength / frameSize * frameSize;
      }
      bufferData=new byte[bufferDataLength];
      resamplerBuffer.setData(bufferData);
      resamplerBuffer.setFormat(resamplerFormat);
      resampler.open();
    }
    try {
      renderer.open();
      renderer.start();
      int bufferLength;
      while (isStarted() && ((bufferLength=audioStream.read(bufferData)) != -1)) {
        audioStreamLength+=bufferLength;
        if (resampler == null) {
          rendererBuffer.setLength(bufferLength);
          rendererBuffer.setOffset(0);
        }
 else {
          resamplerBuffer.setLength(bufferLength);
          resamplerBuffer.setOffset(0);
          rendererBuffer.setLength(0);
          rendererBuffer.setOffset(0);
          resampler.process(resamplerBuffer,rendererBuffer);
        }
        int rendererProcess;
        if (rendererProcessStartTime == 0)         rendererProcessStartTime=System.currentTimeMillis();
        do {
          rendererProcess=renderer.process(rendererBuffer);
          if (rendererProcess == Renderer.BUFFER_PROCESSED_FAILED) {
            logger.error("String_Node_Str" + uri);
            success=false;
            break;
          }
        }
 while ((rendererProcess & Renderer.INPUT_BUFFER_NOT_CONSUMED) == Renderer.INPUT_BUFFER_NOT_CONSUMED);
      }
    }
 catch (    IOException ioex) {
      logger.error("String_Node_Str" + uri,ioex);
      success=false;
    }
catch (    ResourceUnavailableException ruex) {
      logger.error("String_Node_Str" + renderer.getClass().getName(),ruex);
      success=false;
    }
  }
 catch (  ResourceUnavailableException ruex) {
    if (resampler != null) {
      logger.error("String_Node_Str" + resampler.getClass().getName(),ruex);
      success=false;
    }
  }
 finally {
    try {
      audioStream.close();
    }
 catch (    IOException ioex) {
    }
    if (resampler != null)     resampler.close();
    if (success && (audioStreamFormat != null) && (audioStreamLength > 0)&& (rendererProcessStartTime > 0)&& isStarted()) {
      long audioStreamDuration=(audioStreamFormat.computeDuration(audioStreamLength) + 999999) / 1000000;
      if (audioStreamDuration > 0) {
        audioStreamDuration+=MIN_AUDIO_STREAM_DURATION;
        boolean interrupted=false;
synchronized (sync) {
          while (isStarted()) {
            long timeout=System.currentTimeMillis() - rendererProcessStartTime;
            if ((timeout >= audioStreamDuration) || (timeout <= 0)) {
              break;
            }
 else {
              try {
                sync.wait(timeout);
              }
 catch (              InterruptedException ie) {
                interrupted=true;
              }
            }
          }
        }
        if (interrupted)         Thread.currentThread().interrupt();
      }
    }
  }
  return success;
}