nus-yam/ex-repair huggingface dataset:
Program: 56147
Project: 56147
Buggy source:
@Override public KeyValuePair<K,V> deserialize(DataInput in){
  try {
    KeyValuePair<K,V> pair=getInstance();
    pair.read(in);
    return pair;
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
@Override public KeyValuePair<K,V> deserialize(DataInput in){
  try {
    KeyValuePair<K,V> pair=getInstance();
    pair.read(in);
    return pair;
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
}
Program: 56148
Project: 56148
Buggy source:
@Override public boolean next(){
  if (!iterator1.nextKey() || !iterator2.nextKey()) {
    return false;
  }
  K key1=iterator1.getKey();
  K key2=iterator2.getKey();
  while (key1.compareTo(key2) != 0) {
    if (key1.compareTo(key2) > 0) {
      if (!iterator2.nextKey()) {
        return false;
      }
      key2=iterator2.getKey();
    }
 else     if (key1.compareTo(key2) < 0) {
      if (!iterator1.nextKey()) {
        return false;
      }
      key1=iterator1.getKey();
    }
  }
  key=key1;
  return true;
}

Fixed version (ground truth):
@Override public V next(){
  return next.getValue();
}
Program: 56149
Project: 56149
Buggy source:
@Override public K getKey(){
  return key;
}

Fixed version (ground truth):
public K getKey(){
  return next.getKey();
}
Program: 56150
Project: 56150
Buggy source:
@Override public void open() throws IOException, MemoryAllocationException {
  final Comparator<K> keyComparator=new Comparator<K>(){
    @Override public int compare(    K k1,    K k2){
      return k1.compareTo(k2);
    }
  }
;
{
    final SerializationFactory<K> keySerialization=new WritableSerializationFactory<K>(keyClass);
    final SerializationFactory<V1> valSerialization=new WritableSerializationFactory<V1>(valueClass1);
    this.sortMerger1=new UnilateralSortMerger<K,V1>(memoryManager,ioManager,numSortBufferPerChannel,sizeSortBufferPerChannel,ioMemoryPerChannel,fileHandlesPerChannel,keySerialization,valSerialization,keyComparator,reader1,parentTask);
  }
{
    final SerializationFactory<K> keySerialization=new WritableSerializationFactory<K>(keyClass);
    final SerializationFactory<V2> valSerialization=new WritableSerializationFactory<V2>(valueClass2);
    this.sortMerger2=new UnilateralSortMerger<K,V2>(memoryManager,ioManager,numSortBufferPerChannel,sizeSortBufferPerChannel,ioMemoryPerChannel,fileHandlesPerChannel,keySerialization,valSerialization,keyComparator,reader2,parentTask);
  }
  this.iterator1=new KeyGroupedIterator<K,V1>(sortMerger1.getIterator());
  this.iterator2=new KeyGroupedIterator<K,V2>(sortMerger2.getIterator());
}

Fixed version (ground truth):
@Override public void open() throws IOException, MemoryAllocationException {
  final Comparator<K> keyComparator=new Comparator<K>(){
    @Override public int compare(    K k1,    K k2){
      return k1.compareTo(k2);
    }
  }
;
{
    final SerializationFactory<K> keySerialization=new WritableSerializationFactory<K>(keyClass);
    final SerializationFactory<V1> valSerialization=new WritableSerializationFactory<V1>(valueClass1);
    this.sortMerger1=new UnilateralSortMerger<K,V1>(memoryManager,ioManager,numSortBufferPerChannel,sizeSortBufferPerChannel,ioMemoryPerChannel,fileHandlesPerChannel,keySerialization,valSerialization,keyComparator,reader1,parentTask);
  }
{
    final SerializationFactory<K> keySerialization=new WritableSerializationFactory<K>(keyClass);
    final SerializationFactory<V2> valSerialization=new WritableSerializationFactory<V2>(valueClass2);
    this.sortMerger2=new UnilateralSortMerger<K,V2>(memoryManager,ioManager,numSortBufferPerChannel,sizeSortBufferPerChannel,ioMemoryPerChannel,fileHandlesPerChannel,keySerialization,valSerialization,keyComparator,reader2,parentTask);
  }
  this.iterator1=new KeyValueIterator<V1>(sortMerger1.getIterator());
  this.iterator2=new KeyValueIterator<V2>(sortMerger2.getIterator());
}
Program: 56151
Project: 56151
Buggy source:
/** 
 * This method is periodically called by the framework to check the state of the task threads. If any task thread has unexpectedly switch to TERMINATED, this indicates that an   {@link Error} has occurredduring its execution.
 */
private void checkTaskExecution(){
synchronized (this.runningTasks) {
    final Iterator<ExecutionVertexID> it=this.runningTasks.keySet().iterator();
    while (it.hasNext()) {
      final ExecutionVertexID executionVertexID=it.next();
      final Environment environment=this.runningTasks.get(executionVertexID);
      if (environment.getExecutingThread().getState() == Thread.State.TERMINATED) {
        it.remove();
        environment.changeExecutionState(ExecutionState.FAILED,"String_Node_Str");
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * This method is periodically called by the framework to check the state of the task threads. If any task thread has unexpectedly switch to TERMINATED, this indicates that an   {@link Error} has occurredduring its execution.
 */
private void checkTaskExecution(){
  final List<Environment> crashEnvironments=new LinkedList<Environment>();
synchronized (this.runningTasks) {
    final Iterator<ExecutionVertexID> it=this.runningTasks.keySet().iterator();
    while (it.hasNext()) {
      final ExecutionVertexID executionVertexID=it.next();
      final Environment environment=this.runningTasks.get(executionVertexID);
      if (environment.getExecutingThread().getState() == Thread.State.TERMINATED) {
        it.remove();
        crashEnvironments.add(environment);
      }
    }
  }
  final Iterator<Environment> it2=crashEnvironments.iterator();
  while (it2.hasNext()) {
    it2.next().changeExecutionState(ExecutionState.FAILED,"String_Node_Str");
  }
}
Program: 56152
Project: 56152
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public TaskCancelResult cancelTask(ExecutionVertexID id) throws IOException {
  Environment tmpEnvironment;
synchronized (this.runningTasks) {
    tmpEnvironment=this.runningTasks.get(id);
    if (tmpEnvironment == null) {
      final TaskCancelResult taskCancelResult=new TaskCancelResult(id,AbstractTaskResult.ReturnCode.ERROR);
      taskCancelResult.setDescription("String_Node_Str" + id + "String_Node_Str");
      return taskCancelResult;
    }
  }
  final Environment environment=tmpEnvironment;
  Thread tmpThread=new Thread(new Runnable(){
    @Override public void run(){
      environment.cancelExecution();
    }
  }
);
  tmpThread.start();
  return new TaskCancelResult(id,AbstractTaskResult.ReturnCode.SUCCESS);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public TaskCancelResult cancelTask(ExecutionVertexID id) throws IOException {
  Environment tmpEnvironment;
synchronized (this.runningTasks) {
    tmpEnvironment=this.runningTasks.get(id);
    if (tmpEnvironment == null) {
      final TaskCancelResult taskCancelResult=new TaskCancelResult(id,AbstractTaskResult.ReturnCode.ERROR);
      taskCancelResult.setDescription("String_Node_Str" + id + "String_Node_Str");
      return taskCancelResult;
    }
  }
  final Environment environment=tmpEnvironment;
  final Thread tmpThread=new Thread(new Runnable(){
    @Override public void run(){
      environment.cancelExecution();
    }
  }
);
  tmpThread.start();
  return new TaskCancelResult(id,AbstractTaskResult.ReturnCode.SUCCESS);
}
Program: 56154
Project: 56154
Buggy source:
/** 
 * Creates a new channel to the path indicated by the given ID. The channel hands IO requests to the given request queue to be processed.
 * @param channelID The id describing the path of the file that the channel accessed.
 * @param requestQueue The queue that this channel hands its IO requests to.
 */
protected ChannelAccess(Channel.ID channelID,RequestQueue<IORequest<T>> requestQueue,Collection<T> buffers) throws IOException {
  if (channelID == null || requestQueue == null) {
    throw new NullPointerException();
  }
  this.id=channelID;
  this.numBuffers=buffers.size();
  this.requestQueue=requestQueue;
  this.returnBuffers=new ArrayBlockingQueue<T>(buffers.size(),false);
  try {
    RandomAccessFile file=new RandomAccessFile(id.getPath(),"String_Node_Str");
    this.fileChannel=file.getChannel();
  }
 catch (  IOException e) {
    throw new IOException("String_Node_Str" + channelID.getPath() + "String_Node_Str",e);
  }
}

Fixed version (ground truth):
/** 
 * Creates a new channel to the path indicated by the given ID. The channel hands IO requests to the given request queue to be processed.
 * @param channelID The id describing the path of the file that the channel accessed.
 * @param requestQueue The queue that this channel hands its IO requests to.
 */
protected ChannelAccess(Channel.ID channelID,RequestQueue<IORequest<T>> requestQueue,Collection<T> buffers) throws IOException {
  if (channelID == null || requestQueue == null || buffers == null) {
    throw new IllegalArgumentException();
  }
  if (buffers.isEmpty()) {
    throw new IllegalArgumentException();
  }
  this.id=channelID;
  this.numBuffers=buffers.size();
  this.requestQueue=requestQueue;
  this.returnBuffers=new ArrayBlockingQueue<T>(buffers.size(),false);
  try {
    RandomAccessFile file=new RandomAccessFile(id.getPath(),"String_Node_Str");
    this.fileChannel=file.getChannel();
  }
 catch (  IOException e) {
    throw new IOException("String_Node_Str" + channelID.getPath() + "String_Node_Str",e);
  }
}
Program: 56155
Project: 56155
Buggy source:
/** 
 * @param channelID
 * @param requestQueue
 * @param buffers
 * @param deleteWhenDone
 * @throws IOException
 */
public ChannelReader(Channel.ID channelID,RequestQueue<IORequest<Buffer.Input>> requestQueue,Collection<Buffer.Input> buffers,boolean deleteWhenDone) throws IOException {
  super(channelID,requestQueue,buffers);
  this.deleteWhenDone=deleteWhenDone;
  for (  Buffer.Input buffer : buffers) {
    this.requestQueue.add(new IORequest<Buffer.Input>(this,buffer));
  }
}

Fixed version (ground truth):
/** 
 * @param channelID
 * @param requestQueue
 * @param buffers
 * @param deleteWhenDone
 * @throws IOException
 */
protected ChannelReader(Channel.ID channelID,RequestQueue<IORequest<Buffer.Input>> requestQueue,Collection<Buffer.Input> buffers,boolean deleteWhenDone) throws IOException {
  super(channelID,requestQueue,buffers);
  this.deleteWhenDone=deleteWhenDone;
  for (  Buffer.Input buffer : buffers) {
    this.requestQueue.add(new IORequest<Buffer.Input>(this,buffer));
  }
}
Program: 56156
Project: 56156
Buggy source:
/** 
 * @param channelID
 * @param requestQueue
 * @param buffers
 * @param filledBuffers
 * @throws IOException
 */
public ChannelWriter(Channel.ID channelID,RequestQueue<IORequest<Buffer.Output>> requestQueue,Collection<Buffer.Output> buffers,boolean filledBuffers) throws IOException {
  super(channelID,requestQueue,buffers);
  try {
    this.fileChannel.truncate(0);
  }
 catch (  IOException e) {
    throw new IOException("String_Node_Str" + channelID.getPath() + "String_Node_Str",e);
  }
  if (filledBuffers) {
    for (    Buffer.Output buffer : buffers) {
      this.requestQueue.add(new IORequest<Buffer.Output>(this,buffer));
    }
  }
 else {
    this.returnBuffers.addAll(buffers);
  }
  try {
    currentBuffer=nextBuffer();
    checkErroneous();
  }
 catch (  InterruptedException iex) {
    throw new IOException("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * @param channelID
 * @param requestQueue
 * @param buffers
 * @param filledBuffers
 * @throws IOException
 */
protected ChannelWriter(Channel.ID channelID,RequestQueue<IORequest<Buffer.Output>> requestQueue,Collection<Buffer.Output> buffers,boolean filledBuffers) throws IOException {
  super(channelID,requestQueue,buffers);
  try {
    this.fileChannel.truncate(0);
  }
 catch (  IOException e) {
    throw new IOException("String_Node_Str" + channelID.getPath() + "String_Node_Str",e);
  }
  if (filledBuffers) {
    for (    Buffer.Output buffer : buffers) {
      this.requestQueue.add(new IORequest<Buffer.Output>(this,buffer));
    }
  }
 else {
    this.returnBuffers.addAll(buffers);
  }
  try {
    currentBuffer=nextBuffer();
    checkErroneous();
  }
 catch (  InterruptedException iex) {
    throw new IOException("String_Node_Str");
  }
}
Program: 56157
Project: 56157
Buggy source:
/** 
 * <p> Creates a ChannelWriter for the anonymous file identified by the specified   {@code channelID} using the provided{@code memorySegments} as backing memory for an internal flow of output buffers. If the boolean variable {@code filled} is set, the content of the memorySegments is flushed to the file before reusing.</p>
 * @param channelID
 * @param freeSegments
 * @param filled
 * @return
 * @throws IOException
 */
public ChannelWriter createChannelWriter(Channel.ID channelID,Collection<Buffer.Output> buffers,boolean filled) throws IOException {
  if (isClosed) {
    throw new IllegalStateException("String_Node_Str");
  }
  return new ChannelWriter(channelID,writer.requestQueue,buffers,filled);
}

Fixed version (ground truth):
/** 
 * Creates a ChannelWriter for the anonymous file identified by the specified   {@code channelID} using the provided{@code memorySegments} as backing memory for an internal flow of output buffers. If the boolean variable {@code filled} is set, the content of the memorySegments is flushed to the file before reusing.
 * @param channelID
 * @param freeSegments
 * @param filled
 * @return
 * @throws IOException
 */
public ChannelWriter createChannelWriter(Channel.ID channelID,Collection<Buffer.Output> buffers,boolean filled) throws IOException {
  if (isClosed) {
    throw new IllegalStateException("String_Node_Str");
  }
  return new ChannelWriter(channelID,writer.requestQueue,buffers,filled);
}
Program: 56158
Project: 56158
Buggy source:
/** 
 * <p> Creates a ChannelWriter for the anonymous file written on secondary storage and identified by the specified  {@code channelID} using the provided {@code freeSegments} as backing memory for an internal flow of inputbuffers. </p>
 * @param channelID
 * @param freeSegments
 * @return
 * @throws IOException
 */
public ChannelReader createChannelReader(Channel.ID channelID,Collection<MemorySegment> freeSegments,boolean deleteFileAfterRead) throws IOException {
  if (isClosed) {
    throw new IllegalStateException("String_Node_Str");
  }
  return new ChannelReader(channelID,reader.requestQueue,createBuffer(Buffer.Type.INPUT,freeSegments),deleteFileAfterRead);
}

Fixed version (ground truth):
/** 
 * Creates a ChannelWriter for the anonymous file written on secondary storage and identified by the specified  {@code channelID} using the provided {@code freeSegments} as backing memory for an internal flow of inputbuffers.
 * @param channelID
 * @param freeSegments
 * @return
 * @throws IOException
 */
public ChannelReader createChannelReader(Channel.ID channelID,Collection<MemorySegment> freeSegments,boolean deleteFileAfterRead) throws IOException {
  if (isClosed) {
    throw new IllegalStateException("String_Node_Str");
  }
  return new ChannelReader(channelID,reader.requestQueue,createBuffer(Buffer.Type.INPUT,freeSegments),deleteFileAfterRead);
}
Program: 56159
Project: 56159
Buggy source:
/** 
 * Close method. Shuts down the reader and writer threads immediately, not waiting for their pending requests to be served. This method waits until the threads have actually ceased their operation.
 */
public synchronized final void shutdown(){
  if (!isClosed) {
    isClosed=true;
    LOG.info("String_Node_Str");
    try {
      writer.shutdown();
    }
 catch (    Throwable t) {
      LOG.error("String_Node_Str",t);
    }
    try {
      reader.shutdown();
    }
 catch (    Throwable t) {
      LOG.error("String_Node_Str",t);
    }
    try {
      this.writer.join();
      this.reader.join();
    }
 catch (    InterruptedException iex) {
    }
  }
}

Fixed version (ground truth):
/** 
 * Close method. Shuts down the reader and writer threads immediately, not waiting for their pending requests to be served. This method waits until the threads have actually ceased their operation.
 */
public synchronized final void shutdown(){
  if (!isClosed) {
    isClosed=true;
    try {
      writer.shutdown();
    }
 catch (    Throwable t) {
      LOG.error("String_Node_Str",t);
    }
    try {
      reader.shutdown();
    }
 catch (    Throwable t) {
      LOG.error("String_Node_Str",t);
    }
    try {
      this.writer.join();
      this.reader.join();
    }
 catch (    InterruptedException iex) {
    }
  }
}
Program: 56161
Project: 56161
Buggy source:
public ChannelReader(Channel.ID channelID,RequestQueue<IORequest<Buffer.Input>> requestQueue,Collection<Buffer.Input> buffers) throws IOException {
  super(channelID,requestQueue,buffers);
  for (  Buffer.Input buffer : buffers) {
    this.requestQueue.add(new IORequest<Buffer.Input>(this,buffer));
  }
}

Fixed version (ground truth):
public ChannelReader(Channel.ID channelID,RequestQueue<IORequest<Buffer.Input>> requestQueue,Collection<Buffer.Input> buffers,boolean deleteWhenDone) throws IOException {
  super(channelID,requestQueue,buffers);
  this.deleteWhenDone=deleteWhenDone;
  for (  Buffer.Input buffer : buffers) {
    this.requestQueue.add(new IORequest<Buffer.Input>(this,buffer));
  }
}
Program: 56162
Project: 56162
Buggy source:
/** 
 * <p> Creates a ChannelWriter for the anonymous file identified by the specified   {@code channelID} using the provided{@code memorySegments} as backing memory for an internal flow of output buffers. If the boolean variable {@code filled} is set, the content of the memorySegments is flushed to the file before reusing.</p>
 * @param channelID
 * @param freeSegments
 * @param filled
 * @return
 * @throws ServiceException
 */
public ChannelWriter createChannelWriter(Channel.ID channelID,Collection<Buffer.Output> buffers,boolean filled) throws IOException {
  if (isClosed) {
    throw new IllegalStateException("String_Node_Str");
  }
  return new ChannelWriter(channelID,writer.requestQueue,buffers,filled);
}

Fixed version (ground truth):
/** 
 * <p> Creates a ChannelWriter for the anonymous file identified by the specified   {@code channelID} using the provided{@code memorySegments} as backing memory for an internal flow of output buffers. If the boolean variable {@code filled} is set, the content of the memorySegments is flushed to the file before reusing.</p>
 * @param channelID
 * @param freeSegments
 * @param filled
 * @return
 * @throws IOException
 */
public ChannelWriter createChannelWriter(Channel.ID channelID,Collection<Buffer.Output> buffers,boolean filled) throws IOException {
  if (isClosed) {
    throw new IllegalStateException("String_Node_Str");
  }
  return new ChannelWriter(channelID,writer.requestQueue,buffers,filled);
}
Program: 56163
Project: 56163
Buggy source:
/** 
 * <p> Creates a ChannelWriter for the anonymous file written on secondary storage and identified by the specified  {@code channelID} using the provided {@code freeSegments} as backing memory for an internal flow of inputbuffers. </p>
 * @param channelID
 * @param freeSegments
 * @return
 * @throws ServiceException
 */
public ChannelReader createChannelReader(Channel.ID channelID,Collection<MemorySegment> freeSegments) throws IOException {
  if (isClosed) {
    throw new IllegalStateException("String_Node_Str");
  }
  return new ChannelReader(channelID,reader.requestQueue,createBuffer(Buffer.Type.INPUT,freeSegments));
}

Fixed version (ground truth):
/** 
 * <p> Creates a ChannelWriter for the anonymous file written on secondary storage and identified by the specified  {@code channelID} using the provided {@code freeSegments} as backing memory for an internal flow of inputbuffers. </p>
 * @param channelID
 * @param freeSegments
 * @return
 * @throws IOException
 */
public ChannelReader createChannelReader(Channel.ID channelID,Collection<MemorySegment> freeSegments,boolean deleteFileAfterRead) throws IOException {
  if (isClosed) {
    throw new IllegalStateException("String_Node_Str");
  }
  return new ChannelReader(channelID,reader.requestQueue,createBuffer(Buffer.Type.INPUT,freeSegments),deleteFileAfterRead);
}
Program: 56164
Project: 56164
Buggy source:
/** 
 * Generic factory method for typed initialized collections of different buffer types.
 * @param < T >
 * @param bufferType
 * @param numberOfBuffers
 * @return Collection<T> an unsynchronized collection of initialized buffers
 * @throws ServiceException
 */
public static <T extends Buffer>Collection<T> createBuffer(Buffer.Type<T> bufferType,Collection<MemorySegment> freeSegments){
  ArrayList<T> buffers=new ArrayList<T>(freeSegments.size());
  for (  MemorySegment segment : freeSegments) {
    T buffer=createBuffer(bufferType);
    buffer.bind(segment);
    buffers.add(buffer);
  }
  return buffers;
}

Fixed version (ground truth):
/** 
 * Generic factory method for typed initialized collections of different buffer types.
 * @param < T >
 * @param bufferType
 * @param numberOfBuffers
 * @return Collection<T> an unsynchronized collection of initialized buffers
 */
public static <T extends Buffer>Collection<T> createBuffer(Buffer.Type<T> bufferType,Collection<MemorySegment> freeSegments){
  ArrayList<T> buffers=new ArrayList<T>(freeSegments.size());
  for (  MemorySegment segment : freeSegments) {
    T buffer=createBuffer(bufferType);
    buffer.bind(segment);
    buffers.add(buffer);
  }
  return buffers;
}
Program: 56165
Project: 56165
Buggy source:
/** 
 * Close method.
 */
public synchronized final void shutdown(){
  if (!isClosed) {
    isClosed=true;
    LOG.info("String_Node_Str");
    try {
      writer.shutdown();
    }
 catch (    Throwable t) {
      LOG.error("String_Node_Str",t);
    }
    try {
      reader.shutdown();
    }
 catch (    Throwable t) {
      LOG.error("String_Node_Str",t);
    }
    try {
      this.writer.join();
      this.reader.join();
    }
 catch (    InterruptedException iex) {
    }
  }
}

Fixed version (ground truth):
/** 
 * Close method. Shuts down the reader and writer threads immediately, not waiting for their pending requests to be served. This method waits until the threads have actually ceased their operation.
 */
public synchronized final void shutdown(){
  if (!isClosed) {
    isClosed=true;
    LOG.info("String_Node_Str");
    try {
      writer.shutdown();
    }
 catch (    Throwable t) {
      LOG.error("String_Node_Str",t);
    }
    try {
      reader.shutdown();
    }
 catch (    Throwable t) {
      LOG.error("String_Node_Str",t);
    }
    try {
      this.writer.join();
      this.reader.join();
    }
 catch (    InterruptedException iex) {
    }
  }
}
Program: 56166
Project: 56166
Buggy source:
public boolean isProperlyShutDown(){
  return isClosed && (this.writer.getState() == Thread.State.TERMINATED) && (this.reader.getState() == Thread.State.TERMINATED);
}

Fixed version (ground truth):
/** 
 * Utility method to check whether the IO manager has been properly shut down. The IO manager is considered to be properly shut down when it is closed and its threads have ceased operation.
 * @return True, if the IO manager has properly shut down, false otherwise.
 */
public boolean isProperlyShutDown(){
  return isClosed && (this.writer.getState() == Thread.State.TERMINATED) && (this.reader.getState() == Thread.State.TERMINATED);
}
Program: 56167
Project: 56167
Buggy source:
private int readFromChannel(Channel.ID channelID) throws IOException, MemoryAllocationException {
  Collection<MemorySegment> freeSegments=memoryManager.allocate(new DummyInvokable(),NUMBER_OF_SEGMENTS,SEGMENT_SIZE);
  ChannelReader channelReader=ioManager.createChannelReader(channelID,freeSegments);
  generator.reset();
  Value value=new Value();
  int readCounter=0;
  while (channelReader.read(value)) {
    Assert.assertEquals("String_Node_Str",generator.next(),value);
    readCounter++;
  }
  memoryManager.release(channelReader.close());
  return readCounter;
}

Fixed version (ground truth):
private int readFromChannel(Channel.ID channelID) throws IOException, MemoryAllocationException {
  Collection<MemorySegment> freeSegments=memoryManager.allocate(new DummyInvokable(),NUMBER_OF_SEGMENTS,SEGMENT_SIZE);
  ChannelReader channelReader=ioManager.createChannelReader(channelID,freeSegments,true);
  generator.reset();
  Value value=new Value();
  int readCounter=0;
  while (channelReader.read(value)) {
    Assert.assertEquals("String_Node_Str",generator.next(),value);
    readCounter++;
  }
  memoryManager.release(channelReader.close());
  return readCounter;
}
Program: 56168
Project: 56168
Buggy source:
/** 
 * This utility method picks the instance type to be used for scheduling PACT processor instances.
 * @param types The available types.
 * @return The type to be used for scheduling.
 */
private InstanceTypeDescription getType(Map<InstanceType,InstanceTypeDescription> types){
  if (types == null || types.size() < 1) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  long minMemory=0;
  int minCPUCores=Integer.MAX_VALUE;
  InstanceTypeDescription retValue=null;
  final Iterator<InstanceTypeDescription> it=types.values().iterator();
  while (it.hasNext()) {
    final InstanceTypeDescription descr=it.next();
    if (retValue == null) {
      retValue=descr;
    }
    if (descr.getInstanceType().getNumberOfCores() < minCPUCores && descr.getHardwareDescription().getSizeOfFreeMemory() > minMemory) {
      minCPUCores=descr.getInstanceType().getNumberOfCores();
      minMemory=descr.getHardwareDescription().getSizeOfFreeMemory();
      retValue=descr;
    }
  }
  return retValue;
}

Fixed version (ground truth):
/** 
 * This utility method picks the instance type to be used for scheduling PACT processor instances. <p>
 * @param types The available types.
 * @return The type to be used for scheduling.
 * @throws CompilerException
 * @throws IllegalArgumentException
 */
private InstanceTypeDescription getType(Map<InstanceType,InstanceTypeDescription> types) throws CompilerException {
  if (types == null || types.size() < 1) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  InstanceTypeDescription retValue=null;
  long totalMemory=0;
  int numInstances=0;
  final Iterator<InstanceTypeDescription> it=types.values().iterator();
  while (it.hasNext()) {
    final InstanceTypeDescription descr=it.next();
    if (descr.getHardwareDescription() == null || descr.getInstanceType() == null) {
      continue;
    }
    final int curInstances=descr.getMaximumNumberOfAvailableInstances();
    final long curMemory=curInstances * descr.getHardwareDescription().getSizeOfFreeMemory();
    if ((retValue == null) || (curInstances > numInstances && (int)(curMemory * 1.2f) > totalMemory) || (curInstances * retValue.getInstanceType().getNumberOfCores() >= numInstances && (int)(curMemory * 1.5f) > totalMemory)) {
      retValue=descr;
      numInstances=curInstances;
      totalMemory=curMemory;
    }
  }
  if (retValue == null) {
    throw new CompilerException("String_Node_Str" + "String_Node_Str");
  }
  return retValue;
}
Program: 56169
Project: 56169
Buggy source:
@Override public boolean next() throws IOException, InterruptedException {
  KeyValuePair<K,VP> pair=probePairSerialization.newInstance();
  while (currentProbePartitionReader.read(pair)) {
    K key=pair.getKey();
    if (hashMap.contains(key)) {
      currentKey=key;
      currentBuildValuesIterable=hashMap.get(currentKey);
      currentProbeValuesIterable.value=pair.getValue();
      return true;
    }
  }
  if (currentPartition >= numberOfPartitions - 1) {
    return false;
  }
  try {
    currentProbePartitionReader.close();
    currentPartition++;
    LOG.debug("String_Node_Str" + currentPartition);
    hashMap.clear();
    currentBuildPartitionReader=ioManager.createChannelReader(buildPartitionIDs.get(currentPartition),freeSegments);
    KeyValuePair<K,VB> tmp=buildPairSerialization.newInstance();
    while (currentBuildPartitionReader.read(tmp)) {
      hashMap.put(tmp.getKey(),tmp.getValue());
      tmp=buildPairSerialization.newInstance();
    }
    currentBuildPartitionReader.close();
    currentProbePartitionReader=ioManager.createChannelReader(probePartitionIDs.get(currentPartition),freeSegments);
    return next();
  }
 catch (  ServiceException e) {
    throw new IOException(e);
  }
catch (  Exception e) {
    throw new IOException(e);
  }
}

Fixed version (ground truth):
@Override public boolean next() throws IOException, InterruptedException {
  KeyValuePair<K,VP> pair=probePairSerialization.newInstance();
  while (currentProbePartitionReader.read(pair)) {
    K key=pair.getKey();
    if (hashMap.contains(key)) {
      currentKey=key;
      currentBuildValuesIterable=hashMap.get(currentKey);
      currentProbeValuesIterable.value=pair.getValue();
      return true;
    }
  }
  if (currentPartition >= numberOfPartitions - 1) {
    return false;
  }
  try {
    currentProbePartitionReader.close();
    currentPartition++;
    LOG.debug("String_Node_Str" + currentPartition);
    hashMap.clear();
    currentBuildPartitionReader=ioManager.createChannelReader(buildPartitionIDs.get(currentPartition),freeSegments,false);
    KeyValuePair<K,VB> tmp=buildPairSerialization.newInstance();
    while (currentBuildPartitionReader.read(tmp)) {
      hashMap.put(tmp.getKey(),tmp.getValue());
      tmp=buildPairSerialization.newInstance();
    }
    currentBuildPartitionReader.close();
    currentProbePartitionReader=ioManager.createChannelReader(probePartitionIDs.get(currentPartition),freeSegments,false);
    return next();
  }
 catch (  ServiceException e) {
    throw new IOException(e);
  }
catch (  Exception e) {
    throw new IOException(e);
  }
}
Program: 56170
Project: 56170
Buggy source:
/** 
 * Repartitions the build side.
 * @throws IOException
 * @throws InterruptedException
 * @throws ServiceException
 */
private void repartitionBuildSide() throws IOException, InterruptedException, ServiceException {
  LOG.debug("String_Node_Str");
  KeyValuePair<K,VB> pair=buildPairSerialization.newInstance();
  int partition;
  for (  K key : hashMap.keys()) {
    partition=partitioner.getPartition(key);
    for (    VB value : hashMap.get(key)) {
      partitionWriters.get(partition).write(new KeyValuePair<K,VB>(key,value));
    }
  }
  hashMap.clear();
  ChannelReader partitionZeroReader=ioManager.createChannelReader(buildPartitionIDs.get(0),partitionWriters.get(0).close());
  while (partitionZeroReader.read(pair)) {
    hashMap.put(pair.getKey(),pair.getValue());
  }
  partitionWriters.set(0,ioManager.createChannelWriter(buildPartitionIDs.get(0),partitionZeroReader.close()));
  LOG.debug("String_Node_Str");
  pair=overflowCause;
  partition=partitioner.getPartition(pair.getKey());
  if (partition == 0) {
    hashMap.put(pair.getKey(),pair.getValue());
  }
 else {
    partitionWriters.get(partition).write(pair);
  }
  LOG.debug("String_Node_Str");
  while (readerBuild.hasNext()) {
    pair=readerBuild.next();
    partition=partitioner.getPartition(pair.getKey());
    if (partition == 0) {
      hashMap.put(pair.getKey(),pair.getValue());
    }
 else {
      partitionWriters.get(partition).write(pair);
    }
  }
}

Fixed version (ground truth):
/** 
 * Repartitions the build side.
 * @throws IOException
 * @throws InterruptedException
 * @throws ServiceException
 */
private void repartitionBuildSide() throws IOException, InterruptedException, ServiceException {
  LOG.debug("String_Node_Str");
  KeyValuePair<K,VB> pair=buildPairSerialization.newInstance();
  int partition;
  for (  K key : hashMap.keys()) {
    partition=partitioner.getPartition(key);
    for (    VB value : hashMap.get(key)) {
      partitionWriters.get(partition).write(new KeyValuePair<K,VB>(key,value));
    }
  }
  hashMap.clear();
  ChannelReader partitionZeroReader=ioManager.createChannelReader(buildPartitionIDs.get(0),partitionWriters.get(0).close(),false);
  while (partitionZeroReader.read(pair)) {
    hashMap.put(pair.getKey(),pair.getValue());
  }
  partitionWriters.set(0,ioManager.createChannelWriter(buildPartitionIDs.get(0),partitionZeroReader.close()));
  LOG.debug("String_Node_Str");
  pair=overflowCause;
  partition=partitioner.getPartition(pair.getKey());
  if (partition == 0) {
    hashMap.put(pair.getKey(),pair.getValue());
  }
 else {
    partitionWriters.get(partition).write(pair);
  }
  LOG.debug("String_Node_Str");
  while (readerBuild.hasNext()) {
    pair=readerBuild.next();
    partition=partitioner.getPartition(pair.getKey());
    if (partition == 0) {
      hashMap.put(pair.getKey(),pair.getValue());
    }
 else {
      partitionWriters.get(partition).write(pair);
    }
  }
}
Program: 56171
Project: 56171
Buggy source:
@Override public void initialize() throws ServiceException, IOException, InterruptedException {
  LOG.debug("String_Node_Str");
  numberOfPartitions=freeSegments.size() / 2;
  partitioner=new Partitioner(numberOfPartitions);
  partitionWriters=new ArrayList<ChannelWriter>(numberOfPartitions);
  buildPartitionIDs=new ArrayList<Channel.ID>(numberOfPartitions);
  probePartitionIDs=new ArrayList<Channel.ID>(numberOfPartitions);
  LOG.debug("String_Node_Str" + numberOfPartitions + "String_Node_Str");
  LOG.debug("String_Node_Str");
  Channel.Enumerator buildEnumerator=ioManager.createChannelEnumerator();
  allocatePartitionWriters(buildEnumerator,buildPartitionIDs);
  repartitionBuildSide();
  closePartitionWriters();
  LOG.debug("String_Node_Str");
  Channel.Enumerator probeEnumerator=ioManager.createChannelEnumerator();
  allocatePartitionWriters(probeEnumerator,probePartitionIDs);
  repartitionProbeSide();
  closePartitionWriters();
  currentPartition=0;
  currentBuildPartitionReader=ioManager.createChannelReader(buildPartitionIDs.get(currentPartition),freeSegments);
  KeyValuePair<K,VB> pair=buildPairSerialization.newInstance();
  while (currentBuildPartitionReader.read(pair)) {
    hashMap.put(pair.getKey(),pair.getValue());
  }
  currentBuildPartitionReader.close();
  currentProbePartitionReader=ioManager.createChannelReader(probePartitionIDs.get(currentPartition),freeSegments);
}

Fixed version (ground truth):
@Override public void initialize() throws ServiceException, IOException, InterruptedException {
  LOG.debug("String_Node_Str");
  numberOfPartitions=freeSegments.size() / 2;
  partitioner=new Partitioner(numberOfPartitions);
  partitionWriters=new ArrayList<ChannelWriter>(numberOfPartitions);
  buildPartitionIDs=new ArrayList<Channel.ID>(numberOfPartitions);
  probePartitionIDs=new ArrayList<Channel.ID>(numberOfPartitions);
  LOG.debug("String_Node_Str" + numberOfPartitions + "String_Node_Str");
  LOG.debug("String_Node_Str");
  Channel.Enumerator buildEnumerator=ioManager.createChannelEnumerator();
  allocatePartitionWriters(buildEnumerator,buildPartitionIDs);
  repartitionBuildSide();
  closePartitionWriters();
  LOG.debug("String_Node_Str");
  Channel.Enumerator probeEnumerator=ioManager.createChannelEnumerator();
  allocatePartitionWriters(probeEnumerator,probePartitionIDs);
  repartitionProbeSide();
  closePartitionWriters();
  currentPartition=0;
  currentBuildPartitionReader=ioManager.createChannelReader(buildPartitionIDs.get(currentPartition),freeSegments,false);
  KeyValuePair<K,VB> pair=buildPairSerialization.newInstance();
  while (currentBuildPartitionReader.read(pair)) {
    hashMap.put(pair.getKey(),pair.getValue());
  }
  currentBuildPartitionReader.close();
  currentProbePartitionReader=ioManager.createChannelReader(probePartitionIDs.get(currentPartition),freeSegments,false);
}
Program: 56172
Project: 56172
Buggy source:
public void reset(){
  try {
    next=null;
    if (fitsIntoMem) {
      if (currentBuffer != usedBuffers)       inputBuffers.get(currentBuffer).reset();
      currentBuffer=0;
    }
 else {
      ioReader.close();
      ioReader=ioManager.createChannelReader(bufferID,memorySegments);
    }
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
  LOG.debug("String_Node_Str" + count + "String_Node_Str");
  count=0;
}

Fixed version (ground truth):
public void reset(){
  try {
    next=null;
    if (fitsIntoMem) {
      if (currentBuffer != usedBuffers)       inputBuffers.get(currentBuffer).reset();
      currentBuffer=0;
    }
 else {
      ioReader.close();
      ioReader=ioManager.createChannelReader(bufferID,memorySegments,false);
    }
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
  LOG.debug("String_Node_Str" + count + "String_Node_Str");
  count=0;
}
Program: 56176
Project: 56176
Buggy source:
/** 
 * Assigns the execution vertex with an   {@link AllocatedResource}.
 * @param allocatedResource the resources which are supposed to be allocated to this vertex
 */
public synchronized void setAllocatedResource(AllocatedResource allocatedResource){
  this.allocatedResource=allocatedResource;
}

Fixed version (ground truth):
/** 
 * Assigns the execution vertex with an   {@link AllocatedResource}.
 * @param allocatedResource the resources which are supposed to be allocated to this vertex
 */
public synchronized void setAllocatedResource(AllocatedResource allocatedResource){
  this.allocatedResource=allocatedResource;
  final Iterator<VertexAssignmentListener> it=this.vertexAssignmentListeners.iterator();
  while (it.hasNext()) {
    it.next().vertexAssignmentChanged(this.vertexID,this.allocatedResource);
  }
}
Program: 56177
Project: 56177
Buggy source:
/** 
 * Registers a job in form of its execution graph representation with the job progress collector. The collector will subscribe to state changes of the individual subtasks. A separate deregistration is not necessary since the job progress collector periodically discards outdated progress information.
 * @param executionGraph the execution graph representing the job
 * @param profilingAvailable indicates if profiling data is available for this job
 */
public void registerJob(ExecutionGraph executionGraph,boolean profilingAvailable){
  final Iterator<ExecutionVertex> it=new ExecutionGraphIterator(executionGraph,true);
  while (it.hasNext()) {
    final ExecutionVertex vertex=it.next();
    vertex.getEnvironment().registerExecutionListener(new ExecutionListenerWrapper(this,vertex.getGroupVertex().getJobVertexID(),vertex.getID()));
  }
  executionGraph.registerJobStatusListener(new JobStatusListenerWrapper(this,executionGraph.getJobName(),profilingAvailable));
}

Fixed version (ground truth):
/** 
 * Registers a job in form of its execution graph representation with the job progress collector. The collector will subscribe to state changes of the individual subtasks. A separate deregistration is not necessary since the job progress collector periodically discards outdated progress information.
 * @param executionGraph the execution graph representing the job
 * @param profilingAvailable indicates if profiling data is available for this job
 */
public void registerJob(ExecutionGraph executionGraph,boolean profilingAvailable){
  final Iterator<ExecutionVertex> it=new ExecutionGraphIterator(executionGraph,true);
  while (it.hasNext()) {
    final ExecutionVertex vertex=it.next();
    vertex.getEnvironment().registerExecutionListener(new ExecutionListenerWrapper(this,vertex.getGroupVertex().getJobVertexID(),vertex.getID()));
    vertex.registerVertexAssignmentListener(new VertexAssignmentListenerWrapper(this,executionGraph.getJobID()));
  }
  executionGraph.registerJobStatusListener(new JobStatusListenerWrapper(this,executionGraph.getJobName(),profilingAvailable));
}
Program: 56178
Project: 56178
Buggy source:
@Override public void processProfilingEvents(ProfilingEvent profilingEvent){
  addEvent(profilingEvent.getJobID(),profilingEvent);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public void processProfilingEvents(ProfilingEvent profilingEvent){
  addEvent(profilingEvent.getJobID(),profilingEvent);
}
Program: 56179
Project: 56179
Buggy source:
public void updateView(){
  if (this.threadChart != null) {
    this.threadChart.getChart().getXYPlot().configureDomainAxes();
    this.threadChart.getChart().fireChartChanged();
  }
  this.executionStateLabel.setText(this.managementVertex.getExecutionState().toString());
  final ManagementGroupVertex groupVertex=this.managementVertex.getGroupVertex();
  final GroupVertexVisualizationData groupVertexVisualizationData=(GroupVertexVisualizationData)groupVertex.getAttachment();
  if (groupVertexVisualizationData.isCPUBottleneck()) {
    if (this.warningComposite == null) {
      this.warningComposite=createWarningComposite(WARNINGTEXT,SWT.ICON_WARNING);
      Rectangle clientRect=getShell().getClientArea();
      clientRect.height+=ICONSIZE;
      getShell().setSize(clientRect.width,clientRect.height);
    }
  }
 else {
    if (this.warningComposite != null) {
      this.warningComposite.dispose();
      this.warningComposite=null;
      Rectangle clientRect=getShell().getClientArea();
      clientRect.height-=ICONSIZE;
      getShell().setSize(clientRect.width,clientRect.height);
    }
  }
}

Fixed version (ground truth):
public void updateView(){
  if (this.threadChart != null) {
    this.threadChart.getChart().getXYPlot().configureDomainAxes();
    this.threadChart.getChart().fireChartChanged();
  }
  this.executionStateLabel.setText(this.managementVertex.getExecutionState().toString());
  this.instanceIDLabel.setText(this.managementVertex.getInstanceName());
  this.instanceTypeLabel.setText(this.managementVertex.getInstanceType());
  final ManagementGroupVertex groupVertex=this.managementVertex.getGroupVertex();
  final GroupVertexVisualizationData groupVertexVisualizationData=(GroupVertexVisualizationData)groupVertex.getAttachment();
  if (groupVertexVisualizationData.isCPUBottleneck()) {
    if (this.warningComposite == null) {
      this.warningComposite=createWarningComposite(WARNINGTEXT,SWT.ICON_WARNING);
      Rectangle clientRect=getShell().getClientArea();
      clientRect.height+=ICONSIZE;
      getShell().setSize(clientRect.width,clientRect.height);
    }
  }
 else {
    if (this.warningComposite != null) {
      this.warningComposite.dispose();
      this.warningComposite=null;
      Rectangle clientRect=getShell().getClientArea();
      clientRect.height-=ICONSIZE;
      getShell().setSize(clientRect.width,clientRect.height);
    }
  }
}
Program: 56181
Project: 56181
Buggy source:
/** 
 * Initializes the output collector with a set of writers.  To specify for a writer that it must be fed with a deep-copy, set the bit in the copy flag bit mask to 1 that  corresponds to the position of the writer within the   {@link List}.
 * @param writers List of all writers.
 * @param fwdCopyFlags Bit mask that specifies which writer is fed with deep-copies.
 */
public OutputCollector(List<RecordWriter<KeyValuePair<K,V>>> writers,int fwdCopyFlags){
  this.writers=writers;
  this.fwdCopyFlags=fwdCopyFlags;
  this.copier=new SerializationCopier<KeyValuePair<K,V>>();
}

Fixed version (ground truth):
/** 
 * Initializes the output collector with a set of writers.  To specify for a writer that it must be fed with a deep-copy, set the bit in the copy flag bit mask to 1 that  corresponds to the position of the writer within the   {@link List}.
 * @param writers List of all writers.
 * @param fwdCopyFlags Bit mask that specifies which writer is fed with deep-copies.
 */
public OutputCollector(List<RecordWriter<KeyValuePair<K,V>>> writers,int fwdCopyFlags){
  this.writers=writers;
  this.fwdCopyFlags=fwdCopyFlags;
  this.kvpCopier=new SerializationCopier<KeyValuePair<K,V>>();
}
Program: 56182
Project: 56182
Buggy source:
/** 
 * Collects a   {@link Key} and {@link Value}, wraps them in a KeyValuePair, and emit them to all writers. Writers which require a deep-copy are fed with a copy obtained through de/serialization.
 */
@Override public void collect(K key,V value){
  try {
    final KeyValuePair<K,V> emitPair=new KeyValuePair<K,V>(key,value);
    if (fwdCopyFlags == 0) {
      for (int i=0; i < writers.size(); i++) {
        writers.get(i).emit(emitPair);
      }
    }
 else {
      copier.setCopy(emitPair);
      for (int i=0; i < writers.size(); i++) {
        if (((fwdCopyFlags >> i) & 0x1) != 0) {
          copier.getCopy(emitPair);
        }
        writers.get(i).emit(emitPair);
      }
    }
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
catch (  InterruptedException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
/** 
 * Collects a   {@link Key} and {@link Value}, wraps them in a KeyValuePair, and emit them to all writers. Writers which require a deep-copy are fed with a copy obtained through de/serialization.
 */
@Override public void collect(K key,V value){
  try {
    KeyValuePair<K,V> emitPair=new KeyValuePair<K,V>(key,value);
    if (fwdCopyFlags == 0) {
      for (int i=0; i < writers.size(); i++) {
        writers.get(i).emit(emitPair);
      }
    }
 else {
      if (kvpSerialization == null) {
        this.kvpSerialization=new KeyValuePairSerializationFactory<K,V>(new WritableSerializationFactory<K>((Class<K>)key.getClass()),new WritableSerializationFactory<V>((Class<V>)value.getClass()));
      }
      kvpCopier.setCopy(emitPair);
      for (int i=0; i < writers.size(); i++) {
        if (((fwdCopyFlags >> i) & 0x1) != 0) {
          emitPair=kvpSerialization.newInstance();
          kvpCopier.getCopy(emitPair);
        }
        writers.get(i).emit(emitPair);
      }
    }
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
catch (  InterruptedException e) {
    throw new RuntimeException(e);
  }
}
Program: 56183
Project: 56183
Buggy source:
protected JobGraph getJobGraph() throws Exception {
  JobGraph jobGraph=new JobGraph("String_Node_Str");
  JobFileInputVertex input=new JobFileInputVertex("String_Node_Str",jobGraph);
  input.setFileInputClass(FileLineReader.class);
  input.setFilePath(new Path(hdfs.getTempDirPath() + "String_Node_Str"));
  JobTaskVertex task=new JobTaskVertex("String_Node_Str",jobGraph);
  task.setTaskClass(GrepTask.class);
  JobFileOutputVertex output=new JobFileOutputVertex("String_Node_Str",jobGraph);
  output.setFileOutputClass(FileLineWriter.class);
  output.setFilePath(new Path(hdfs.getTempDirPath() + "String_Node_Str"));
  input.connectTo(task,ChannelType.INMEMORY,CompressionLevel.NO_COMPRESSION);
  task.connectTo(output,ChannelType.INMEMORY,CompressionLevel.NO_COMPRESSION);
  return jobGraph;
}

Fixed version (ground truth):
protected JobGraph getJobGraph() throws Exception {
  JobGraph jobGraph=new JobGraph("String_Node_Str");
  JobFileInputVertex input=new JobFileInputVertex("String_Node_Str",jobGraph);
  input.setFileInputClass(FileLineReader.class);
  input.setFilePath(new Path(hdfs.getURIPrefix() + hdfs.getTempDirPath() + "String_Node_Str"));
  JobTaskVertex task=new JobTaskVertex("String_Node_Str",jobGraph);
  task.setTaskClass(GrepTask.class);
  JobFileOutputVertex output=new JobFileOutputVertex("String_Node_Str",jobGraph);
  output.setFileOutputClass(FileLineWriter.class);
  output.setFilePath(new Path(hdfs.getURIPrefix() + hdfs.getTempDirPath() + "String_Node_Str"));
  input.connectTo(task,ChannelType.INMEMORY,CompressionLevel.NO_COMPRESSION);
  task.connectTo(output,ChannelType.INMEMORY,CompressionLevel.NO_COMPRESSION);
  return jobGraph;
}
Program: 56184
Project: 56184
Buggy source:
protected void preSubmit() throws Exception {
  OutputStream os=hdfs.getOutputStream("String_Node_Str");
  Writer wr=new OutputStreamWriter(os);
  wr.write("String_Node_Str");
  wr.write("String_Node_Str");
  wr.write("String_Node_Str");
  wr.close();
}

Fixed version (ground truth):
protected void preSubmit() throws Exception {
  OutputStream os=hdfs.getOutputStream(hdfs.getTempDirPath() + "String_Node_Str");
  Writer wr=new OutputStreamWriter(os);
  wr.write("String_Node_Str");
  wr.write("String_Node_Str");
  wr.write("String_Node_Str");
  wr.close();
}