nus-yam/ex-repair huggingface dataset:
Program: 91310
Project: 91310
Buggy source:
/** 
 * Create reverse index from straight/forward pack index, by indexing all its entries.
 * @param packIndex forward index - entries to (reverse) index.
 */
public PackReverseIndex(final PackIndex packIndex){
  index=packIndex;
  final long cnt=index.getObjectCount();
  final long n64=index.getOffset64Count();
  final long n32=cnt - n64;
  if (n32 > Integer.MAX_VALUE || n64 > Integer.MAX_VALUE || cnt > 0xffffffffL)   throw new IllegalArgumentException(JGitText.get().hugeIndexesAreNotSupportedByJgitYet);
  offsets32=new int[(int)n32];
  offsets64=new long[(int)n64];
  nth32=new int[offsets32.length];
  nth64=new int[offsets64.length];
  int i32=0;
  int i64=0;
  for (  final MutableEntry me : index) {
    final long o=me.getOffset();
    if (o < Integer.MAX_VALUE)     offsets32[i32++]=(int)o;
 else     offsets64[i64++]=o;
  }
  Arrays.sort(offsets32);
  Arrays.sort(offsets64);
  int nth=0;
  for (  final MutableEntry me : index) {
    final long o=me.getOffset();
    if (o < Integer.MAX_VALUE)     nth32[Arrays.binarySearch(offsets32,(int)o)]=nth++;
 else     nth64[Arrays.binarySearch(offsets64,o)]=nth++;
  }
}

Fixed version (ground truth):
/** 
 * Create reverse index from straight/forward pack index, by indexing all its entries.
 * @param packIndex forward index - entries to (reverse) index.
 */
public PackReverseIndex(final PackIndex packIndex){
  index=packIndex;
  final long cnt=index.getObjectCount();
  final long n64=index.getOffset64Count();
  final long n32=cnt - n64;
  if (n32 > Integer.MAX_VALUE || n64 > Integer.MAX_VALUE || cnt > 0xffffffffL)   throw new IllegalArgumentException(JGitText.get().hugeIndexesAreNotSupportedByJgitYet);
  offsets32=new int[(int)n32];
  offsets64=new long[(int)n64];
  nth32=new int[offsets32.length];
  nth64=new int[offsets64.length];
  int i32=0;
  int i64=0;
  for (  final MutableEntry me : index) {
    final long o=me.getOffset();
    if (o <= Integer.MAX_VALUE)     offsets32[i32++]=(int)o;
 else     offsets64[i64++]=o;
  }
  Arrays.sort(offsets32);
  Arrays.sort(offsets64);
  int nth=0;
  for (  final MutableEntry me : index) {
    final long o=me.getOffset();
    if (o <= Integer.MAX_VALUE)     nth32[Arrays.binarySearch(offsets32,(int)o)]=nth++;
 else     nth64[Arrays.binarySearch(offsets64,o)]=nth++;
  }
}
Program: 91311
Project: 91311
Buggy source:
private String format(final boolean includePassword,boolean escapeNonAscii){
  final StringBuilder r=new StringBuilder();
  if (getScheme() != null) {
    r.append(getScheme());
    r.append("String_Node_Str");
  }
  if (getUser() != null) {
    r.append(escape(getUser(),true,escapeNonAscii));
    if (includePassword && getPass() != null) {
      r.append(':');
      r.append(escape(getPass(),true,escapeNonAscii));
    }
  }
  if (getHost() != null) {
    if (getUser() != null)     r.append('@');
    r.append(escape(getHost(),false,escapeNonAscii));
    if (getScheme() != null && getPort() > 0) {
      r.append(':');
      r.append(getPort());
    }
  }
  if (getPath() != null) {
    if (getScheme() != null) {
      if (!getPath().startsWith("String_Node_Str"))       r.append('/');
    }
 else     if (getHost() != null)     r.append(':');
    if (getScheme() != null)     if (escapeNonAscii)     r.append(escape(getPath(),false,escapeNonAscii));
 else     r.append(getRawPath());
 else     r.append(getPath());
  }
  return r.toString();
}

Fixed version (ground truth):
private String format(final boolean includePassword,boolean escapeNonAscii){
  final StringBuilder r=new StringBuilder();
  if (getScheme() != null) {
    r.append(getScheme());
    r.append("String_Node_Str");
  }
  if (getUser() != null) {
    r.append(escape(getUser(),true,escapeNonAscii));
    if (includePassword && getPass() != null) {
      r.append(':');
      r.append(escape(getPass(),true,escapeNonAscii));
    }
  }
  if (getHost() != null) {
    if (getUser() != null && getUser().length() > 0)     r.append('@');
    r.append(escape(getHost(),false,escapeNonAscii));
    if (getScheme() != null && getPort() > 0) {
      r.append(':');
      r.append(getPort());
    }
  }
  if (getPath() != null) {
    if (getScheme() != null) {
      if (!getPath().startsWith("String_Node_Str"))       r.append('/');
    }
 else     if (getHost() != null)     r.append(':');
    if (getScheme() != null)     if (escapeNonAscii)     r.append(escape(getPath(),false,escapeNonAscii));
 else     r.append(getRawPath());
 else     r.append(getPath());
  }
  return r.toString();
}
Program: 91312
Project: 91312
Buggy source:
/** 
 * Save the configuration as a Git text style configuration file. <p> <b>Warning:</b> Although this method uses the traditional Git file locking approach to protect against concurrent writes of the configuration file, it does not ensure that the file has not been modified since the last read, which means updates performed by other objects accessing the same backing file may be lost.
 * @throws IOException the file could not be written.
 */
public void save() throws IOException {
  final byte[] out;
  final String text=toText();
  if (utf8Bom) {
    final ByteArrayOutputStream bos=new ByteArrayOutputStream();
    bos.write(0xEF);
    bos.write(0xBB);
    bos.write(0xBF);
    bos.write(text.getBytes(RawParseUtils.UTF8_CHARSET));
    out=bos.toByteArray();
  }
 else {
    out=Constants.encode(text);
  }
  final LockFile lf=new LockFile(getFile(),fs);
  if (!lf.lock())   throw new LockFailedException(getFile());
  try {
    lf.setNeedSnapshot(true);
    lf.write(out);
    if (!lf.commit())     throw new IOException(MessageFormat.format(JGitText.get().cannotCommitWriteTo,getFile()));
  }
  finally {
    lf.unlock();
  }
  snapshot=lf.getCommitSnapshot();
  hash=hash(out);
  fireConfigChangedEvent();
}

Fixed version (ground truth):
/** 
 * Save the configuration as a Git text style configuration file. <p> <b>Warning:</b> Although this method uses the traditional Git file locking approach to protect against concurrent writes of the configuration file, it does not ensure that the file has not been modified since the last read, which means updates performed by other objects accessing the same backing file may be lost.
 * @throws IOException the file could not be written.
 */
