nus-yam/ex-repair huggingface dataset:
Program: 80316
Project: 80316
Buggy source:
@Override public Iterator<T> iterator(){
  if (this.state != State.READ) {
    throw new IllegalStateException();
  }
  return new Iterator<T>(){
    @Override public boolean hasNext(){
      try {
        return DiskList.this.inputStream.available() > 0;
      }
 catch (      IOException e) {
        return false;
      }
    }
    @Override public T next(){
      try {
        int length=DiskList.this.inputStream.read();
        byte[] bytes=new byte[length];
        int size=DiskList.this.inputStream.read(bytes);
        if (size < 0) {
          throw new GuaguaRuntimeException("String_Node_Str");
        }
        return DiskList.this.getSerializer().deserialize(bytes,null);
      }
 catch (      IOException e) {
        throw new GuaguaRuntimeException(e);
      }
    }
    @Override public void remove(){
      throw new UnsupportedOperationException();
    }
  }
;
}

Fixed version (ground truth):
@Override public Iterator<T> iterator(){
  if (this.state != State.READ) {
    throw new IllegalStateException();
  }
  return new Iterator<T>(){
    @Override public boolean hasNext(){
      try {
        return DiskList.this.inputStream.available() > 0;
      }
 catch (      IOException e) {
        return false;
      }
    }
    @Override public T next(){
      try {
        int length=DiskList.this.inputStream.readInt();
        byte[] bytes=new byte[length];
        for (int i=0; i < bytes.length; i++) {
          bytes[i]=DiskList.this.inputStream.readByte();
        }
        return DiskList.this.getSerializer().deserialize(bytes,null);
      }
 catch (      IOException e) {
        throw new GuaguaRuntimeException(e);
      }
    }
    @Override public void remove(){
      throw new UnsupportedOperationException();
    }
  }
;
}
Program: 80317
Project: 80317
Buggy source:
/** 
 * Constructor with file name in current working dir.
 */
public DiskList(String fileName){
  try {
    this.file=new File(fileName);
    this.outputStream=new FileOutputStream(file);
    this.inputStream=new FileInputStream(file);
  }
 catch (  FileNotFoundException e) {
    throw new GuaguaRuntimeException(e);
  }
}

Fixed version (ground truth):
/** 
 * Constructor with file name in current working dir.
 */
public DiskList(String fileName){
  try {
    this.file=new File(fileName);
    this.outputStream=new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file)));
    this.inputStream=new DataInputStream(new BufferedInputStream(new FileInputStream(file)));
  }
 catch (  FileNotFoundException e) {
    throw new GuaguaRuntimeException(e);
  }
}
Program: 80318
Project: 80318
Buggy source:
@Override public boolean append(T t){
  if (this.state != State.WRITE) {
    throw new IllegalStateException();
  }
  this.count+=1;
  byte[] bytes=getSerializer().serialize(t);
  try {
    this.outputStream.write(bytes.length);
    this.outputStream.write(bytes);
  }
 catch (  IOException e) {
    throw new GuaguaRuntimeException(e);
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean append(T t){
  if (this.state != State.WRITE) {
    throw new IllegalStateException();
  }
  this.count+=1;
  byte[] bytes=getSerializer().serialize(t);
  try {
    this.outputStream.writeInt(bytes.length);
    for (    byte b : bytes) {
      this.outputStream.writeByte(b);
    }
  }
 catch (  IOException e) {
    throw new GuaguaRuntimeException(e);
  }
  return true;
}
Program: 80321
Project: 80321
Buggy source:
@Override public void readFields(DataInput in) throws IOException {
  this.currentIteration=in.readInt();
  this.containerId=in.readUTF();
  this.isStopMessage=in.readBoolean();
  int bytesSize=in.readInt();
  if (bytesSize != 0) {
    this.bytes=new byte[bytesSize];
    in.readFully(bytes);
  }
}

Fixed version (ground truth):
@Override public void readFields(DataInput in) throws IOException {
  this.currentIteration=in.readInt();
  int containerIdlen=in.readInt();
  if (containerIdlen != 0) {
    byte[] containerIdbytes=new byte[containerIdlen];
    for (int i=0; i < containerIdbytes.length; i++) {
      containerIdbytes[i]=in.readByte();
    }
    this.containerId=new String(containerIdbytes,Charset.forName("String_Node_Str"));
  }
 else {
    this.containerId=null;
  }
  this.isStopMessage=in.readBoolean();
  int bytesSize=in.readInt();
  if (bytesSize != 0) {
    this.bytes=new byte[bytesSize];
    for (int i=0; i < this.bytes.length; i++) {
      this.bytes[i]=in.readByte();
    }
  }
}
Program: 80322
Project: 80322
Buggy source:
@Override public void write(DataOutput out) throws IOException {
  out.writeInt(this.currentIteration);
  out.writeUTF(this.containerId);
  out.writeBoolean(this.isStopMessage);
  if (this.bytes != null) {
    out.writeInt(bytes.length);
    out.write(bytes);
  }
 else {
    out.writeInt(0);
  }
}

Fixed version (ground truth):
@Override public void write(DataOutput out) throws IOException {
  out.writeInt(this.currentIteration);
  if (this.containerId == null) {
    out.writeInt(0);
  }
 else {
    writeBytes(out,this.containerId.getBytes(Charset.forName("String_Node_Str")));
  }
  out.writeBoolean(this.isStopMessage);
  if (this.bytes != null) {
    out.writeInt(bytes.length);
    for (int i=0; i < bytes.length; i++) {
      out.writeByte(bytes[i]);
    }
  }
 else {
    out.writeInt(0);
  }
}
Program: 80324
Project: 80324
Buggy source:
/** 
 * Start netty server which is used to communicate with workers.
 */
private void startNettyServer(Properties props){
  this.messageServerPort=NumberFormatUtils.getInt(props.getProperty(GuaguaConstants.GUAGUA_NETTY_SEVER_PORT),GuaguaConstants.GUAGUA_NETTY_SEVER_DEFAULT_PORT);
  this.messageServerPort=NetworkUtils.getValidServerPort(this.messageServerPort);
  this.messageServer=new ServerBootstrap(new NioServerSocketChannelFactory(Executors.newFixedThreadPool(GuaguaConstants.GUAGUA_NETTY_SERVER_DEFAULT_THREAD_COUNT),Executors.newCachedThreadPool()));
  this.messageServer.setPipelineFactory(new ChannelPipelineFactory(){
    public ChannelPipeline getPipeline() throws Exception {
      return Channels.pipeline(new NettyBytableEncoder(),new NettyBytableDecoder(),new ServerHandler());
    }
  }
);
  try {
    this.messageServer.bind(new InetSocketAddress(this.messageServerPort));
  }
 catch (  ChannelException e) {
    LOG.warn(e.getMessage() + "String_Node_Str");
    this.messageServerPort=NetworkUtils.getValidServerPort(this.messageServerPort);
    this.messageServer.bind(new InetSocketAddress(this.messageServerPort));
  }
}

Fixed version (ground truth):
/** 
 * Start netty server which is used to communicate with workers.
 */
private void startNettyServer(Properties props){
  this.messageServerPort=NumberFormatUtils.getInt(props.getProperty(GuaguaConstants.GUAGUA_NETTY_SEVER_PORT),GuaguaConstants.GUAGUA_NETTY_SEVER_DEFAULT_PORT);
  this.messageServerPort=NetworkUtils.getValidServerPort(this.messageServerPort);
  this.messageServer=new ServerBootstrap(new NioServerSocketChannelFactory(Executors.newFixedThreadPool(GuaguaConstants.GUAGUA_NETTY_SERVER_DEFAULT_THREAD_COUNT),Executors.newCachedThreadPool(new MasterThreadFactory())));
  this.messageServer.setPipelineFactory(new ChannelPipelineFactory(){
    public ChannelPipeline getPipeline() throws Exception {
      return Channels.pipeline(new NettyBytableEncoder(),new NettyBytableDecoder(),new ServerHandler());
    }
  }
);
  try {
    this.messageServer.bind(new InetSocketAddress(this.messageServerPort));
  }
 catch (  ChannelException e) {
    LOG.warn(e.getMessage() + "String_Node_Str");
    this.messageServerPort=NetworkUtils.getValidServerPort(this.messageServerPort);
    this.messageServer.bind(new InetSocketAddress(this.messageServerPort));
  }
}
Program: 80325
Project: 80325
Buggy source:
/** 
 * Re-open stream for iterators.
 */
public void reOpen(){
  close();
  try {
    this.inputStream=new FileInputStream(file);
  }
 catch (  FileNotFoundException e) {
    throw new GuaguaRuntimeException(e);
  }
}

Fixed version (ground truth):
/** 
 * Re-open stream for iterators.
 */
public void reOpen(){
  close();
  try {
    this.inputStream=new DataInputStream(new FileInputStream(file));
  }
 catch (  FileNotFoundException e) {
    throw new GuaguaRuntimeException(e);
  }
}
Program: 80326
Project: 80326
Buggy source:
@Override public T next(){
  try {
    int length=BytableDiskList.this.inputStream.read();
    byte[] bytes=new byte[length];
    int size=BytableDiskList.this.inputStream.read(bytes);
    if (size < 0) {
      throw new GuaguaRuntimeException("String_Node_Str");
    }
    return BytableDiskList.this.getSerializer().bytesToObject(bytes,className);
  }
 catch (  IOException e) {
    throw new GuaguaRuntimeException(e);
  }
}

Fixed version (ground truth):
@Override public T next(){
  try {
    int length=BytableDiskList.this.inputStream.readInt();
    byte[] bytes=new byte[length];
    int size=BytableDiskList.this.inputStream.read(bytes);
    if (size < 0) {
      throw new GuaguaRuntimeException("String_Node_Str");
    }
    return BytableDiskList.this.getSerializer().bytesToObject(bytes,className);
  }
 catch (  IOException e) {
    throw new GuaguaRuntimeException(e);
  }
}
Program: 80327
Project: 80327
Buggy source:
@Override public void clear(){
  FileUtils.deleteQuietly(file);
}

Fixed version (ground truth):
/** 
 * Delete file to store elements. After this method call, user cannot use such list. But clear here is used to clear resources used.
 */
@Override public void clear(){
  FileUtils.deleteQuietly(file);
}
Program: 80328
Project: 80328
Buggy source:
/** 
 * Constructor with file name in current working dir, class name and serializer instance.
 */
public BytableDiskList(String fileName,String className,BytableSerializer<T> serializer){
  try {
    this.file=new File(fileName);
    this.outputStream=new FileOutputStream(file);
    this.inputStream=new FileInputStream(file);
  }
 catch (  FileNotFoundException e) {
    throw new GuaguaRuntimeException(e);
  }
  this.className=className;
  this.serializer=serializer;
}

Fixed version (ground truth):
/** 
 * Constructor with file name in current working dir, class name and serializer instance.
 */
public BytableDiskList(String fileName,String className,BytableSerializer<T> serializer){
  try {
    this.file=new File(fileName);
    this.outputStream=new DataOutputStream(new FileOutputStream(file));
    this.inputStream=new DataInputStream(new FileInputStream(file));
  }
 catch (  FileNotFoundException e) {
    throw new GuaguaRuntimeException(e);
  }
  this.className=className;
  this.serializer=serializer;
}
Program: 80329
Project: 80329
Buggy source:
@Override public Iterator<T> iterator(){
  if (this.state != State.READ) {
    throw new IllegalStateException();
  }
  return new Iterator<T>(){
    @Override public boolean hasNext(){
      try {
        return BytableDiskList.this.inputStream.available() > 0;
      }
 catch (      IOException e) {
        return false;
      }
    }
    @Override public T next(){
      try {
        int length=BytableDiskList.this.inputStream.read();
        byte[] bytes=new byte[length];
        int size=BytableDiskList.this.inputStream.read(bytes);
        if (size < 0) {
          throw new GuaguaRuntimeException("String_Node_Str");
        }
        return BytableDiskList.this.getSerializer().bytesToObject(bytes,className);
      }
 catch (      IOException e) {
        throw new GuaguaRuntimeException(e);
      }
    }
    @Override public void remove(){
      throw new UnsupportedOperationException();
    }
  }
;
}

Fixed version (ground truth):
@Override public Iterator<T> iterator(){
  if (this.state != State.READ) {
    throw new IllegalStateException();
  }
  return new Iterator<T>(){
    @Override public boolean hasNext(){
      try {
        return BytableDiskList.this.inputStream.available() > 0;
      }
 catch (      IOException e) {
        return false;
      }
    }
    @Override public T next(){
      try {
        int length=BytableDiskList.this.inputStream.readInt();
        byte[] bytes=new byte[length];
        int size=BytableDiskList.this.inputStream.read(bytes);
        if (size < 0) {
          throw new GuaguaRuntimeException("String_Node_Str");
        }
        return BytableDiskList.this.getSerializer().bytesToObject(bytes,className);
      }
 catch (      IOException e) {
        throw new GuaguaRuntimeException(e);
      }
    }
    @Override public void remove(){
      throw new UnsupportedOperationException();
    }
  }
;
}
Program: 80330
Project: 80330
Buggy source:
@Override public boolean append(T t){
  if (this.state != State.WRITE) {
    throw new IllegalStateException();
  }
  this.count+=1;
  byte[] bytes=getSerializer().objectToBytes(t);
  try {
    this.outputStream.write(bytes.length);
    this.outputStream.write(bytes);
  }
 catch (  IOException e) {
    throw new GuaguaRuntimeException(e);
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean append(T t){
  if (this.state != State.WRITE) {
    throw new IllegalStateException();
  }
  this.count+=1;
  byte[] bytes=getSerializer().objectToBytes(t);
  try {
    this.outputStream.writeInt(bytes.length);
    this.outputStream.write(bytes);
  }
 catch (  IOException e) {
    throw new GuaguaRuntimeException(e);
  }
  return true;
}
Program: 80331
Project: 80331
Buggy source:
/** 
 * Switch state from WRITE to READ
 */
@Override public void switchState(){
  this.state=State.READ;
}

Fixed version (ground truth):
/** 
 * Switch state from WRITE to READ
 */
@Override public void switchState(){
  this.state=State.READ;
  try {
    this.outputStream.flush();
  }
 catch (  IOException e) {
    throw new GuaguaRuntimeException(e);
  }
}
Program: 80332
Project: 80332
Buggy source:
/** 
 * Send stop message to master and then clean resources.
 */
@Override public void postApplication(final WorkerContext<MASTER_RESULT,WORKER_RESULT> context){
  new BasicCoordinatorCommand(){
    @Override public void doExecute() throws Exception, InterruptedException {
      try {
        BytableWrapper stopMessage=new BytableWrapper();
        stopMessage.setCurrentIteration(context.getCurrentIteration());
        stopMessage.setContainerId(context.getContainerId());
        stopMessage.setStopMessage(true);
        ChannelFuture future=NettyWorkerCoordinator.this.clientChannel.write(stopMessage);
        future.await(5,TimeUnit.SECONDS);
      }
  finally {
        NettyWorkerCoordinator.this.clientChannel.close();
        Method shutDownMethod=ReflectionUtils.getMethod(NettyWorkerCoordinator.this.messageClient.getClass(),"String_Node_Str");
        if (shutDownMethod != null) {
          shutDownMethod.invoke(NettyWorkerCoordinator.this.messageClient,(Object[])null);
        }
        NettyWorkerCoordinator.this.messageClient.releaseExternalResources();
        closeZooKeeper();
      }
    }
  }
.execute();
}

Fixed version (ground truth):
/** 
 * Send stop message to master and then clean resources.
 */
@Override public void postApplication(final WorkerContext<MASTER_RESULT,WORKER_RESULT> context){
  new BasicCoordinatorCommand(){
    @Override public void doExecute() throws Exception, InterruptedException {
      try {
        BytableWrapper stopMessage=new BytableWrapper();
        stopMessage.setCurrentIteration(context.getCurrentIteration());
        stopMessage.setContainerId(context.getContainerId());
        stopMessage.setStopMessage(true);
        ChannelFuture future=NettyWorkerCoordinator.this.clientChannel.write(stopMessage);
        future.await(30,TimeUnit.SECONDS);
      }
  finally {
        NettyWorkerCoordinator.this.clientChannel.close();
        Method shutDownMethod=ReflectionUtils.getMethod(NettyWorkerCoordinator.this.messageClient.getClass(),"String_Node_Str");
        if (shutDownMethod != null) {
          shutDownMethod.invoke(NettyWorkerCoordinator.this.messageClient,(Object[])null);
        }
        NettyWorkerCoordinator.this.messageClient.releaseExternalResources();
        closeZooKeeper();
      }
    }
  }
.execute();
}
Program: 80333
Project: 80333
Buggy source:
@Override public void doExecute() throws Exception, InterruptedException {
  try {
    BytableWrapper stopMessage=new BytableWrapper();
    stopMessage.setCurrentIteration(context.getCurrentIteration());
    stopMessage.setContainerId(context.getContainerId());
    stopMessage.setStopMessage(true);
    ChannelFuture future=NettyWorkerCoordinator.this.clientChannel.write(stopMessage);
    future.await(5,TimeUnit.SECONDS);
  }
  finally {
    NettyWorkerCoordinator.this.clientChannel.close();
    Method shutDownMethod=ReflectionUtils.getMethod(NettyWorkerCoordinator.this.messageClient.getClass(),"String_Node_Str");
    if (shutDownMethod != null) {
      shutDownMethod.invoke(NettyWorkerCoordinator.this.messageClient,(Object[])null);
    }
    NettyWorkerCoordinator.this.messageClient.releaseExternalResources();
    closeZooKeeper();
  }
}

Fixed version (ground truth):
@Override public void doExecute() throws Exception, InterruptedException {
  try {
    BytableWrapper stopMessage=new BytableWrapper();
    stopMessage.setCurrentIteration(context.getCurrentIteration());
    stopMessage.setContainerId(context.getContainerId());
    stopMessage.setStopMessage(true);
    ChannelFuture future=NettyWorkerCoordinator.this.clientChannel.write(stopMessage);
    future.await(30,TimeUnit.SECONDS);
  }
  finally {
    NettyWorkerCoordinator.this.clientChannel.close();
    Method shutDownMethod=ReflectionUtils.getMethod(NettyWorkerCoordinator.this.messageClient.getClass(),"String_Node_Str");
    if (shutDownMethod != null) {
      shutDownMethod.invoke(NettyWorkerCoordinator.this.messageClient,(Object[])null);
    }
    NettyWorkerCoordinator.this.messageClient.releaseExternalResources();
    closeZooKeeper();
  }
}
Program: 80334
Project: 80334
Buggy source:
/** 
 * Check whether a server is alive.
 * @param host the server host
 * @param port the server port
 * @return true if a server is alive, false if a server is not alive.
 */
public static boolean isServerAlive(String host,int port){
  Socket socket=null;
  int i=0;
  while (i++ < RETRY_COUNT) {
    try {
      socket=new Socket(host,port);
      break;
    }
 catch (    IOException e) {
      try {
        Thread.sleep(1000);
      }
 catch (      InterruptedException e1) {
        Thread.currentThread().interrupt();
      }
    }
 finally {
      try {
        if (socket != null) {
          socket.close();
        }
      }
 catch (      IOException ignore) {
      }
    }
  }
  return i == RETRY_COUNT;
}

Fixed version (ground truth):
/** 
 * Check whether a server is alive.
 * @param host the server host
 * @param port the server port
 * @return true if a server is alive, false if a server is not alive.
 */
public static boolean isServerAlive(String host,int port){
  Socket socket=null;
  int i=0;
  while (i++ < RETRY_COUNT) {
    try {
      socket=new Socket(host,port);
      break;
    }
 catch (    IOException e) {
      try {
        Thread.sleep(1000);
      }
 catch (      InterruptedException e1) {
        Thread.currentThread().interrupt();
      }
    }
 finally {
      try {
        if (socket != null) {
          socket.close();
        }
      }
 catch (      IOException ignore) {
      }
    }
  }
  return i < RETRY_COUNT;
}
Program: 80335
Project: 80335
Buggy source:
/** 
 * Check zookeeper servers, if one of them is alive, return true;
 */
public static boolean checkServers(String servers){
  String[] serverArray=servers.split("String_Node_Str");
  for (  String server : serverArray) {
    if (server != null) {
      server=server.trim();
      String port=null;
      String host=null;
      if (server.indexOf(':') > 0) {
        String[] hostAndPort=server.split("String_Node_Str");
        host=hostAndPort[0].trim();
        port=hostAndPort[1].trim();
      }
 else {
        host=server;
      }
      if (isServerAlive(host,Integer.parseInt(port))) {
        return true;
      }
    }
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Check zookeeper servers, if one of them is alive, return true;
 */
public static boolean checkServers(String servers){
  String[] serverArray=servers.split("String_Node_Str");
  for (  String server : serverArray) {
    if (server != null) {
      server=server.trim();
      String port=null;
      String host=null;
      if (server.indexOf(':') > 0) {
        String[] hostAndPort=server.split("String_Node_Str");
        host=hostAndPort[0].trim();
        port=hostAndPort[1].trim();
      }
 else {
        host=server;
        port=DEFAULT_ZK_PORT + "String_Node_Str";
      }
      if (isServerAlive(host,Integer.parseInt(port))) {
        return true;
      }
    }
  }
  return false;
}
Program: 80336
Project: 80336
Buggy source:
/** 
 * Iterate   {@link WorkerComputable#compute(WorkerContext)}, and set hook point before and after each iteration.
 */
@Override public void run(Progressable progress){
  WorkerContext<MASTER_RESULT,WORKER_RESULT> context=buildContext();
  int iteration=context.getCurrentIteration();
  while (iteration < getTotalIteration()) {
    int currIter=iteration + 1;
    context.setCurrentIteration(currIter);
    iterate(context,currIter,progress);
    iteration=context.getCurrentIteration();
    MASTER_RESULT masterResult=context.getLastMasterResult();
    if ((masterResult instanceof HaltBytable) && ((HaltBytable)masterResult).isHalt()) {
      break;
    }
  }
}

Fixed version (ground truth):
/** 
 * Iterate   {@link WorkerComputable#compute(WorkerContext)}, and set hook point before and after each iteration.
 */
@Override public void run(Progressable progress){
  WorkerContext<MASTER_RESULT,WORKER_RESULT> context=buildContext();
  int firstIteration=context.getCurrentIteration() + 1;
  int iteration=context.getCurrentIteration();
  while (iteration < getTotalIteration()) {
    int currIter=iteration + 1;
    context.setCurrentIteration(currIter);
    iterate(context,firstIteration,progress);
    iteration=context.getCurrentIteration();
    MASTER_RESULT masterResult=context.getLastMasterResult();
    if ((masterResult instanceof HaltBytable) && ((HaltBytable)masterResult).isHalt()) {
      break;
    }
  }
}
Program: 80337
Project: 80337
Buggy source:
@Override public GuaguaWritableAdapter<LongWritable> doCompute(WorkerContext<GuaguaWritableAdapter<LongWritable>,GuaguaWritableAdapter<LongWritable>> context){
  long sum=context.getLastMasterResult() == null ? 0l : context.getLastMasterResult().getWritable().get();
  this.list.reOpen();
  for (  Long longValue : this.list) {
    sum+=longValue;
  }
  try {
    Thread.sleep(10 * 1000);
  }
 catch (  InterruptedException e) {
    e.printStackTrace();
  }
  LOG.info("String_Node_Str",context,sum);
  return new GuaguaWritableAdapter<LongWritable>(new LongWritable(sum));
}

Fixed version (ground truth):
@Override public GuaguaWritableAdapter<LongWritable> doCompute(WorkerContext<GuaguaWritableAdapter<LongWritable>,GuaguaWritableAdapter<LongWritable>> context){
  long sum=context.getLastMasterResult() == null ? 0l : context.getLastMasterResult().getWritable().get();
  this.list.reOpen();
  for (  Long longValue : this.list) {
    sum+=longValue;
  }
  LOG.info("String_Node_Str",context,sum);
  return new GuaguaWritableAdapter<LongWritable>(new LongWritable(sum));
}
Program: 80338
Project: 80338
Buggy source:
@Override protected void setUp() throws Exception {
  super.setUp();
  final String dexCache=getContext().getCacheDir().getPath();
  System.setProperty("String_Node_Str",dexCache);
  rootFile=new File(Environment.getExternalStorageDirectory(),"String_Node_Str");
  FileGenerator.generate(rootFile);
  driven=new ExternalDrive(rootFile.getAbsolutePath());
  Credential credential=new Credential(getContext());
  ExternalDriveFile.setStorageProvider(driven);
  driven.authenticate(credential);
  remoteDir=driven.get("String_Node_Str");
  remoteFile=driven.get(remoteDir,"String_Node_Str");
}

Fixed version (ground truth):
@Override protected void setUp() throws Exception {
  super.setUp();
  final String dexCache=getContext().getCacheDir().getPath();
  System.setProperty("String_Node_Str",dexCache);
  rootFile=new File(Environment.getExternalStorageDirectory(),"String_Node_Str");
  FileGenerator.generate(rootFile);
  driven=new ExternalDrive();
  Credential credential=new Credential(getContext(),rootFile.getAbsolutePath());
  ExternalDriveFile.setStorageProvider(driven);
  driven.authenticate(credential);
  remoteDir=driven.get("String_Node_Str");
  remoteFile=driven.get(remoteDir,"String_Node_Str");
}
Program: 80339
Project: 80339
Buggy source:
public void test_create_file() throws Exception {
  RemoteFile remoteFile=driven.get("String_Node_Str");
  LocalFile localFile=new LocalFile(new File(remoteFile.getId()));
  remoteFile=driven.create("String_Node_Str",localFile);
  assertNotNull(remoteFile);
  assertFalse(remoteFile.isDirectory());
  remoteFile=driven.id("String_Node_Str");
  assertNotNull(remoteFile);
  assertFalse(remoteFile.isDirectory());
}

Fixed version (ground truth):
public void test_create_file() throws Exception {
  driven.authenticate(credential);
  RemoteFile remoteFile=driven.get("String_Node_Str");
  LocalFile localFile=new LocalFile(new File(remoteFile.getId()));
  remoteFile=driven.create("String_Node_Str",localFile);
  assertNotNull(remoteFile);
  assertFalse(remoteFile.isDirectory());
  remoteFile=driven.id("String_Node_Str");
  assertNotNull(remoteFile);
  assertFalse(remoteFile.isDirectory());
}
Program: 80340
Project: 80340
Buggy source:
@Override protected void setUp() throws Exception {
  super.setUp();
  final String dexCache=getContext().getCacheDir().getPath();
  System.setProperty("String_Node_Str",dexCache);
  rootFile=new File(Environment.getExternalStorageDirectory(),"String_Node_Str");
  FileGenerator.generate(rootFile);
  driven=new ExternalDrive(rootFile.getAbsolutePath());
  credential=new Credential(getContext());
  FileGenerator.generate(rootFile);
}

Fixed version (ground truth):
@Override protected void setUp() throws Exception {
  super.setUp();
  final String dexCache=getContext().getCacheDir().getPath();
  System.setProperty("String_Node_Str",dexCache);
  rootFile=new File(Environment.getExternalStorageDirectory(),"String_Node_Str");
  FileGenerator.generate(rootFile);
  driven=new ExternalDrive();
  credential=new Credential(getContext(),rootFile.getAbsolutePath());
}
Program: 80341
Project: 80341
Buggy source:
public void test_createAsync_file() throws Exception {
  RemoteFile remoteFile=driven.get("String_Node_Str");
  LocalFile localFile=new LocalFile(new File(remoteFile.getId()));
  final CountDownLatch signal=new CountDownLatch(1);
  driven.createAsync("String_Node_Str",localFile,new Task<RemoteFile>(){
    @Override public void onCompleted(    RemoteFile result){
      assertNotNull(result);
      assertFalse(result.isDirectory());
      result=driven.id("String_Node_Str");
      assertNotNull(result);
      assertFalse(result.isDirectory());
      signal.countDown();
    }
  }
);
  signal.await();
}

Fixed version (ground truth):
public void test_createAsync_file() throws Exception {
  driven.authenticate(credential);
  RemoteFile remoteFile=driven.get("String_Node_Str");
  LocalFile localFile=new LocalFile(new File(remoteFile.getId()));
  final CountDownLatch signal=new CountDownLatch(1);
  driven.createAsync("String_Node_Str",localFile,new Task<RemoteFile>(){
    @Override public void onCompleted(    RemoteFile result){
      assertNotNull(result);
      assertFalse(result.isDirectory());
      result=driven.id("String_Node_Str");
      assertNotNull(result);
      assertFalse(result.isDirectory());
      signal.countDown();
    }
  }
);
  signal.await();
}
Program: 80342
Project: 80342
Buggy source:
public void test_create_fileInParent() throws Exception {
  RemoteFile remoteFile=driven.get("String_Node_Str");
  LocalFile localFile=new LocalFile(new File(remoteFile.getId()));
  driven.authenticate(credential);
  RemoteFile parent=driven.create("String_Node_Str");
  assertNotNull(parent);
  remoteFile=driven.create(parent,"String_Node_Str",localFile);
  assertNotNull(remoteFile);
  assertFalse(remoteFile.isDirectory());
}

Fixed version (ground truth):
public void test_create_fileInParent() throws Exception {
  driven.authenticate(credential);
  RemoteFile remoteFile=driven.get("String_Node_Str");
  LocalFile localFile=new LocalFile(new File(remoteFile.getId()));
  driven.authenticate(credential);
  RemoteFile parent=driven.create("String_Node_Str");
  assertNotNull(parent);
  remoteFile=driven.create(parent,"String_Node_Str",localFile);
  assertNotNull(remoteFile);
  assertFalse(remoteFile.isDirectory());
}
Program: 80343
Project: 80343
Buggy source:
public void test_createAsync_fileInParent() throws Exception {
  RemoteFile remoteFile=driven.get("String_Node_Str");
  LocalFile localFile=new LocalFile(new File(remoteFile.getId()));
  driven.authenticate(credential);
  RemoteFile parent=driven.create("String_Node_Str");
  assertNotNull(parent);
  final CountDownLatch signal=new CountDownLatch(1);
  driven.createAsync(parent,"String_Node_Str",localFile,new Task<RemoteFile>(){
    @Override public void onCompleted(    RemoteFile result){
      assertNotNull(result);
      assertFalse(result.isDirectory());
      signal.countDown();
    }
  }
);
  signal.await();
}

Fixed version (ground truth):
public void test_createAsync_fileInParent() throws Exception {
  driven.authenticate(credential);
  RemoteFile remoteFile=driven.get("String_Node_Str");
  LocalFile localFile=new LocalFile(new File(remoteFile.getId()));
  driven.authenticate(credential);
  RemoteFile parent=driven.create("String_Node_Str");
  assertNotNull(parent);
  final CountDownLatch signal=new CountDownLatch(1);
  driven.createAsync(parent,"String_Node_Str",localFile,new Task<RemoteFile>(){
    @Override public void onCompleted(    RemoteFile result){
      assertNotNull(result);
      assertFalse(result.isDirectory());
      signal.countDown();
    }
  }
);
  signal.await();
}
Program: 80344
Project: 80344
Buggy source:
@Override public boolean hasSavedCredentials(Context context){
  return true;
}

Fixed version (ground truth):
@Override public boolean hasSavedCredentials(Context context){
  Credential credential=new Credential(context);
  return credential.hasSavedCredential(TAG);
}
Program: 80345
Project: 80345
Buggy source:
@Override public Result<DrivenException> authenticate(Credential credential,boolean saveCredential){
  return new Result<DrivenException>();
}

Fixed version (ground truth):
@Override public Result<DrivenException> authenticate(Credential credential,boolean saveCredential){
  Log.i(TAG,"String_Node_Str");
  Result<DrivenException> result=new Result<DrivenException>(false);
  try {
    if (credential == null)     throw new DrivenException(new IllegalArgumentException("String_Node_Str"));
    if (credential.hasSavedCredential(TAG)) {
      credential.read(TAG);
    }
    root=new File(credential.getAccountName());
    IOUtils.safeCreateDir(root);
    userInfo=new ExternalDriveUserInfo();
    result.setSuccess(true);
    Log.i(TAG,"String_Node_Str" + userInfo);
    if (saveCredential)     credential.save(TAG);
  }
 catch (  Exception e) {
    Log.i(TAG,"String_Node_Str");
    Log.e(TAG,"String_Node_Str",e);
    result.setException(new DrivenException(e));
  }
  return result;
}
Program: 80346
Project: 80346
Buggy source:
@Override public boolean isAuthenticated(){
  return true;
}

Fixed version (ground truth):
@Override public boolean isAuthenticated(){
  return root != null && userInfo != null;
}
Program: 80347
Project: 80347
Buggy source:
@Override public UserInfo getDrivenUser(){
  return userInfo;
}

Fixed version (ground truth):
@Override public UserInfo getDrivenUser(){
  if (!isAuthenticated())   throw new DrivenException("String_Node_Str");
  return userInfo;
}
Program: 80348
Project: 80348
Buggy source:
/** 
 * Creates an external drive with path root
 * @param path the root
 */
public ExternalDrive(String path){
  root=new File(path);
  IOUtils.safeCreateDir(root);
  ExternalDriveFile.setStorageProvider(this);
}

Fixed version (ground truth):
public ExternalDrive(){
  ExternalDriveFile.setStorageProvider(this);
}
Program: 80349
Project: 80349
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  if (getIntent() != null) {
    String rootPath=getIntent().getStringExtra(BUNDLE_KEY_ROOT);
    if (rootPath != null) {
      storageProvider=new ExternalDrive(rootPath);
      successfullyAuthenticated();
      return;
    }
  }
  throw new DrivenException("String_Node_Str");
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  if (getIntent() != null) {
    String rootPath=getIntent().getStringExtra(BUNDLE_KEY_ROOT);
    if (rootPath != null) {
      storageProvider=new ExternalDrive();
      Result<DrivenException> result=storageProvider.authenticate(new Credential(this,rootPath));
      if (result.isSuccess()) {
        successfullyAuthenticated();
        return;
      }
 else {
        throw new DrivenException(result.getException());
      }
    }
  }
  throw new DrivenException("String_Node_Str");
}
Program: 80350
Project: 80350
Buggy source:
private void authenticate(){
  driven.authenticateAsync(credential,new Task.WithErrorReporting<Result<DrivenException>>(){
    @Override public void onCompleted(    Result<DrivenException> result){
      if (!result.isSuccess()) {
        driven.getDropboxApi().getSession().startOAuth2Authentication(DropboxActivity.this);
      }
 else {
        successfullyAuthorized();
      }
    }
    @Override public void onError(    Throwable error){
      Log.e(driven.getName(),error.getMessage(),error);
      finish();
    }
  }
);
}

Fixed version (ground truth):
private void authenticate(){
  driven.authenticateAsync(credential,new Task.WithErrorReporting<Result<DrivenException>>(){
    @Override public void onCompleted(    Result<DrivenException> result){
      if (!result.isSuccess()) {
        driven.getDropboxApi().getSession().startOAuth2Authentication(DropboxActivity.this);
      }
 else {
        successfullyAuthenticated();
      }
    }
    @Override public void onError(    Throwable error){
      Log.e(driven.getName(),error.getMessage(),error);
      finish();
    }
  }
);
}
Program: 80351
Project: 80351
Buggy source:
@Override public void onCompleted(Result<DrivenException> result){
  if (!result.isSuccess()) {
    driven.getDropboxApi().getSession().startOAuth2Authentication(DropboxActivity.this);
  }
 else {
    successfullyAuthorized();
  }
}

Fixed version (ground truth):
@Override public void onCompleted(Result<DrivenException> result){
  if (!result.isSuccess()) {
    driven.getDropboxApi().getSession().startOAuth2Authentication(DropboxActivity.this);
  }
 else {
    successfullyAuthenticated();
  }
}
Program: 80352
Project: 80352
Buggy source:
@Override protected void onResume(){
  super.onResume();
  try {
    if (driven.getDropboxApi().getSession().authenticationSuccessful()) {
      driven.getDropboxApi().getSession().finishAuthentication();
      credential.getToken().setAccessToken(driven.getDropboxApi().getSession().getOAuth2AccessToken());
    }
 else {
      finish();
    }
  }
 catch (  DrivenException e) {
    authenticate();
  }
}

Fixed version (ground truth):
@Override protected void onResume(){
  super.onResume();
  try {
    if (driven.getDropboxApi().getSession().authenticationSuccessful()) {
      driven.getDropboxApi().getSession().finishAuthentication();
      credential.getToken().setAccessToken(driven.getDropboxApi().getSession().getOAuth2AccessToken());
      successfullyAuthenticated();
    }
 else {
      finish();
    }
  }
 catch (  DrivenException e) {
    authenticate();
  }
}
Program: 80353
Project: 80353
Buggy source:
@Override public RemoteFile create(RemoteFile parent,LocalFile local){
  return create(local);
}

Fixed version (ground truth):
@Override public RemoteFile create(RemoteFile parent,LocalFile local){
  try {
    if (local.getName() == null)     throw new NullPointerException("String_Node_Str");
    InputStream input=getApiFactory().createInputStream(local.getFile());
    getDropboxApi().putFile(Path.combine(parent,local.getName()),input,local.getFile().length(),null,null);
    safeClose(input);
    return get(local.getName());
  }
 catch (  Exception e) {
    return null;
  }
}
Program: 80354
Project: 80354
Buggy source:
/** 
 * The name of this file
 */
public String getName();

Fixed version (ground truth):
/** 
 * The name of this file
 */
String getName();
Program: 80355
Project: 80355
Buggy source:
/** 
 * Fetch this file's complete metadata
 */
public boolean fetchDetails();

Fixed version (ground truth):
/** 
 * Fetch this file's complete metadata
 */
boolean fetchDetails();
Program: 80356
Project: 80356
Buggy source:
/** 
 * Upload/Save a file to this file. The remote content file will be overwritten by the   {@code content}
 */
public boolean upload(LocalFile local);

Fixed version (ground truth):
/** 
 * Upload/Save a file to this file. The remote content file will be overwritten by the   {@code content}
 */
boolean upload(LocalFile local);
Program: 80357
Project: 80357
Buggy source:
/** 
 * Async for   {@link #upload(com.bingzer.android.driven.LocalFile)}
 */
public void uploadAsync(LocalFile local,Task<Boolean> task);

Fixed version (ground truth):
/** 
 * Async for   {@link #upload(com.bingzer.android.driven.LocalFile)}
 */
void uploadAsync(LocalFile local,Task<Boolean> task);
Program: 80358
Project: 80358
Buggy source:
/** 
 * The unique identifier.
 */
public String getId();

Fixed version (ground truth):
/** 
 * The unique identifier.
 */
String getId();
Program: 80359
Project: 80359
Buggy source:
/** 
 * Async for   {@link #delete()}
 */
public void deleteAsync(Task<Boolean> task);

Fixed version (ground truth):
/** 
 * Async for   {@link #delete()}
 */
void deleteAsync(Task<Boolean> task);
Program: 80360
Project: 80360
Buggy source:
/** 
 * Async for   {@link #download(LocalFile)}
 */
public void downloadAsync(LocalFile local,Task<Boolean> task);

Fixed version (ground truth):
/** 
 * Async for   {@link #download(LocalFile)}
 */
void downloadAsync(LocalFile local,Task<Boolean> task);
Program: 80361
Project: 80361
Buggy source:
/** 
 * Async call for   {@link #rename(String)}
 */
public void renameAsync(String name,Task<Boolean> task);

Fixed version (ground truth):
/** 
 * Async call for   {@link #rename(String)}
 */
void renameAsync(String name,Task<Boolean> task);
Program: 80362
Project: 80362
Buggy source:
/** 
 * Async for   {@link #get(String)}
 */
public void getAsync(String name,Task<RemoteFile> task);

Fixed version (ground truth):
/** 
 * Async for   {@link #get(String)}
 */
void getAsync(String name,Task<RemoteFile> task);
Program: 80363
Project: 80363
Buggy source:
/** 
 * If this file is   {@link #isDirectory()} then thismethod should return all children within.
 */
public List<RemoteFile> list();

Fixed version (ground truth):
/** 
 * If this file is   {@link #isDirectory()} then thismethod should return all children within.
 */
List<RemoteFile> list();
Program: 80364
Project: 80364
Buggy source:
/** 
 * Delete or removes this file from remote provider.
 */
public boolean delete();

Fixed version (ground truth):
/** 
 * Delete or removes this file from remote provider.
 */
boolean delete();
Program: 80365
Project: 80365
Buggy source:
/** 
 * Download and keep this file to the local. There should be no local-to-remote mapping.
 */
public boolean download(LocalFile local);

Fixed version (ground truth):
/** 
 * Download and keep this file to the local. There should be no local-to-remote mapping.
 */
boolean download(LocalFile local);
Program: 80366
Project: 80366
Buggy source:
/** 
 * The public downloadable URL. Driven API should be able to use this URL to download this file on demand. It may or may not use authenticate scheme by the provider.
 */
public String getDownloadUrl();

Fixed version (ground truth):
/** 
 * The public downloadable URL. Driven API should be able to use this URL to download this file on demand. It may or may not use authenticate scheme by the provider.
 */
String getDownloadUrl();
Program: 80367
Project: 80367
Buggy source:
/** 
 * True if this file has "all" the details (metadata) provided by the provider.
 */
public boolean hasDetails();

Fixed version (ground truth):
/** 
 * True if this file has "all" the details (metadata) provided by the provider.
 */
boolean hasDetails();
Program: 80368
Project: 80368
Buggy source:
/** 
 * The MIME type of this file
 */
public String getType();

Fixed version (ground truth):
/** 
 * The MIME type of this file
 */
String getType();
Program: 80369
Project: 80369
Buggy source:
/** 
 * Rename the name of this file. True if successful, false otherwise
 */
public boolean rename(String name);

Fixed version (ground truth):
/** 
 * Rename the name of this file. True if successful, false otherwise
 */
boolean rename(String name);
Program: 80370
Project: 80370
Buggy source:
/** 
 * If this file is   {@link #isDirectory()} then thismethod should return a single children the specified  {@code name}
 */
public RemoteFile get(String name);

Fixed version (ground truth):
/** 
 * If this file is   {@link #isDirectory()} then thismethod should return a single children the specified  {@code name}
 */
RemoteFile get(String name);
Program: 80371
Project: 80371
Buggy source:
/** 
 * Share this file to other user. "Sharing" is generic and you should refer to the Provider's documentation
 */
public String share(String user,int kind);

Fixed version (ground truth):
/** 
 * Share this file to other user. "Sharing" is generic and you should refer to the Provider's documentation
 */
String share(String user,int kind);
Program: 80372
Project: 80372
Buggy source:
/** 
 * Async for   {@link #share(String,int)}
 */
public void shareAsync(String user,int kind,Task<String> task);

Fixed version (ground truth):
/** 
 * Async for   {@link #share(String,int)}
 */
void shareAsync(String user,int kind,Task<String> task);
Program: 80373
Project: 80373
Buggy source:
/** 
 * Async for   {@link #list()}
 */
public void listAsync(Task<List<RemoteFile>> task);

Fixed version (ground truth):
/** 
 * Async for   {@link #list()}
 */
void listAsync(Task<List<RemoteFile>> task);
Program: 80374
Project: 80374
Buggy source:
/** 
 * True if this file is a directory
 */
public boolean isDirectory();

Fixed version (ground truth):
/** 
 * True if this file is a directory
 */
boolean isDirectory();
Program: 80375
Project: 80375
Buggy source:
/** 
 * Async for   {@link #fetchDetails()}
 */
public void fetchDetailsAsync(Task<Boolean> task);

Fixed version (ground truth):
/** 
 * Async for   {@link #fetchDetails()}
 */
void fetchDetailsAsync(Task<Boolean> task);
Program: 80376
Project: 80376
Buggy source:
@Override protected void onResume(){
  super.onResume();
  try {
    if (driven.getDropboxApi().getSession().authenticationSuccessful()) {
      driven.getDropboxApi().getSession().finishAuthentication();
      credential.getToken().setAccessToken(driven.getDropboxApi().getSession().getOAuth2AccessToken());
      successfullyAuthenticated();
    }
 else {
      finish();
    }
  }
 catch (  DrivenException e) {
    authenticate();
  }
}

Fixed version (ground truth):
@Override protected void onResume(){
  super.onResume();
  try {
    if (driven.getDropboxApi().getSession().authenticationSuccessful()) {
      driven.getDropboxApi().getSession().finishAuthentication();
      credential.getToken().setAccessToken(driven.getDropboxApi().getSession().getOAuth2AccessToken());
      credential.save(driven.getName());
      successfullyAuthenticated();
    }
 else {
      finish();
    }
  }
 catch (  DrivenException e) {
    authenticate();
  }
}
Program: 80377
Project: 80377
Buggy source:
private void authenticate(){
  driven.authenticateAsync(credential,new Task<Result<DrivenException>>(){
    @Override public void onCompleted(    Result<DrivenException> result){
      if (!result.isSuccess()) {
        driven.getDropboxApi().getSession().startOAuth2Authentication(DropboxActivity.this);
      }
 else {
        successfullyAuthorized();
      }
    }
  }
);
}

Fixed version (ground truth):
private void authenticate(){
  driven.authenticateAsync(credential,new Task.WithErrorReporting<Result<DrivenException>>(){
    @Override public void onCompleted(    Result<DrivenException> result){
      if (!result.isSuccess()) {
        driven.getDropboxApi().getSession().startOAuth2Authentication(DropboxActivity.this);
      }
 else {
        successfullyAuthorized();
      }
    }
    @Override public void onError(    Throwable error){
      Log.e(driven.getName(),error.getMessage(),error);
      finish();
    }
  }
);
}
Program: 80378
Project: 80378
Buggy source:
@Override protected void onResume(){
  super.onResume();
  try {
    if (driven.getDropboxApi().getSession().authenticationSuccessful()) {
      driven.getDropboxApi().getSession().finishAuthentication();
      credential.getToken().setAccessToken(driven.getDropboxApi().getSession().getOAuth2AccessToken());
    }
  }
 catch (  DrivenException e) {
    authenticate();
  }
}

Fixed version (ground truth):
@Override protected void onResume(){
  super.onResume();
  try {
    if (driven.getDropboxApi().getSession().authenticationSuccessful()) {
      driven.getDropboxApi().getSession().finishAuthentication();
      credential.getToken().setAccessToken(driven.getDropboxApi().getSession().getOAuth2AccessToken());
    }
 else {
      finish();
    }
  }
 catch (  DrivenException e) {
    authenticate();
  }
}
Program: 80379
Project: 80379
Buggy source:
private void authenticate(){
  storageProvider.authenticateAsync(new Credential(this,googleAccount.getSelectedAccountName()),new Task<Result<DrivenException>>(){
    @Override public void onCompleted(    Result<DrivenException> result){
      if (result.isSuccess())       successfullyAuthenticated();
 else {
        if (result.getException().getCause() instanceof UserRecoverableAuthIOException) {
          UserRecoverableAuthIOException exception=(UserRecoverableAuthIOException)result.getException().getCause();
          startActivityForResult(exception.getIntent(),REQUEST_AUTHORIZATION);
        }
 else {
          throw result.getException();
        }
      }
    }
  }
);
}

Fixed version (ground truth):
private void authenticate(){
  Credential credential=new Credential(this,googleAccount.getSelectedAccountName());
  storageProvider.authenticateAsync(credential,new Task.WithErrorReporting<Result<DrivenException>>(){
    @Override public void onCompleted(    Result<DrivenException> result){
      if (result.isSuccess())       successfullyAuthenticated();
 else {
        if (result.getException().getCause() instanceof UserRecoverableAuthIOException) {
          UserRecoverableAuthIOException exception=(UserRecoverableAuthIOException)result.getException().getCause();
          startActivityForResult(exception.getIntent(),REQUEST_AUTHORIZATION);
        }
 else {
          onError(result.getException());
        }
      }
    }
    @Override public void onError(    Throwable error){
      Log.e(storageProvider.getName(),error.getMessage(),error);
      finish();
    }
  }
);
}
Program: 80380
Project: 80380
Buggy source:
@Override public void onCompleted(Result<DrivenException> result){
  if (result.isSuccess())   successfullyAuthenticated();
 else {
    if (result.getException().getCause() instanceof UserRecoverableAuthIOException) {
      UserRecoverableAuthIOException exception=(UserRecoverableAuthIOException)result.getException().getCause();
      startActivityForResult(exception.getIntent(),REQUEST_AUTHORIZATION);
    }
 else {
      throw result.getException();
    }
  }
}

Fixed version (ground truth):
@Override public void onCompleted(Result<DrivenException> result){
  if (result.isSuccess())   successfullyAuthenticated();
 else {
    if (result.getException().getCause() instanceof UserRecoverableAuthIOException) {
      UserRecoverableAuthIOException exception=(UserRecoverableAuthIOException)result.getException().getCause();
      startActivityForResult(exception.getIntent(),REQUEST_AUTHORIZATION);
    }
 else {
      onError(result.getException());
    }
  }
}