public void save() throws IOException {
  final byte[] out;
  final String text=toText();
  if (utf8Bom) {
    final ByteArrayOutputStream bos=new ByteArrayOutputStream();
    bos.write(0xEF);
    bos.write(0xBB);
    bos.write(0xBF);
    bos.write(text.getBytes(RawParseUtils.UTF8_CHARSET.name()));
    out=bos.toByteArray();
  }
 else {
    out=Constants.encode(text);
  }
  final LockFile lf=new LockFile(getFile(),fs);
  if (!lf.lock())   throw new LockFailedException(getFile());
  try {
    lf.setNeedSnapshot(true);
    lf.write(out);
    if (!lf.commit())     throw new IOException(MessageFormat.format(JGitText.get().cannotCommitWriteTo,getFile()));
  }
  finally {
    lf.unlock();
  }
  snapshot=lf.getCommitSnapshot();
  hash=hash(out);
  fireConfigChangedEvent();
}
Program: 91314
Project: 91314
Buggy source:
/** 
 * Creates a new InputStream, wrapping the specified stream
 * @param in raw input stream
 */
public EolCanonicalizingInputStream(InputStream in,boolean detectBinary){
  this.in=in;
  this.detectBinary=detectBinary;
}

Fixed version (ground truth):
/** 
 * Creates a new InputStream, wrapping the specified stream
 * @param in raw input stream
 * @param detectBinary whether binaries should be detected
 */
public EolCanonicalizingInputStream(InputStream in,boolean detectBinary){
  this.in=in;
  this.detectBinary=detectBinary;
}
Program: 91315
Project: 91315
Buggy source:
@Test public void testSkip() throws IOException {
  final UnionInputStream u=new UnionInputStream();
  u.add(new ByteArrayInputStream(new byte[]{1,0,2}));
  u.add(new ByteArrayInputStream(new byte[]{3}));
  u.add(new ByteArrayInputStream(new byte[]{4,5}));
  assertEquals(0,u.skip(0));
  assertEquals(4,u.skip(4));
  assertEquals(4,u.read());
  assertEquals(1,u.skip(5));
  assertEquals(0,u.skip(5));
  assertEquals(-1,u.read());
  u.add(new ByteArrayInputStream(new byte[]{20,30}){
    public long skip(    long n){
      return 0;
    }
  }
);
  assertEquals(2,u.skip(8));
  assertEquals(-1,u.read());
}

Fixed version (ground truth):
@Test public void testSkip() throws IOException {
  final UnionInputStream u=new UnionInputStream();
  u.add(new ByteArrayInputStream(new byte[]{1,0,2}));
  u.add(new ByteArrayInputStream(new byte[]{3}));
  u.add(new ByteArrayInputStream(new byte[]{4,5}));
  assertEquals(0,u.skip(0));
  assertEquals(3,u.skip(3));
  assertEquals(3,u.read());
  assertEquals(2,u.skip(5));
  assertEquals(0,u.skip(5));
  assertEquals(-1,u.read());
  u.add(new ByteArrayInputStream(new byte[]{20,30}){
    public long skip(    long n){
      return 0;
    }
  }
);
  assertEquals(2,u.skip(8));
  assertEquals(-1,u.read());
}
Program: 91316
Project: 91316
Buggy source:
@Test public void testReadByteBlocks() throws IOException {
  final UnionInputStream u=new UnionInputStream();
  u.add(new ByteArrayInputStream(new byte[]{1,0,2}));
  u.add(new ByteArrayInputStream(new byte[]{3}));
  u.add(new ByteArrayInputStream(new byte[]{4,5}));
  final byte[] r=new byte[5];
  assertEquals(5,u.read(r,0,5));
  assertTrue(Arrays.equals(new byte[]{1,0,2,3,4},r));
  assertEquals(1,u.read(r,0,5));
  assertEquals(5,r[0]);
  assertEquals(-1,u.read(r,0,5));
}

Fixed version (ground truth):
@Test public void testReadByteBlocks() throws IOException {
  final UnionInputStream u=new UnionInputStream();
  u.add(new ByteArrayInputStream(new byte[]{1,0,2}));
  u.add(new ByteArrayInputStream(new byte[]{3}));
  u.add(new ByteArrayInputStream(new byte[]{4,5}));
  final byte[] r=new byte[5];
  assertEquals(3,u.read(r,0,5));
  assertTrue(Arrays.equals(new byte[]{1,0,2},slice(r,3)));
  assertEquals(1,u.read(r,0,5));
  assertEquals(3,r[0]);
  assertEquals(2,u.read(r,0,5));
  assertTrue(Arrays.equals(new byte[]{4,5},slice(r,2)));
  assertEquals(-1,u.read(r,0,5));
}
Program: 91317
Project: 91317
Buggy source:
@Test public void testArrayConstructor() throws IOException {
  final UnionInputStream u=new UnionInputStream(new ByteArrayInputStream(new byte[]{1,0,2}),new ByteArrayInputStream(new byte[]{3}),new ByteArrayInputStream(new byte[]{4,5}));
  final byte[] r=new byte[5];
  assertEquals(5,u.read(r,0,5));
  assertTrue(Arrays.equals(new byte[]{1,0,2,3,4},r));
  assertEquals(1,u.read(r,0,5));
  assertEquals(5,r[0]);
  assertEquals(-1,u.read(r,0,5));
}

Fixed version (ground truth):
@Test public void testArrayConstructor() throws IOException {
  final UnionInputStream u=new UnionInputStream(new ByteArrayInputStream(new byte[]{1,0,2}),new ByteArrayInputStream(new byte[]{3}),new ByteArrayInputStream(new byte[]{4,5}));
  final byte[] r=new byte[5];
  assertEquals(3,u.read(r,0,5));
  assertTrue(Arrays.equals(new byte[]{1,0,2},slice(r,3)));
  assertEquals(1,u.read(r,0,5));
  assertEquals(3,r[0]);
  assertEquals(2,u.read(r,0,5));
  assertTrue(Arrays.equals(new byte[]{4,5},slice(r,2)));
  assertEquals(-1,u.read(r,0,5));
}
Program: 91318
Project: 91318
Buggy source:
@Override public int read(byte[] b,int off,int len) throws IOException {
  int cnt=0;
  while (0 < len) {
    final InputStream in=head();
    final int n=in.read(b,off,len);
    if (0 < n) {
      cnt+=n;
      off+=n;
      len-=n;
    }
 else     if (in == EOF)     return 0 < cnt ? cnt : -1;
 else     pop();
  }
  return cnt;
}

Fixed version (ground truth):
@Override public int read(byte[] b,int off,int len) throws IOException {
  int cnt=0;
  while (0 < len) {
    final InputStream in=head();
    final int n=in.read(b,off,len);
    if (0 < n) {
      cnt+=n;
      off+=n;
      len-=n;
    }
 else     if (in == EOF)     return 0 < cnt ? cnt : -1;
 else {
      pop();
      if (0 < cnt)       break;
    }
  }
  return cnt;
}
Program: 91319
Project: 91319
Buggy source:
@Override public long skip(long len) throws IOException {
  long cnt=0;
  while (0 < len) {
    final InputStream in=head();
    final long n=in.skip(len);
    if (0 < n) {
      cnt+=n;
      len-=n;
    }
 else     if (in == EOF) {
      return cnt;
    }
 else {
      final int r=in.read();
      if (r < 0) {
        pop();
      }
 else {
        cnt+=1;
        len-=1;
      }
    }
  }
  return cnt;
}

Fixed version (ground truth):
@Override public long skip(long len) throws IOException {
  long cnt=0;
  while (0 < len) {
    final InputStream in=head();
    final long n=in.skip(len);
    if (0 < n) {
      cnt+=n;
      len-=n;
    }
 else     if (in == EOF) {
      return cnt;
    }
 else {
      final int r=in.read();
      if (r < 0) {
        pop();
        if (0 < cnt)         break;
      }
 else {
        cnt+=1;
        len-=1;
      }
    }
  }
  return cnt;
}
Program: 91320
Project: 91320
Buggy source:
/** 
 * Start a mutation task.
 * @param < T > any type the task might return.
 * @param task the mutation task. The result of the task is discarded, so callers should perform result validation within the task.
 * @param size number of bytes that are buffered within the task.
 * @throws DhtException a prior task has completed, and failed.
 */
protected <T>void start(final Callable<T> task,int size) throws DhtException {
  final int permits=permitsForSize(size);
  final Callable<T> op=new Callable<T>(){
    public T call() throws Exception {
      try {
        return task.call();
      }
  finally {
        spaceAvailable.release(permits);
      }
    }
  }
;
  if (flushing && finalTask == null) {
    finalTask=op;
    return;
  }
  if (!flushing)   checkRunningTasks(false);
  running.add(executor.submit(op));
}

Fixed version (ground truth):
/** 
 * Start a mutation task.
 * @param < T > any type the task might return.
 * @param task the mutation task. The result of the task is discarded, so callers should perform result validation within the task.
 * @param size number of bytes that are buffered within the task.
 * @throws DhtException a prior task has completed, and failed.
 */
protected <T>void start(final Callable<T> task,int size) throws DhtException {
  final int permits=permitsForSize(size);
  final Callable<T> op=new Callable<T>(){
    public T call() throws Exception {
      try {
        return task.call();
      }
  finally {
        spaceAvailable.release(permits);
      }
    }
  }
;
  if (flushing && finalTask == null) {
    finalTask=op;
    return;
  }
synchronized (runningLock) {
    if (!flushing)     checkRunningTasks(false);
    running.add(executor.submit(op));
  }
}
Program: 91321
Project: 91321
Buggy source:
public void flush() throws DhtException {
  try {
    flushing=true;
    if (0 < queuedCount) {
      startQueuedOperations(queuedCount);
      queuedCount=0;
    }
    if (finalTask != null) {
      try {
        waitFor(finalTask);
      }
  finally {
        finalTask=null;
      }
    }
    checkRunningTasks(true);
  }
  finally {
    flushing=false;
  }
}

Fixed version (ground truth):
public void flush() throws DhtException {
  try {
    flushing=true;
    if (0 < queuedCount) {
      startQueuedOperations(queuedCount);
      queuedCount=0;
    }
    if (finalTask != null) {
      try {
        waitFor(finalTask);
      }
  finally {
        finalTask=null;
      }
    }
synchronized (runningLock) {
      checkRunningTasks(true);
    }
  }
  finally {
    flushing=false;
  }
}
Program: 91322
Project: 91322
Buggy source:
/** 
 * Initialize a buffer with a backing executor service.
 * @param executor service to run mutation tasks on.
 * @param bufferSize maximum number of bytes to have pending at once.
 */
protected AbstractWriteBuffer(ExecutorService executor,int bufferSize){
  this.executor=executor;
  this.bufferSize=bufferSize;
  this.running=new LinkedList<Future<?>>();
  this.spaceAvailable=new Semaphore(bufferSize);
}

Fixed version (ground truth):
/** 
 * Initialize a buffer with a backing executor service.
 * @param executor service to run mutation tasks on.
 * @param bufferSize maximum number of bytes to have pending at once.
 */
protected AbstractWriteBuffer(ExecutorService executor,int bufferSize){
  this.executor=executor;
  this.bufferSize=bufferSize;
  this.running=new LinkedList<Future<?>>();
  this.runningLock=new Object();
  this.spaceAvailable=new Semaphore(bufferSize);
}
Program: 91323
Project: 91323
Buggy source:
public void abort() throws DhtException {
  checkRunningTasks(true);
}

Fixed version (ground truth):
public void abort() throws DhtException {
synchronized (runningLock) {
    checkRunningTasks(true);
  }
}
Program: 91324
Project: 91324
Buggy source:
/** 
 * Wrap a callback to update the buffer. <p> Flushing the buffer will wait for the returned callback to complete.
 * @param < T > any type the task might return.
 * @param callback callback invoked when the task has finished.
 * @param size number of bytes that are buffered within the task.
 * @return wrapped callback that will update the buffer state when thecallback is invoked.
 * @throws DhtException a prior task has completed, and failed.
 */
protected <T>AsyncCallback<T> wrap(final AsyncCallback<T> callback,int size) throws DhtException {
  int permits=permitsForSize(size);
  WrappedCallback<T> op=new WrappedCallback<T>(callback,permits);
  checkRunningTasks(false);
  running.add(op);
  return op;
}

Fixed version (ground truth):
/** 
 * Wrap a callback to update the buffer. <p> Flushing the buffer will wait for the returned callback to complete.
 * @param < T > any type the task might return.
 * @param callback callback invoked when the task has finished.
 * @param size number of bytes that are buffered within the task.
 * @return wrapped callback that will update the buffer state when thecallback is invoked.
 * @throws DhtException a prior task has completed, and failed.
 */
protected <T>AsyncCallback<T> wrap(final AsyncCallback<T> callback,int size) throws DhtException {
  int permits=permitsForSize(size);
  WrappedCallback<T> op=new WrappedCallback<T>(callback,permits);
synchronized (runningLock) {
    checkRunningTasks(false);
    running.add(op);
  }
  return op;
}
Program: 91325
Project: 91325
Buggy source:
@Test public void testEdit_InsertNearCommonTail(){
  EditList r=diff(t("String_Node_Str"),t("String_Node_Str"));
  assertEquals(new Edit(1,1,1,2),r.get(0));
  assertEquals(new Edit(3,3,4,7),r.get(1));
  assertEquals(2,r.size());
}

Fixed version (ground truth):
@Test public void testEdit_InsertNearCommonTail(){
  EditList r=diff(t("String_Node_Str"),t("String_Node_Str"));
  assertEquals(new Edit(1,1,1,2),r.get(0));
  assertEquals(new Edit(4,4,5,8),r.get(1));
  assertEquals(2,r.size());
}
Program: 91327
Project: 91327
Buggy source:
@Test public void testEdit_InsertNearCommonTail(){
  EditList r=diff(t("String_Node_Str"),t("String_Node_Str"));
  assertEquals(new Edit(1,1,1,2),r.get(0));
  assertEquals(new Edit(3,3,4,7),r.get(1));
  assertEquals(2,r.size());
}

Fixed version (ground truth):
@Test public void testEdit_InsertNearCommonTail(){
  EditList r=diff(t("String_Node_Str"),t("String_Node_Str"));
  assertEquals(new Edit(1,1,1,2),r.get(0));
  assertEquals(new Edit(4,4,5,8),r.get(1));
  assertEquals(2,r.size());
}
Program: 91329
Project: 91329
Buggy source:
static void sendError(int statusCode,HttpServletRequest req,HttpServletResponse rsp) throws IOException {
  String svc=req.getParameter("String_Node_Str");
  String accept=req.getHeader(HDR_ACCEPT);
  if (svc != null && svc.startsWith("String_Node_Str") && accept != null && accept.contains("String_Node_Str" + svc + "String_Node_Str")) {
    rsp.setContentType("String_Node_Str" + svc + "String_Node_Str");
    SmartOutputStream buf=new SmartOutputStream(req,rsp);
    PacketLineOut out=new PacketLineOut(buf);
    out.writeString("String_Node_Str" + svc + "String_Node_Str");
    out.end();
    out.writeString("String_Node_Str" + translate(statusCode));
    buf.close();
    return;
  }
  if (accept != null && accept.contains(UploadPackServlet.RSP_TYPE)) {
    rsp.setContentType(UploadPackServlet.RSP_TYPE);
    SmartOutputStream buf=new SmartOutputStream(req,rsp);
    PacketLineOut out=new PacketLineOut(buf);
    out.writeString("String_Node_Str" + translate(statusCode));
    buf.close();
    return;
  }
  rsp.sendError(statusCode);
}

Fixed version (ground truth):
static void sendError(int statusCode,HttpServletRequest req,HttpServletResponse rsp) throws IOException {
  String svc=req.getParameter("String_Node_Str");
  if (req.getRequestURI().endsWith("String_Node_Str") && isService(svc)) {
    rsp.setContentType("String_Node_Str" + svc + "String_Node_Str");
    SmartOutputStream buf=new SmartOutputStream(req,rsp);
    PacketLineOut out=new PacketLineOut(buf);
    out.writeString("String_Node_Str" + svc + "String_Node_Str");
    out.end();
    out.writeString("String_Node_Str" + translate(statusCode));
    buf.close();
    return;
  }
  String accept=req.getHeader(HDR_ACCEPT);
  if (accept != null && accept.contains(UploadPackServlet.RSP_TYPE)) {
    rsp.setContentType(UploadPackServlet.RSP_TYPE);
    SmartOutputStream buf=new SmartOutputStream(req,rsp);
    PacketLineOut out=new PacketLineOut(buf);
    out.writeString("String_Node_Str" + translate(statusCode));
    buf.close();
    return;
  }
  rsp.sendError(statusCode);
}
Program: 91330
Project: 91330
Buggy source:
static void sendError(int statusCode,HttpServletRequest req,HttpServletResponse rsp) throws IOException {
  String svc=req.getParameter("String_Node_Str");
  String accept=req.getHeader(HDR_ACCEPT);
  if (svc != null && svc.startsWith("String_Node_Str") && accept != null && accept.contains("String_Node_Str" + svc + "String_Node_Str")) {
    rsp.setContentType("String_Node_Str" + svc + "String_Node_Str");
    SmartOutputStream buf=new SmartOutputStream(req,rsp);
    PacketLineOut out=new PacketLineOut(buf);
    out.writeString("String_Node_Str" + svc + "String_Node_Str");
    out.end();
    out.writeString("String_Node_Str" + translate(statusCode));
    buf.close();
    return;
  }
  if (accept != null && accept.contains(UploadPackServlet.RSP_TYPE)) {
    rsp.setContentType(UploadPackServlet.RSP_TYPE);
    SmartOutputStream buf=new SmartOutputStream(req,rsp);
    PacketLineOut out=new PacketLineOut(buf);
    out.writeString("String_Node_Str" + translate(statusCode));
    buf.close();
    return;
  }
  rsp.sendError(statusCode);
}

Fixed version (ground truth):
static void sendError(int statusCode,HttpServletRequest req,HttpServletResponse rsp) throws IOException {
  String svc=req.getParameter("String_Node_Str");
  if (req.getRequestURI().endsWith("String_Node_Str") && isService(svc)) {
    rsp.setContentType("String_Node_Str" + svc + "String_Node_Str");
    SmartOutputStream buf=new SmartOutputStream(req,rsp);
    PacketLineOut out=new PacketLineOut(buf);
    out.writeString("String_Node_Str" + svc + "String_Node_Str");
    out.end();
    out.writeString("String_Node_Str" + translate(statusCode));
    buf.close();
    return;
  }
  String accept=req.getHeader(HDR_ACCEPT);
  if (accept != null && accept.contains(UploadPackServlet.RSP_TYPE)) {
    rsp.setContentType(UploadPackServlet.RSP_TYPE);
    SmartOutputStream buf=new SmartOutputStream(req,rsp);
    PacketLineOut out=new PacketLineOut(buf);
    out.writeString("String_Node_Str" + translate(statusCode));
    buf.close();
    return;
  }
  rsp.sendError(statusCode);
}
Program: 91333
Project: 91333
Buggy source:
/** 
 * @return a list of updated pathes and objectIds
 */
public Map<String,ObjectId> getUpdated(){
  return updated;
}

Fixed version (ground truth):
/** 
 * @return a list of updated paths and objectIds
 */
public Map<String,ObjectId> getUpdated(){
  return updated;
}
Program: 91334
Project: 91334
Buggy source:
@Override protected boolean mergeImpl() throws IOException {
  boolean implicitDirCache=false;
  if (dircache == null) {
    dircache=getRepository().lockDirCache();
    implicitDirCache=true;
  }
  try {
    builder=dircache.builder();
    DirCacheBuildIterator buildIt=new DirCacheBuildIterator(builder);
    tw=new NameConflictTreeWalk(db);
    tw.addTree(mergeBase());
    tw.addTree(sourceTrees[0]);
    tw.addTree(sourceTrees[1]);
    tw.addTree(buildIt);
    if (workingTreeIterator != null)     tw.addTree(workingTreeIterator);
    while (tw.next()) {
      if (!processEntry(tw.getTree(T_BASE,CanonicalTreeParser.class),tw.getTree(T_OURS,CanonicalTreeParser.class),tw.getTree(T_THEIRS,CanonicalTreeParser.class),tw.getTree(T_INDEX,DirCacheBuildIterator.class),(workingTreeIterator == null) ? null : tw.getTree(T_FILE,WorkingTreeIterator.class))) {
        cleanUp();
        return false;
      }
      if (tw.isSubtree() && enterSubtree)       tw.enterSubtree();
    }
    if (!inCore) {
      if (!builder.commit()) {
        cleanUp();
        throw new IndexWriteException();
      }
      builder=null;
      checkout();
    }
 else {
      builder.finish();
      builder=null;
    }
    if (getUnmergedPathes().isEmpty()) {
      resultTree=dircache.writeTree(oi);
      return true;
    }
 else {
      resultTree=null;
      return false;
    }
  }
  finally {
    if (implicitDirCache)     dircache.unlock();
  }
}

Fixed version (ground truth):
@Override protected boolean mergeImpl() throws IOException {
  boolean implicitDirCache=false;
  if (dircache == null) {
    dircache=getRepository().lockDirCache();
    implicitDirCache=true;
  }
  try {
    builder=dircache.builder();
    DirCacheBuildIterator buildIt=new DirCacheBuildIterator(builder);
    tw=new NameConflictTreeWalk(db);
    tw.addTree(mergeBase());
    tw.addTree(sourceTrees[0]);
    tw.addTree(sourceTrees[1]);
    tw.addTree(buildIt);
    if (workingTreeIterator != null)     tw.addTree(workingTreeIterator);
    while (tw.next()) {
      if (!processEntry(tw.getTree(T_BASE,CanonicalTreeParser.class),tw.getTree(T_OURS,CanonicalTreeParser.class),tw.getTree(T_THEIRS,CanonicalTreeParser.class),tw.getTree(T_INDEX,DirCacheBuildIterator.class),(workingTreeIterator == null) ? null : tw.getTree(T_FILE,WorkingTreeIterator.class))) {
        cleanUp();
        return false;
      }
      if (tw.isSubtree() && enterSubtree)       tw.enterSubtree();
    }
    if (!inCore) {
      if (!builder.commit()) {
        cleanUp();
        throw new IndexWriteException();
      }
      builder=null;
      checkout();
    }
 else {
      builder.finish();
      builder=null;
    }
    if (getUnmergedPaths().isEmpty()) {
      resultTree=dircache.writeTree(oi);
      return true;
    }
 else {
      resultTree=null;
      return false;
    }
  }
  finally {
    if (implicitDirCache)     dircache.unlock();
  }
}
Program: 91335
Project: 91335
Buggy source:
/** 
 * @return the paths of files which have been modified by this merge. Afile will be modified if a content-merge works on this path or if the merge algorithm decides to take the theirs-version. This is a superset of the files listed by  {@link #getUnmergedPathes()}.
 */
public List<String> getModifiedFiles(){
  return modifiedFiles;
}

Fixed version (ground truth):
/** 
 * @return the paths of files which have been modified by this merge. Afile will be modified if a content-merge works on this path or if the merge algorithm decides to take the theirs-version. This is a superset of the files listed by  {@link #getUnmergedPaths()}.
 */
public List<String> getModifiedFiles(){
  return modifiedFiles;
}
Program: 91337
Project: 91337
Buggy source:
private void checkout() throws NoWorkTreeException, IOException {
  for (  Map.Entry<String,DirCacheEntry> entry : toBeCheckedOut.entrySet()) {
    File f=new File(db.getWorkTree(),entry.getKey());
    if (entry.getValue() != null) {
      createDir(f.getParentFile());
      DirCacheCheckout.checkoutEntry(db,f,entry.getValue());
    }
 else {
      if (!f.delete())       failingPathes.put(entry.getKey(),MergeFailureReason.COULD_NOT_DELETE);
    }
    modifiedFiles.add(entry.getKey());
  }
}

Fixed version (ground truth):
private void checkout() throws NoWorkTreeException, IOException {
  for (  Map.Entry<String,DirCacheEntry> entry : toBeCheckedOut.entrySet()) {
    File f=new File(db.getWorkTree(),entry.getKey());
    if (entry.getValue() != null) {
      createDir(f.getParentFile());
      DirCacheCheckout.checkoutEntry(db,f,entry.getValue());
    }
 else {
      if (!f.delete())       failingPaths.put(entry.getKey(),MergeFailureReason.COULD_NOT_DELETE);
    }
    modifiedFiles.add(entry.getKey());
  }
}
Program: 91344
Project: 91344
Buggy source:
@Override public byte[] idBuffer(){
  if (currentSubtree != null)   return subtreeId;
  if (currentEntry != null)   return currentEntry.idBuffer();
  return zeroid;
}

Fixed version (ground truth):
@Override public byte[] idBuffer(){
  if (currentSubtree != null)   return currentSubtree.isValid() ? subtreeId : zeroid;
  if (currentEntry != null)   return currentEntry.idBuffer();
  return zeroid;
}
Program: 91345
Project: 91345
Buggy source:
private void parseEntry(){
  currentEntry=cache.getEntry(ptr);
  final byte[] cep=currentEntry.path;
  if (nextSubtreePos != tree.getChildCount()) {
    final DirCacheTree s=tree.getChild(nextSubtreePos);
    if (s.contains(cep,pathOffset,cep.length)) {
      currentSubtree=s;
      nextSubtreePos++;
      if (s.isValid())       s.getObjectId().copyRawTo(subtreeId,0);
 else       Arrays.fill(subtreeId,(byte)0);
      mode=FileMode.TREE.getBits();
      path=cep;
      pathLen=pathOffset + s.nameLength();
      return;
    }
  }
  mode=currentEntry.getRawMode();
  path=cep;
  pathLen=cep.length;
  currentSubtree=null;
}

Fixed version (ground truth):
private void parseEntry(){
  currentEntry=cache.getEntry(ptr);
  final byte[] cep=currentEntry.path;
  if (nextSubtreePos != tree.getChildCount()) {
    final DirCacheTree s=tree.getChild(nextSubtreePos);
    if (s.contains(cep,pathOffset,cep.length)) {
      currentSubtree=s;
      nextSubtreePos++;
      if (s.isValid())       s.getObjectId().copyRawTo(subtreeId,0);
      mode=FileMode.TREE.getBits();
      path=cep;
      pathLen=pathOffset + s.nameLength();
      return;
    }
  }
  mode=currentEntry.getRawMode();
  path=cep;
  pathLen=cep.length;
  currentSubtree=null;
}
Program: 91346
Project: 91346
Buggy source:
/** 
 * Compare two tree's current ObjectId values for equality.
 * @param nthA first tree to compare the object id from.
 * @param nthB second tree to compare the object id from.
 * @return result of<code>getObjectId(nthA).equals(getObjectId(nthB))</code>.
 * @see #getObjectId(int)
 */
public boolean idEqual(final int nthA,final int nthB){
  final AbstractTreeIterator ch=currentHead;
  final AbstractTreeIterator a=trees[nthA];
  final AbstractTreeIterator b=trees[nthB];
  if (a.matches == ch && b.matches == ch)   return a.idEqual(b);
  if (a.matches != ch && b.matches != ch) {
    return true;
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Compare two tree's current ObjectId values for equality.
 * @param nthA first tree to compare the object id from.
 * @param nthB second tree to compare the object id from.
 * @return result of<code>getObjectId(nthA).equals(getObjectId(nthB))</code>.
 * @see #getObjectId(int)
 */
public boolean idEqual(final int nthA,final int nthB){
  final AbstractTreeIterator ch=currentHead;
  final AbstractTreeIterator a=trees[nthA];
  final AbstractTreeIterator b=trees[nthB];
  if (a.matches != ch && b.matches != ch) {
    return true;
  }
  if (!a.hasId() || !b.hasId())   return false;
  if (a.matches == ch && b.matches == ch)   return a.idEqual(b);
  return false;
}
Program: 91347
Project: 91347
Buggy source:
private static int common(long[] srcHash,int srcIdx,long[] dstHash,int dstIdx){
  if (srcIdx == srcHash.length || dstIdx == dstHash.length)   return 0;
  int common=0;
  int srcKey=keyOf(srcHash[srcIdx]);
  int dstKey=keyOf(dstHash[dstIdx]);
  for (; ; ) {
    if (srcKey == dstKey) {
      common+=countOf(dstHash[dstIdx]);
      if (++srcIdx == srcHash.length)       break;
      srcKey=keyOf(srcHash[srcIdx]);
      if (++dstIdx == dstHash.length)       break;
      dstKey=keyOf(dstHash[dstIdx]);
    }
 else     if (srcKey < dstKey) {
      if (++srcIdx == srcHash.length)       break;
      srcKey=keyOf(srcHash[srcIdx]);
    }
 else {
      if (++dstIdx == dstHash.length)       break;
      dstKey=keyOf(dstHash[dstIdx]);
    }
  }
  return common;
}

Fixed version (ground truth):
private static int common(long[] srcHash,int srcIdx,long[] dstHash,int dstIdx){
  if (srcIdx == srcHash.length || dstIdx == dstHash.length)   return 0;
  int common=0;
  int srcKey=keyOf(srcHash[srcIdx]);
  int dstKey=keyOf(dstHash[dstIdx]);
  for (; ; ) {
    if (srcKey == dstKey) {
      common+=Math.min(countOf(srcHash[srcIdx]),countOf(dstHash[dstIdx]));
      if (++srcIdx == srcHash.length)       break;
      srcKey=keyOf(srcHash[srcIdx]);
      if (++dstIdx == dstHash.length)       break;
      dstKey=keyOf(dstHash[dstIdx]);
    }
 else     if (srcKey < dstKey) {
      if (++srcIdx == srcHash.length)       break;
      srcKey=keyOf(srcHash[srcIdx]);
    }
 else {
      if (++dstIdx == dstHash.length)       break;
      dstKey=keyOf(dstHash[dstIdx]);
    }
  }
  return common;
}
Program: 91348
Project: 91348
Buggy source:
private void inflate(final Source src,final long inflatedSize,final byte[] dst,final boolean keep) throws IOException {
  final Inflater inf=inflater;
  try {
    int off=0;
    long cnt=0;
    int p=fill(src,24);
    inf.setInput(buf,p,bAvail);
    do {
      int r=inf.inflate(dst,off,dst.length - off);
      if (r == 0) {
        if (inf.finished())         break;
        if (inf.needsInput()) {
          if (p >= 0) {
            crc.update(buf,p,bAvail);
            use(bAvail);
          }
          p=fill(src,24);
          inf.setInput(buf,p,bAvail);
        }
 else {
          throw new CorruptObjectException(MessageFormat.format(JGitText.get().packfileCorruptionDetected,JGitText.get().unknownZlibError));
        }
      }
      cnt+=r;
      if (keep)       off+=r;
    }
 while (cnt < inflatedSize);
    if (!inf.finished() || cnt != inflatedSize) {
      throw new CorruptObjectException(MessageFormat.format(JGitText.get().packfileCorruptionDetected,JGitText.get().wrongDecompressedLength));
    }
    int left=bAvail - inf.getRemaining();
    if (left > 0) {
      crc.update(buf,p,left);
      use(left);
    }
  }
 catch (  DataFormatException dfe) {
    throw new CorruptObjectException(MessageFormat.format(JGitText.get().packfileCorruptionDetected,dfe.getMessage()));
  }
 finally {
    inf.reset();
  }
}

Fixed version (ground truth):
private void inflate(final Source src,final long inflatedSize,final byte[] dst,final boolean keep) throws IOException {
  final Inflater inf=inflater;
  try {
    int off=0;
    long cnt=0;
    int p=fill(src,24);
    inf.setInput(buf,p,bAvail);
    for (; ; ) {
      int r=inf.inflate(dst,off,dst.length - off);
      if (r == 0) {
        if (inf.finished())         break;
        if (inf.needsInput()) {
          if (p >= 0) {
            crc.update(buf,p,bAvail);
            use(bAvail);
          }
          p=fill(src,24);
          inf.setInput(buf,p,bAvail);
        }
 else {
          throw new CorruptObjectException(MessageFormat.format(JGitText.get().packfileCorruptionDetected,JGitText.get().unknownZlibError));
        }
      }
      cnt+=r;
      if (keep)       off+=r;
    }
    if (cnt != inflatedSize) {
      throw new CorruptObjectException(MessageFormat.format(JGitText.get().packfileCorruptionDetected,JGitText.get().wrongDecompressedLength));
    }
    int left=bAvail - inf.getRemaining();
    if (left > 0) {
      crc.update(buf,p,left);
      use(left);
    }
  }
 catch (  DataFormatException dfe) {
    throw new CorruptObjectException(MessageFormat.format(JGitText.get().packfileCorruptionDetected,dfe.getMessage()));
  }
 finally {
    inf.reset();
  }
}
Program: 91350
Project: 91350
Buggy source:
@Override protected void setUp() throws Exception {
  super.setUp();
  if (shutdownHook == null) {
    shutdownHook=new Thread(){
      @Override public void run(){
        System.gc();
        recursiveDelete("String_Node_Str",trash,false,false);
      }
    }
;
    Runtime.getRuntime().addShutdownHook(shutdownHook);
  }
  recursiveDelete(testName(),trash,true,false);
  mockSystemReader=new MockSystemReader();
  mockSystemReader.userGitConfig=new FileBasedConfig(new File(trash,"String_Node_Str"));
  ceilTestDirectories(getCeilings());
  SystemReader.setInstance(mockSystemReader);
  final long now=mockSystemReader.getCurrentTime();
  final int tz=mockSystemReader.getTimezone(now);
  author=new PersonIdent("String_Node_Str","String_Node_Str");
  author=new PersonIdent(author,now,tz);
  committer=new PersonIdent("String_Node_Str","String_Node_Str");
  committer=new PersonIdent(committer,now,tz);
  final WindowCacheConfig c=new WindowCacheConfig();
  c.setPackedGitLimit(128 * WindowCacheConfig.KB);
  c.setPackedGitWindowSize(8 * WindowCacheConfig.KB);
  c.setPackedGitMMAP(useMMAP);
  c.setDeltaBaseCacheLimit(8 * WindowCacheConfig.KB);
  WindowCache.reconfigure(c);
}

Fixed version (ground truth):
@Override protected void setUp() throws Exception {
  super.setUp();
  if (shutdownHook == null) {
    shutdownHook=new Thread(){
      @Override public void run(){
        System.gc();
        recursiveDelete("String_Node_Str",trash,false,false);
      }
    }
;
    Runtime.getRuntime().addShutdownHook(shutdownHook);
  }
  recursiveDelete(testName(),trash,true,false);
  mockSystemReader=new MockSystemReader();
  mockSystemReader.userGitConfig=new FileBasedConfig(new File(trash,"String_Node_Str"),FS.DETECTED);
  ceilTestDirectories(getCeilings());
  SystemReader.setInstance(mockSystemReader);
  final long now=mockSystemReader.getCurrentTime();
  final int tz=mockSystemReader.getTimezone(now);
  author=new PersonIdent("String_Node_Str","String_Node_Str");
  author=new PersonIdent(author,now,tz);
  committer=new PersonIdent("String_Node_Str","String_Node_Str");
  committer=new PersonIdent(committer,now,tz);
  final WindowCacheConfig c=new WindowCacheConfig();
  c.setPackedGitLimit(128 * WindowCacheConfig.KB);
  c.setPackedGitWindowSize(8 * WindowCacheConfig.KB);
  c.setPackedGitMMAP(useMMAP);
  c.setDeltaBaseCacheLimit(8 * WindowCacheConfig.KB);
  WindowCache.reconfigure(c);
}
Program: 91351
Project: 91351
Buggy source:
public MockSystemReader(){
  init(Constants.OS_USER_NAME_KEY);
  init(Constants.GIT_AUTHOR_NAME_KEY);
  init(Constants.GIT_AUTHOR_EMAIL_KEY);
  init(Constants.GIT_COMMITTER_NAME_KEY);
  init(Constants.GIT_COMMITTER_EMAIL_KEY);
  userGitConfig=new FileBasedConfig(null){
    @Override public void load() throws IOException, ConfigInvalidException {
    }
    @Override public boolean isOutdated(){
      return false;
    }
  }
;
}

Fixed version (ground truth):
public MockSystemReader(){
  init(Constants.OS_USER_NAME_KEY);
  init(Constants.GIT_AUTHOR_NAME_KEY);
  init(Constants.GIT_AUTHOR_EMAIL_KEY);
  init(Constants.GIT_COMMITTER_NAME_KEY);
  init(Constants.GIT_COMMITTER_EMAIL_KEY);
  userGitConfig=new FileBasedConfig(null,null){
    @Override public void load() throws IOException, ConfigInvalidException {
    }
    @Override public boolean isOutdated(){
      return false;
    }
  }
;
}
Program: 91352
Project: 91352
Buggy source:
private void writeFile(final File p,final byte[] bin) throws IOException, ObjectWritingException {
  final LockFile lck=new LockFile(p);
  if (!lck.lock())   throw new ObjectWritingException("String_Node_Str" + p);
  try {
    lck.write(bin);
  }
 catch (  IOException ioe) {
    throw new ObjectWritingException("String_Node_Str" + p);
  }
  if (!lck.commit())   throw new ObjectWritingException("String_Node_Str" + p);
}

Fixed version (ground truth):
private void writeFile(final File p,final byte[] bin) throws IOException, ObjectWritingException {
  final LockFile lck=new LockFile(p,db.getFS());
  if (!lck.lock())   throw new ObjectWritingException("String_Node_Str" + p);
  try {
    lck.write(bin);
  }
 catch (  IOException ioe) {
    throw new ObjectWritingException("String_Node_Str" + p);
  }
  if (!lck.commit())   throw new ObjectWritingException("String_Node_Str" + p);
}
Program: 91353
Project: 91353
Buggy source:
private void detachHead() throws IOException {
  final String head=db.getFullBranch();
  final ObjectId id=db.resolve(Constants.HEAD);
  if (!ObjectId.isId(head) && id != null) {
    final LockFile lf;
    lf=new LockFile(new File(db.getDirectory(),Constants.HEAD));
    if (!lf.lock())     throw new IOException(MessageFormat.format(CLIText.get().cannotLock,Constants.HEAD));
    lf.write(id);
    if (!lf.commit())     throw new IOException(CLIText.get().cannotDeatchHEAD);
  }
}

Fixed version (ground truth):
private void detachHead() throws IOException {
  final String head=db.getFullBranch();
  final ObjectId id=db.resolve(Constants.HEAD);
  if (!ObjectId.isId(head) && id != null) {
    final LockFile lf;
    lf=new LockFile(new File(db.getDirectory(),Constants.HEAD),db.getFS());
    if (!lf.lock())     throw new IOException(MessageFormat.format(CLIText.get().cannotLock,Constants.HEAD));
    lf.write(id);
    if (!lf.commit())     throw new IOException(CLIText.get().cannotDeatchHEAD);
  }
}
Program: 91354
Project: 91354
Buggy source:
@Override protected void writeFile(final String name,final byte[] content) throws IOException {
  final File file=new File(db.getDirectory(),name);
  final LockFile lck=new LockFile(file);
  if (!lck.lock())   throw new ObjectWritingException(MessageFormat.format(CLIText.get().cantWrite,file));
  try {
    lck.write(content);
  }
 catch (  IOException ioe) {
    throw new ObjectWritingException(MessageFormat.format(CLIText.get().cantWrite,file));
  }
  if (!lck.commit())   throw new ObjectWritingException(MessageFormat.format(CLIText.get().cantWrite,file));
}

Fixed version (ground truth):
@Override protected void writeFile(final String name,final byte[] content) throws IOException {
  final File file=new File(db.getDirectory(),name);
  final LockFile lck=new LockFile(file,db.getFS());
  if (!lck.lock())   throw new ObjectWritingException(MessageFormat.format(CLIText.get().cantWrite,file));
  try {
    lck.write(content);
  }
 catch (  IOException ioe) {
    throw new ObjectWritingException(MessageFormat.format(CLIText.get().cantWrite,file));
  }
  if (!lck.commit())   throw new ObjectWritingException(MessageFormat.format(CLIText.get().cantWrite,file));
}
Program: 91355
Project: 91355
Buggy source:
private void recreateRefs() throws Exception {
  final Map<String,Ref> refs=computeNewRefs();
  new RefWriter(refs.values()){
    @Override protected void writeFile(    final String name,    final byte[] content) throws IOException {
      final File file=new File(db.getDirectory(),name);
      final LockFile lck=new LockFile(file);
      if (!lck.lock())       throw new ObjectWritingException(MessageFormat.format(CLIText.get().cantWrite,file));
      try {
        lck.write(content);
      }
 catch (      IOException ioe) {
        throw new ObjectWritingException(MessageFormat.format(CLIText.get().cantWrite,file));
      }
      if (!lck.commit())       throw new ObjectWritingException(MessageFormat.format(CLIText.get().cantWrite,file));
    }
  }
.writePackedRefs();
}

Fixed version (ground truth):
private void recreateRefs() throws Exception {
  final Map<String,Ref> refs=computeNewRefs();
  new RefWriter(refs.values()){
    @Override protected void writeFile(    final String name,    final byte[] content) throws IOException {
      final File file=new File(db.getDirectory(),name);
      final LockFile lck=new LockFile(file,db.getFS());
      if (!lck.lock())       throw new ObjectWritingException(MessageFormat.format(CLIText.get().cantWrite,file));
      try {
        lck.write(content);
      }
 catch (      IOException ioe) {
        throw new ObjectWritingException(MessageFormat.format(CLIText.get().cantWrite,file));
      }
      if (!lck.commit())       throw new ObjectWritingException(MessageFormat.format(CLIText.get().cantWrite,file));
    }
  }
.writePackedRefs();
}
Program: 91356
Project: 91356
Buggy source:
@Override protected void run() throws Exception {
  if (CookieHandler.getDefault() == null)   CookieHandler.setDefault(new SimpleCookieManager());
  final IpLogGenerator log=new IpLogGenerator();
  if (commitId == null) {
    System.err.println(MessageFormat.format(CLIText.get().warningNoCommitGivenOnCommandLine,Constants.HEAD));
    commitId=db.resolve(Constants.HEAD);
  }
  final RevWalk rw=new RevWalk(db);
  final RevObject start=rw.parseAny(commitId);
  if (version == null && start instanceof RevTag)   version=((RevTag)start).getTagName();
 else   if (version == null)   throw die(MessageFormat.format(CLIText.get().notATagVersionIsRequired,start.name()));
  log.scan(db,rw.parseCommit(start),version);
  if (output != null) {
    if (!output.getParentFile().exists())     output.getParentFile().mkdirs();
    LockFile lf=new LockFile(output);
    if (!lf.lock())     throw die(MessageFormat.format(CLIText.get().cannotLock,output));
    try {
      OutputStream os=lf.getOutputStream();
      try {
        log.writeTo(os);
      }
  finally {
        os.close();
      }
      if (!lf.commit())       throw die(MessageFormat.format(CLIText.get().cannotWrite,output));
    }
  finally {
      lf.unlock();
    }
  }
 else {
    log.writeTo(System.out);
    System.out.flush();
  }
}

Fixed version (ground truth):
@Override protected void run() throws Exception {
  if (CookieHandler.getDefault() == null)   CookieHandler.setDefault(new SimpleCookieManager());
  final IpLogGenerator log=new IpLogGenerator();
  if (commitId == null) {
    System.err.println(MessageFormat.format(CLIText.get().warningNoCommitGivenOnCommandLine,Constants.HEAD));
    commitId=db.resolve(Constants.HEAD);
  }
  final RevWalk rw=new RevWalk(db);
  final RevObject start=rw.parseAny(commitId);
  if (version == null && start instanceof RevTag)   version=((RevTag)start).getTagName();
 else   if (version == null)   throw die(MessageFormat.format(CLIText.get().notATagVersionIsRequired,start.name()));
  log.scan(db,rw.parseCommit(start),version);
  if (output != null) {
    if (!output.getParentFile().exists())     output.getParentFile().mkdirs();
    LockFile lf=new LockFile(output,db.getFS());
    if (!lf.lock())     throw die(MessageFormat.format(CLIText.get().cannotLock,output));
    try {
      OutputStream os=lf.getOutputStream();
      try {
        log.writeTo(os);
      }
  finally {
        os.close();
      }
      if (!lf.commit())       throw die(MessageFormat.format(CLIText.get().cannotWrite,output));
    }
  finally {
      lf.unlock();
    }
  }
 else {
    log.writeTo(System.out);
    System.out.flush();
  }
}
Program: 91357
Project: 91357
Buggy source:
@Override protected void run() throws Exception {
  if (CookieHandler.getDefault() == null)   CookieHandler.setDefault(new SimpleCookieManager());
  final URL ipzilla=new URL(url);
  if (username == null) {
    final PasswordAuthentication auth=Authenticator.requestPasswordAuthentication(ipzilla.getHost(),null,ipzilla.getPort(),ipzilla.getProtocol(),CLIText.get().IPZillaPasswordPrompt,ipzilla.getProtocol(),ipzilla,Authenticator.RequestorType.SERVER);
    username=auth.getUserName();
    password=new String(auth.getPassword());
  }
  if (output == null)   output=new File(db.getWorkTree(),IpLogMeta.IPLOG_CONFIG_FILE);
  IpLogMeta meta=new IpLogMeta();
  meta.syncCQs(output,ipzilla,username,password);
}

Fixed version (ground truth):
@Override protected void run() throws Exception {
  if (CookieHandler.getDefault() == null)   CookieHandler.setDefault(new SimpleCookieManager());
  final URL ipzilla=new URL(url);
  if (username == null) {
    final PasswordAuthentication auth=Authenticator.requestPasswordAuthentication(ipzilla.getHost(),null,ipzilla.getPort(),ipzilla.getProtocol(),CLIText.get().IPZillaPasswordPrompt,ipzilla.getProtocol(),ipzilla,Authenticator.RequestorType.SERVER);
    username=auth.getUserName();
    password=new String(auth.getPassword());
  }
  if (output == null)   output=new File(db.getWorkTree(),IpLogMeta.IPLOG_CONFIG_FILE);
  IpLogMeta meta=new IpLogMeta();
  meta.syncCQs(output,db.getFS(),ipzilla,username,password);
}