nus-yam/ex-repair huggingface dataset:
Program: 39557
Project: 39557
Buggy source:
/** 
 * Clear object for garbage collection.
 */
public void clear(){
  this.vertices().points().clear();
  this.vertices().uvs().clear();
  this.vertices().normals().clear();
  this.vertices().colors().clear();
  _textures.clear();
  if (this.parent() != null)   this.parent().removeChild(this);
}

Fixed version (ground truth):
/** 
 * Clear object for garbage collection.
 */
public void clear(){
  this.vertices().points().clear();
  this.vertices().uvs().clear();
  this.vertices().normals().clear();
  if (this.vertices().colors() != null)   this.vertices().colors().clear();
  _textures.clear();
  if (this.parent() != null)   this.parent().removeChild(this);
}
Program: 39558
Project: 39558
Buggy source:
/** 
 * Color used to render object, but only when colorsEnabled is false.
 */
public Color4 defaultColor(){
  return _defaultColor;
}

Fixed version (ground truth):
public void defaultColor(Color4 color){
  _defaultColor=color;
}
Program: 39559
Project: 39559
Buggy source:
@Override public Object3d getChildAt(int $index){
  return _children.get($index);
}

Fixed version (ground truth):
public Object3d getChildAt(int $index){
  return _children.get($index);
}
Program: 39560
Project: 39560
Buggy source:
/** 
 * TODO: Use better lookup 
 */
@Override public Object3d getChildByName(String $name){
  for (int i=0; i < _children.size(); i++) {
    if (_children.get(i).name().equals($name))     return _children.get(i);
  }
  return null;
}

Fixed version (ground truth):
/** 
 * TODO: Use better lookup 
 */
public Object3d getChildByName(String $name){
  for (int i=0; i < _children.size(); i++) {
    if (_children.get(i).name().equals($name))     return _children.get(i);
  }
  return null;
}
Program: 39561
Project: 39561
Buggy source:
@Override public void addChildAt(Object3d $o,int $index){
  _children.add($index,$o);
  $o.parent(this);
  $o.scene(this.scene());
}

Fixed version (ground truth):
public void addChildAt(Object3d $o,int $index){
  _children.add($index,$o);
  $o.parent(this);
  $o.scene(this.scene());
}
Program: 39562
Project: 39562
Buggy source:
@Override public Object3d removeChildAt(int $index){
  Object3d o=_children.remove($index);
  if (o != null) {
    o.parent(null);
    o.scene(null);
  }
  return o;
}

Fixed version (ground truth):
public Object3d removeChildAt(int $index){
  Object3d o=_children.remove($index);
  if (o != null) {
    o.parent(null);
    o.scene(null);
  }
  return o;
}
Program: 39563
Project: 39563
Buggy source:
@Override public boolean removeChild(Object3d $o){
  boolean b=_children.remove($o);
  if (b) {
    $o.parent(null);
    $o.scene(null);
  }
  return b;
}

Fixed version (ground truth):
public boolean removeChild(Object3d $o){
  boolean b=_children.remove($o);
  if (b) {
    $o.parent(null);
    $o.scene(null);
  }
  return b;
}
Program: 39564
Project: 39564
Buggy source:
@Override public int numChildren(){
  return _children.size();
}

Fixed version (ground truth):
public int numChildren(){
  return _children.size();
}
Program: 39565
Project: 39565
Buggy source:
@Override public void addChild(Object3d $o){
  _children.add($o);
  $o.parent(this);
  $o.scene(this.scene());
}

Fixed version (ground truth):
public void addChild(Object3d $o){
  _children.add($o);
  $o.parent(this);
  $o.scene(this.scene());
}
Program: 39566
Project: 39566
Buggy source:
@Override public int getChildIndexOf(Object3d $o){
  return _children.indexOf($o);
}

Fixed version (ground truth):
public int getChildIndexOf(Object3d $o){
  return _children.indexOf($o);
}
Program: 39568
Project: 39568
Buggy source:
/** 
 * TODO: Use better lookup 
 */
@Override public Object3d getChildByName(String $name){
  for (int i=0; i < _children.size(); i++) {
    if (_children.get(0).name() == $name)     return _children.get(0);
  }
  return null;
}

Fixed version (ground truth):
/** 
 * TODO: Use better lookup 
 */
public Object3d getChildByName(String $name){
  for (int i=0; i < _children.size(); i++) {
    if (_children.get(0).name() == $name)     return _children.get(0);
  }
  return null;
}
Program: 39569
Project: 39569
Buggy source:
/** 
 * Removes Object3d from Scene. Returns false if unsuccessful
 */
@Override public boolean removeChild(Object3d $o){
  $o.parent(null);
  $o.scene(null);
  return _children.remove($o);
}

Fixed version (ground truth):
/** 
 * Removes Object3d from Scene. Returns false if unsuccessful
 */
public boolean removeChild(Object3d $o){
  $o.parent(null);
  $o.scene(null);
  return _children.remove($o);
}
Program: 39570
Project: 39570
Buggy source:
@Override public void onDirty(){
}

Fixed version (ground truth):
public void onDirty(){
}
Program: 39571
Project: 39571
Buggy source:
@Override public int getChildIndexOf(Object3d $o){
  return _children.indexOf($o);
}

Fixed version (ground truth):
public int getChildIndexOf(Object3d $o){
  return _children.indexOf($o);
}
Program: 39572
Project: 39572
Buggy source:
@Override public Object3d getChildAt(int $index){
  return _children.get($index);
}

Fixed version (ground truth):
public Object3d getChildAt(int $index){
  return _children.get($index);
}
Program: 39573
Project: 39573
Buggy source:
@Override public void addChildAt(Object3d $o,int $index){
  if (_children.contains($o))   return;
  _children.add($index,$o);
}

Fixed version (ground truth):
public void addChildAt(Object3d $o,int $index){
  if (_children.contains($o))   return;
  _children.add($index,$o);
}
Program: 39574
Project: 39574
Buggy source:
@Override public Object3d removeChildAt(int $index){
  Object3d o=_children.remove($index);
  if (o != null) {
    o.parent(null);
    o.scene(null);
  }
  return o;
}

Fixed version (ground truth):
public Object3d removeChildAt(int $index){
  Object3d o=_children.remove($index);
  if (o != null) {
    o.parent(null);
    o.scene(null);
  }
  return o;
}
Program: 39575
Project: 39575
Buggy source:
@Override public int numChildren(){
  return _children.size();
}

Fixed version (ground truth):
public int numChildren(){
  return _children.size();
}
Program: 39576
Project: 39576
Buggy source:
/** 
 * Adds Object3d to Scene. Object3d's must be added to Scene in order to be rendered Returns always true. 
 */
@Override public void addChild(Object3d $o){
  if (_children.contains($o))   return;
  _children.add($o);
  $o.parent(this);
  $o.scene(this);
}

Fixed version (ground truth):
/** 
 * Adds Object3d to Scene. Object3d's must be added to Scene in order to be rendered Returns always true. 
 */
public void addChild(Object3d $o){
  if (_children.contains($o))   return;
  _children.add($o);
  $o.parent(this);
  $o.scene(this);
}
Program: 39577
Project: 39577
Buggy source:
public Rectangle(float $width,float $height,int $segsW,int $segsH,long $colorRgba){
  super(4 * $segsW * $segsH,2 * $segsW * $segsH);
  int row, col;
  float w=$width / $segsW;
  float h=$height / $segsH;
  float width5=$width / 2f;
  float height5=$height / 2f;
  Color4 c=new Color4();
  c.setAll($colorRgba);
  for (row=0; row <= $segsH; row++) {
    for (col=0; col <= $segsW; col++) {
      this.vertices().addVertex((float)col * w - width5,(float)row * h - height5,0f,(float)col / (float)$segsW,1 - (float)row / (float)$segsH,0,0,1f,c.r,c.g,c.b,c.a);
    }
  }
  int colspan=$segsW + 1;
  for (row=1; row <= $segsH; row++) {
    for (col=1; col <= $segsW; col++) {
      int lr=row * colspan + col;
      int ll=lr - 1;
      int ur=lr - colspan;
      int ul=ur - 1;
      Utils.addQuad(this,ul,ur,lr,ll);
    }
  }
}

Fixed version (ground truth):
public Rectangle(float $width,float $height,int $segsW,int $segsH,Color4 color){
  super(4 * $segsW * $segsH,2 * $segsW * $segsH);
  int row, col;
  float w=$width / $segsW;
  float h=$height / $segsH;
  float width5=$width / 2f;
  float height5=$height / 2f;
  for (row=0; row <= $segsH; row++) {
    for (col=0; col <= $segsW; col++) {
      this.vertices().addVertex((float)col * w - width5,(float)row * h - height5,0f,(float)col / (float)$segsW,1 - (float)row / (float)$segsH,0,0,1f,color.r,color.g,color.b,color.a);
    }
  }
  int colspan=$segsW + 1;
  for (row=1; row <= $segsH; row++) {
    for (col=1; col <= $segsW; col++) {
      int lr=row * colspan + col;
      int ll=lr - 1;
      int ur=lr - colspan;
      int ul=ur - 1;
      Utils.addQuad(this,ul,ur,lr,ll);
    }
  }
}
Program: 39578
Project: 39578
Buggy source:
/** 
 * Override this in the concrete parser
 */
@Override public void parse(){
}

Fixed version (ground truth):
/** 
 * Override this in the concrete parser
 */
public void parse(){
}
Program: 39579
Project: 39579
Buggy source:
/** 
 * Override this in the concrete parser
 */
@Override public Object3dContainer getParsedObject(){
  return null;
}

Fixed version (ground truth):
/** 
 * Override this in the concrete parser
 */
public Object3dContainer getParsedObject(){
  return null;
}
Program: 39580
Project: 39580
Buggy source:
/** 
 * Override this in the concrete parser if applicable 
 */
@Override public AnimationObject3d getParsedAnimationObject(){
  return null;
}

Fixed version (ground truth):
/** 
 * Override this in the concrete parser if applicable 
 */
public AnimationObject3d getParsedAnimationObject(){
  return null;
}
Program: 39581
Project: 39581
Buggy source:
private void getFrames(BufferedInputStream stream,byte[] bytes) throws IOException {
  ByteArrayInputStream ba=new ByteArrayInputStream(bytes,header.offsetFrames - 68,bytes.length - header.offsetFrames);
  LittleEndianDataInputStream is=new LittleEndianDataInputStream(ba);
  ArrayList<Number3d> firstFrameVerts=new ArrayList<Number3d>();
  for (int i=0; i < header.numFrames; i++) {
    float scaleX=is.readFloat();
    float scaleY=is.readFloat();
    float scaleZ=is.readFloat();
    float translateX=is.readFloat();
    float translateY=is.readFloat();
    float translateZ=is.readFloat();
    String name=is.readString(16);
    name=name.subSequence(0,name.lastIndexOf("String_Node_Str")).toString();
    Log.d(Min3d.TAG,"String_Node_Str" + name);
    float vertices[]=new float[header.numVerts * 3];
    int index=0;
    for (int j=0; j < header.numVerts; j++) {
      vertices[index++]=scaleX * is.readUnsignedByte() + translateX;
      vertices[index++]=scaleY * is.readUnsignedByte() + translateY;
      vertices[index++]=scaleZ * is.readUnsignedByte() + translateZ;
      int normalIndex=is.readUnsignedByte();
      if (i == 0)       co.vertices.add(new Number3d(vertices[index - 3],vertices[index - 2],vertices[index - 1]));
    }
    frames[i]=new KeyFrame(name,vertices);
  }
}

Fixed version (ground truth):
private void getFrames(BufferedInputStream stream,byte[] bytes) throws IOException {
  ByteArrayInputStream ba=new ByteArrayInputStream(bytes,header.offsetFrames - 68,bytes.length - header.offsetFrames);
  LittleEndianDataInputStream is=new LittleEndianDataInputStream(ba);
  ArrayList<Number3d> firstFrameVerts=new ArrayList<Number3d>();
  for (int i=0; i < header.numFrames; i++) {
    float scaleX=is.readFloat();
    float scaleY=is.readFloat();
    float scaleZ=is.readFloat();
    float translateX=is.readFloat();
    float translateY=is.readFloat();
    float translateZ=is.readFloat();
    String name=is.readString(16);
    if (name.indexOf("String_Node_Str") > 0)     name=name.subSequence(0,name.lastIndexOf("String_Node_Str")).toString();
 else     name=name.substring(0,6).replaceAll("String_Node_Str","String_Node_Str");
    Log.d(Min3d.TAG,"String_Node_Str" + name);
    float vertices[]=new float[header.numVerts * 3];
    int index=0;
    for (int j=0; j < header.numVerts; j++) {
      vertices[index++]=scaleX * is.readUnsignedByte() + translateX;
      vertices[index++]=scaleY * is.readUnsignedByte() + translateY;
      vertices[index++]=scaleZ * is.readUnsignedByte() + translateZ;
      int normalIndex=is.readUnsignedByte();
      if (i == 0)       co.vertices.add(new Number3d(vertices[index - 3],vertices[index - 2],vertices[index - 1]));
    }
    frames[i]=new KeyFrame(name,vertices);
  }
}
Program: 39582
Project: 39582
Buggy source:
public void play(String name){
  currentFrameIndex=0;
  for (int i=0; i < numFrames; i++) {
    if (frames[i].getName().equals(name))     currentFrameIndex=i;
  }
  play();
}

Fixed version (ground truth):
public void play(String name,boolean loop){
  this.loop=loop;
  play(name);
}
Program: 39584
Project: 39584
Buggy source:
private void getFrames(BufferedInputStream stream,byte[] bytes) throws IOException {
  ByteArrayInputStream ba=new ByteArrayInputStream(bytes,header.offsetFrames - 68,bytes.length - header.offsetFrames);
  LittleEndianDataInputStream is=new LittleEndianDataInputStream(ba);
  ArrayList<Number3d> firstFrameVerts=new ArrayList<Number3d>();
  for (int i=0; i < header.numFrames; i++) {
    float scaleX=is.readFloat();
    float scaleY=is.readFloat();
    float scaleZ=is.readFloat();
    float translateX=is.readFloat();
    float translateY=is.readFloat();
    float translateZ=is.readFloat();
    String name=is.readString(16);
    float vertices[]=new float[header.numVerts * 3];
    int index=0;
    for (int j=0; j < header.numVerts; j++) {
      vertices[index++]=scaleX * is.readUnsignedByte() + translateX;
      vertices[index++]=scaleY * is.readUnsignedByte() + translateY;
      vertices[index++]=scaleZ * is.readUnsignedByte() + translateZ;
      int normalIndex=is.readUnsignedByte();
      if (i == 0)       co.vertices.add(new Number3d(vertices[index - 3],vertices[index - 2],vertices[index - 1]));
    }
    frames[i]=new KeyFrame(name,vertices);
  }
}

Fixed version (ground truth):
private void getFrames(BufferedInputStream stream,byte[] bytes) throws IOException {
  ByteArrayInputStream ba=new ByteArrayInputStream(bytes,header.offsetFrames - 68,bytes.length - header.offsetFrames);
  LittleEndianDataInputStream is=new LittleEndianDataInputStream(ba);
  ArrayList<Number3d> firstFrameVerts=new ArrayList<Number3d>();
  for (int i=0; i < header.numFrames; i++) {
    float scaleX=is.readFloat();
    float scaleY=is.readFloat();
    float scaleZ=is.readFloat();
    float translateX=is.readFloat();
    float translateY=is.readFloat();
    float translateZ=is.readFloat();
    String name=is.readString(16);
    name=name.subSequence(0,name.lastIndexOf("String_Node_Str")).toString();
    Log.d(Min3d.TAG,"String_Node_Str" + name);
    float vertices[]=new float[header.numVerts * 3];
    int index=0;
    for (int j=0; j < header.numVerts; j++) {
      vertices[index++]=scaleX * is.readUnsignedByte() + translateX;
      vertices[index++]=scaleY * is.readUnsignedByte() + translateY;
      vertices[index++]=scaleZ * is.readUnsignedByte() + translateZ;
      int normalIndex=is.readUnsignedByte();
      if (i == 0)       co.vertices.add(new Number3d(vertices[index - 3],vertices[index - 2],vertices[index - 1]));
    }
    frames[i]=new KeyFrame(name,vertices);
  }
}
Program: 39585
Project: 39585
Buggy source:
/** 
 * Generates a new texture atlas
 */
public void generate(){
  Collections.sort(bitmaps,new BitmapHeightComparer());
  if (bitmaps.size() == 0)   return;
  BitmapAsset largestBitmap=bitmaps.get(0);
  int totalWidth=0;
  int numBitmaps=bitmaps.size();
  int uOffset=0;
  int vOffset=0;
  for (int i=0; i < numBitmaps; i++) {
    if (bitmaps.get(i).useForAtlasDimensions)     totalWidth+=bitmaps.get(i).bitmap.getWidth();
  }
  atlas=Bitmap.createBitmap(totalWidth,largestBitmap.bitmap.getHeight(),Config.ARGB_8888);
  for (int i=0; i < numBitmaps; i++) {
    BitmapAsset ba=bitmaps.get(i);
    BitmapAsset existingBA=getBitmapAssetByResourceID(ba.resourceID);
    if (ba.useForAtlasDimensions) {
      Bitmap b=ba.bitmap;
      int w=b.getWidth();
      int h=b.getHeight();
      int[] pixels=new int[w * h];
      b.getPixels(pixels,0,w,0,0,w,h);
      atlas.setPixels(pixels,0,w,uOffset,vOffset,w,h);
      ba.uOffset=(float)uOffset / totalWidth;
      ba.vOffset=0;
      ba.uScale=(float)w / (float)totalWidth;
      ba.vScale=(float)h / (float)largestBitmap.bitmap.getHeight();
      uOffset+=w;
      b.recycle();
    }
 else {
      ba.uOffset=existingBA.uOffset;
      ba.vOffset=existingBA.vOffset;
      ba.uScale=existingBA.uScale;
      ba.vScale=existingBA.vScale;
    }
  }
}

Fixed version (ground truth):
/** 
 * Generates a new texture atlas
 */
public void generate(){
  Collections.sort(bitmaps,new BitmapHeightComparer());
  if (bitmaps.size() == 0)   return;
  BitmapAsset largestBitmap=bitmaps.get(0);
  int totalWidth=0;
  int numBitmaps=bitmaps.size();
  int uOffset=0;
  int vOffset=0;
  for (int i=0; i < numBitmaps; i++) {
    if (bitmaps.get(i).useForAtlasDimensions)     totalWidth+=bitmaps.get(i).bitmap.getWidth();
  }
  atlas=Bitmap.createBitmap(totalWidth,largestBitmap.bitmap.getHeight(),Config.ARGB_8888);
  for (int i=0; i < numBitmaps; i++) {
    BitmapAsset ba=bitmaps.get(i);
    BitmapAsset existingBA=getBitmapAssetByResourceID(ba.resourceID);
    if (ba.useForAtlasDimensions) {
      Bitmap b=ba.bitmap;
      int w=b.getWidth();
      int h=b.getHeight();
      int[] pixels=new int[w * h];
      b.getPixels(pixels,0,w,0,0,w,h);
      atlas.setPixels(pixels,0,w,uOffset,vOffset,w,h);
      ba.uOffset=(float)uOffset / totalWidth;
      ba.vOffset=0;
      ba.uScale=(float)w / (float)totalWidth;
      ba.vScale=(float)h / (float)largestBitmap.bitmap.getHeight();
      uOffset+=w;
      b.recycle();
    }
 else {
      ba.uOffset=existingBA.uOffset;
      ba.vOffset=existingBA.vOffset;
      ba.uScale=existingBA.uScale;
      ba.vScale=existingBA.vScale;
    }
  }
  setId(Shared.textureManager().getNewAtlasId());
}
Program: 39586
Project: 39586
Buggy source:
@Override public AnimationObject3d getParsedAnimationObject(){
  Log.d(Min3d.TAG,"String_Node_Str");
  Bitmap texture=null;
  AnimationObject3d animObj;
  if (textureAtlas.hasBitmaps()) {
    textureAtlas.generate();
    texture=textureAtlas.getBitmap();
    Shared.textureManager().addTextureId(texture,"String_Node_Str",generateMipMap);
  }
  Log.d(Min3d.TAG,"String_Node_Str" + co.name);
  animObj=co.getParsedObject(textureAtlas,frames);
  if (textureAtlas.hasBitmaps()) {
    if (texture != null)     texture.recycle();
  }
  Log.d(Min3d.TAG,"String_Node_Str");
  super.cleanup();
  return animObj;
}

Fixed version (ground truth):
@Override public AnimationObject3d getParsedAnimationObject(){
  Log.d(Min3d.TAG,"String_Node_Str");
  Bitmap texture=null;
  AnimationObject3d animObj;
  if (textureAtlas.hasBitmaps()) {
    textureAtlas.generate();
    texture=textureAtlas.getBitmap();
    Shared.textureManager().addTextureId(texture,textureAtlas.getId(),generateMipMap);
  }
  Log.d(Min3d.TAG,"String_Node_Str" + co.name);
  animObj=co.getParsedObject(textureAtlas,frames);
  if (textureAtlas.hasBitmaps()) {
    if (texture != null)     texture.recycle();
  }
  Log.d(Min3d.TAG,"String_Node_Str");
  super.cleanup();
  return animObj;
}
Program: 39587
Project: 39587
Buggy source:
public Object3dContainer getParsedObject(){
  Log.d(Min3d.TAG,"String_Node_Str");
  Object3dContainer obj=new Object3dContainer(0,0);
  int numObjects=parseObjects.size();
  Bitmap texture=null;
  if (textureAtlas.hasBitmaps()) {
    textureAtlas.generate();
    texture=textureAtlas.getBitmap();
    Shared.textureManager().addTextureId(texture,"String_Node_Str",generateMipMap);
  }
  for (int i=0; i < numObjects; i++) {
    ParseObjectData o=parseObjects.get(i);
    Log.d(Min3d.TAG,"String_Node_Str" + o.name);
    obj.addChild(o.getParsedObject(textureAtlas));
  }
  if (textureAtlas.hasBitmaps()) {
    if (texture != null)     texture.recycle();
  }
  Log.d(Min3d.TAG,"String_Node_Str");
  super.cleanup();
  return obj;
}

Fixed version (ground truth):
public Object3dContainer getParsedObject(){
  Log.d(Min3d.TAG,"String_Node_Str");
  Object3dContainer obj=new Object3dContainer(0,0);
  int numObjects=parseObjects.size();
  Bitmap texture=null;
  if (textureAtlas.hasBitmaps()) {
    textureAtlas.generate();
    texture=textureAtlas.getBitmap();
    Shared.textureManager().addTextureId(texture,textureAtlas.getId(),generateMipMap);
  }
  for (int i=0; i < numObjects; i++) {
    ParseObjectData o=parseObjects.get(i);
    Log.d(Min3d.TAG,"String_Node_Str" + o.name);
    obj.addChild(o.getParsedObject(textureAtlas));
  }
  if (textureAtlas.hasBitmaps()) {
    if (texture != null)     texture.recycle();
  }
  Log.d(Min3d.TAG,"String_Node_Str");
  super.cleanup();
  return obj;
}
Program: 39588
Project: 39588
Buggy source:
public Object3dContainer getParsedObject(){
  Log.d(Min3d.TAG,"String_Node_Str");
  Object3dContainer obj=new Object3dContainer(0,0);
  int numObjects=parseObjects.size();
  Bitmap texture=null;
  if (textureAtlas.hasBitmaps()) {
    textureAtlas.generate();
    texture=textureAtlas.getBitmap();
    Shared.textureManager().addTextureId(texture,"String_Node_Str",generateMipMap);
  }
  for (int i=0; i < numObjects; i++) {
    ParseObjectData o=parseObjects.get(i);
    Log.d(Min3d.TAG,"String_Node_Str" + o.name);
    obj.addChild(o.getParsedObject(textureAtlas));
  }
  if (textureAtlas.hasBitmaps()) {
    if (texture != null)     texture.recycle();
  }
  Log.d(Min3d.TAG,"String_Node_Str");
  cleanup();
  return obj;
}

Fixed version (ground truth):
public Object3dContainer getParsedObject(){
  Log.d(Min3d.TAG,"String_Node_Str");
  Object3dContainer obj=new Object3dContainer(0,0);
  int numObjects=parseObjects.size();
  Bitmap texture=null;
  if (textureAtlas.hasBitmaps()) {
    textureAtlas.generate();
    texture=textureAtlas.getBitmap();
    Shared.textureManager().addTextureId(texture,textureAtlas.getId(),generateMipMap);
  }
  for (int i=0; i < numObjects; i++) {
    ParseObjectData o=parseObjects.get(i);
    Log.d(Min3d.TAG,"String_Node_Str" + o.name);
    obj.addChild(o.getParsedObject(textureAtlas));
  }
  if (textureAtlas.hasBitmaps()) {
    if (texture != null)     texture.recycle();
  }
  Log.d(Min3d.TAG,"String_Node_Str");
  cleanup();
  return obj;
}
Program: 39589
Project: 39589
Buggy source:
private void parseObject(Object3d obj,TextureAtlas textureAtlas){
  int numFaces=faces.size();
  int faceIndex=0;
  boolean hasBitmaps=textureAtlas.hasBitmaps();
  for (int i=0; i < numFaces; i++) {
    ParseObjectFace face=faces.get(i);
    BitmapAsset ba=textureAtlas.getBitmapAssetByName(face.materialKey);
    for (int j=0; j < face.faceLength; j++) {
      Number3d newVertex=vertices.get(face.v[j]);
      Uv newUv=face.hasuv ? texCoords.get(face.uv[j]).clone() : new Uv();
      Number3d newNormal=face.hasn ? normals.get(face.n[j]) : new Number3d();
      Color4 newColor=new Color4(255,255,0,255);
      if (hasBitmaps) {
        newUv.u=ba.uOffset + newUv.u * ba.uScale;
        newUv.v=ba.vOffset + ((newUv.v + 1) * ba.vScale) - 1;
      }
      obj.vertices().addVertex(newVertex,newUv,newNormal,newColor);
    }
    if (face.faceLength == 3) {
      obj.faces().add(new Face(faceIndex,faceIndex + 1,faceIndex + 2));
    }
 else     if (face.faceLength == 4) {
      obj.faces().add(new Face(faceIndex,faceIndex + 1,faceIndex + 3));
      obj.faces().add(new Face(faceIndex + 1,faceIndex + 2,faceIndex + 3));
    }
    faceIndex+=face.faceLength;
  }
  if (hasBitmaps) {
    obj.textures().addById("String_Node_Str");
  }
  cleanup();
}

Fixed version (ground truth):
private void parseObject(Object3d obj,TextureAtlas textureAtlas){
  int numFaces=faces.size();
  int faceIndex=0;
  boolean hasBitmaps=textureAtlas.hasBitmaps();
  for (int i=0; i < numFaces; i++) {
    ParseObjectFace face=faces.get(i);
    BitmapAsset ba=textureAtlas.getBitmapAssetByName(face.materialKey);
    for (int j=0; j < face.faceLength; j++) {
      Number3d newVertex=vertices.get(face.v[j]);
      Uv newUv=face.hasuv ? texCoords.get(face.uv[j]).clone() : new Uv();
      Number3d newNormal=face.hasn ? normals.get(face.n[j]) : new Number3d();
      Color4 newColor=new Color4(255,255,0,255);
      if (hasBitmaps) {
        newUv.u=ba.uOffset + newUv.u * ba.uScale;
        newUv.v=ba.vOffset + ((newUv.v + 1) * ba.vScale) - 1;
      }
      obj.vertices().addVertex(newVertex,newUv,newNormal,newColor);
    }
    if (face.faceLength == 3) {
      obj.faces().add(new Face(faceIndex,faceIndex + 1,faceIndex + 2));
    }
 else     if (face.faceLength == 4) {
      obj.faces().add(new Face(faceIndex,faceIndex + 1,faceIndex + 3));
      obj.faces().add(new Face(faceIndex + 1,faceIndex + 2,faceIndex + 3));
    }
    faceIndex+=face.faceLength;
  }
  if (hasBitmaps) {
    obj.textures().addById(textureAtlas.getId());
  }
  cleanup();
}
Program: 39590
Project: 39590
Buggy source:
/** 
 * Generates a new texture atlas
 */
public void generate(){
  Collections.sort(bitmaps,new BitmapHeightComparer());
  BitmapAsset largestBitmap=bitmaps.get(0);
  int totalWidth=0;
  int numBitmaps=bitmaps.size();
  for (int i=0; i < numBitmaps; i++) {
    totalWidth+=bitmaps.get(i).bitmap.getWidth();
  }
  atlas=Bitmap.createBitmap(totalWidth,largestBitmap.bitmap.getHeight(),Config.ARGB_8888);
  int uOffset=0;
  int vOffset=0;
  for (int i=0; i < numBitmaps; i++) {
    BitmapAsset ba=bitmaps.get(i);
    Bitmap b=ba.bitmap;
    int w=b.getWidth();
    int h=b.getHeight();
    int[] pixels=new int[w * h];
    b.getPixels(pixels,0,w,0,0,w,h);
    atlas.setPixels(pixels,0,w,uOffset,vOffset,w,h);
    ba.uOffset=(float)uOffset / totalWidth;
    ba.vOffset=0;
    ba.uScale=(float)w / (float)totalWidth;
    ba.vScale=(float)h / (float)largestBitmap.bitmap.getHeight();
    uOffset+=w;
    b.recycle();
  }
}

Fixed version (ground truth):
/** 
 * Generates a new texture atlas
 */
public void generate(){
  Collections.sort(bitmaps,new BitmapHeightComparer());
  if (bitmaps.size() == 0)   return;
  BitmapAsset largestBitmap=bitmaps.get(0);
  int totalWidth=0;
  int numBitmaps=bitmaps.size();
  for (int i=0; i < numBitmaps; i++) {
    totalWidth+=bitmaps.get(i).bitmap.getWidth();
  }
  atlas=Bitmap.createBitmap(totalWidth,largestBitmap.bitmap.getHeight(),Config.ARGB_8888);
  int uOffset=0;
  int vOffset=0;
  for (int i=0; i < numBitmaps; i++) {
    BitmapAsset ba=bitmaps.get(i);
    Bitmap b=ba.bitmap;
    int w=b.getWidth();
    int h=b.getHeight();
    int[] pixels=new int[w * h];
    b.getPixels(pixels,0,w,0,0,w,h);
    atlas.setPixels(pixels,0,w,uOffset,vOffset,w,h);
    ba.uOffset=(float)uOffset / totalWidth;
    ba.vOffset=0;
    ba.uScale=(float)w / (float)totalWidth;
    ba.vScale=(float)h / (float)largestBitmap.bitmap.getHeight();
    uOffset+=w;
    b.recycle();
  }
}
Program: 39591
Project: 39591
Buggy source:
public Object3dContainer getParsedObject(){
  Log.d(Min3d.TAG,"String_Node_Str");
  Object3dContainer obj=new Object3dContainer(0,0);
  int numObjects=parseObjects.size();
  textureAtlas.generate();
  Bitmap texture=textureAtlas.getBitmap();
  Shared.textureManager().addTextureId(texture,"String_Node_Str");
  for (int i=0; i < numObjects; i++) {
    ParseObjectData o=parseObjects.get(i);
    Log.d(Min3d.TAG,"String_Node_Str" + o.name);
    obj.addChild(o.getParsedObject(textureAtlas));
  }
  texture.recycle();
  textureAtlas.cleanup();
  Log.d(Min3d.TAG,"String_Node_Str");
  cleanup();
  return obj;
}

Fixed version (ground truth):
public Object3dContainer getParsedObject(){
  Log.d(Min3d.TAG,"String_Node_Str");
  Object3dContainer obj=new Object3dContainer(0,0);
  int numObjects=parseObjects.size();
  Bitmap texture=null;
  if (textureAtlas.hasBitmaps()) {
    textureAtlas.generate();
    texture=textureAtlas.getBitmap();
    Shared.textureManager().addTextureId(texture,"String_Node_Str");
  }
  for (int i=0; i < numObjects; i++) {
    ParseObjectData o=parseObjects.get(i);
    Log.d(Min3d.TAG,"String_Node_Str" + o.name);
    obj.addChild(o.getParsedObject(textureAtlas));
  }
  if (textureAtlas.hasBitmaps()) {
    if (texture != null)     texture.recycle();
    textureAtlas.cleanup();
  }
  Log.d(Min3d.TAG,"String_Node_Str");
  cleanup();
  return obj;
}
Program: 39592
Project: 39592
Buggy source:
public ObjFace(StringTokenizer parts,String materialKey,int faceLength){
  super();
  this.materialKey=materialKey;
  this.faceLength=faceLength;
  StringTokenizer subParts=new StringTokenizer(parts.nextToken(),"String_Node_Str");
  int partLength=subParts.countTokens();
  boolean emptyVt=parts.toString().indexOf("String_Node_Str") > -1;
  hasuv=partLength >= 2 && !emptyVt;
  hasn=partLength == 3;
  v=new short[faceLength];
  if (hasuv)   uv=new short[faceLength];
  if (hasn)   n=new short[faceLength];
  for (int i=1; i < faceLength + 1; i++) {
    if (i > 1)     subParts=new StringTokenizer(parts.nextToken(),"String_Node_Str");
    int index=i - 1;
    v[index]=(short)(Short.parseShort(subParts.nextToken()) - 1);
    if (hasuv)     uv[index]=(short)(Short.parseShort(subParts.nextToken()) - 1);
    if (hasn)     n[index]=(short)(Short.parseShort(subParts.nextToken()) - 1);
  }
}

Fixed version (ground truth):
public ObjFace(String line,String materialKey,int faceLength){
  super();
  this.materialKey=materialKey;
  this.faceLength=faceLength;
  boolean emptyVt=line.indexOf("String_Node_Str") > -1;
  if (emptyVt)   line=line.replace("String_Node_Str","String_Node_Str");
  StringTokenizer parts=new StringTokenizer(line);
  parts.nextToken();
  StringTokenizer subParts=new StringTokenizer(parts.nextToken(),"String_Node_Str");
  int partLength=subParts.countTokens();
  hasuv=partLength >= 2 && !emptyVt;
  hasn=partLength == 3 || (partLength == 2 && emptyVt);
  v=new short[faceLength];
  if (hasuv)   uv=new short[faceLength];
  if (hasn)   n=new short[faceLength];
  for (int i=1; i < faceLength + 1; i++) {
    if (i > 1)     subParts=new StringTokenizer(parts.nextToken(),"String_Node_Str");
    int index=i - 1;
    v[index]=(short)(Short.parseShort(subParts.nextToken()) - 1);
    if (hasuv)     uv[index]=(short)(Short.parseShort(subParts.nextToken()) - 1);
    if (hasn)     n[index]=(short)(Short.parseShort(subParts.nextToken()) - 1);
  }
}
Program: 39594
Project: 39594
Buggy source:
@Override public void updateTwitterData(User user){
  Connection connection=null;
  PreparedStatement ps=null;
  try {
    connection=dbMgr.getConnection();
    ps=connection.prepareStatement("String_Node_Str");
    ps.setString(1,user.getUserName());
    ps.setString(2,user.getPictureUrl());
    ps.setString(3,user.getLocation());
    ps.setString(4,user.getDescription());
    ps.setString(5,user.getLongName());
    ps.setString(6,user.getLanguage());
    ps.setString(7,user.getUrl());
    ps.setLong(8,user.getId());
    ps.executeUpdate();
    logger.debug(DBConstants.QUERY_EXECUTION_SUCC + ps.toString());
  }
 catch (  SQLException ex) {
    logger.error(DBConstants.QUERY_EXECUTION_FAIL + ps.toString(),ex);
  }
 finally {
    dbMgr.closeResources(connection,ps,null);
  }
}

Fixed version (ground truth):
@Override public void updateTwitterData(User user){
  Connection connection=null;
  PreparedStatement ps=null;
  try {
    connection=dbMgr.getConnection();
    ps=connection.prepareStatement("String_Node_Str");
    ps.setString(1,user.getUserName());
    ps.setString(2,user.getPictureUrl());
    ps.setString(3,user.getLocation());
    ps.setString(4,user.getDescription());
    ps.setString(5,user.getLongName());
    ps.setString(6,user.getLanguage());
    ps.setString(7,user.getUrl());
    ps.setLong(8,user.getId());
    ps.executeUpdate();
    logger.debug(DBConstants.QUERY_EXECUTION_SUCC + ps.toString());
  }
 catch (  MySQLIntegrityConstraintViolationException e) {
  }
catch (  SQLException ex) {
    logger.error(DBConstants.QUERY_EXECUTION_FAIL + ps.toString(),ex);
  }
 finally {
    dbMgr.closeResources(connection,ps,null);
  }
}
Program: 39595
Project: 39595
Buggy source:
public void doPost(HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException {
  super.doPost(request,response);
  response.setContentType("String_Node_Str");
  try {
    getServletContext().getRequestDispatcher("String_Node_Str").forward(request,response);
  }
 catch (  ServletException e) {
    logger.error("String_Node_Str",e);
  }
}

Fixed version (ground truth):
public void doPost(HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException {
  response.setContentType("String_Node_Str");
  response.setHeader("String_Node_Str","String_Node_Str");
  response.setHeader("String_Node_Str","String_Node_Str");
  response.setDateHeader("String_Node_Str",0);
  loadUserFromCookie(request);
  try {
    getServletContext().getRequestDispatcher("String_Node_Str").forward(request,response);
  }
 catch (  ServletException e) {
    logger.error("String_Node_Str",e);
  }
}
Program: 39596
Project: 39596
Buggy source:
@Override public void doPost(HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException {
  super.doPost(request,response);
  response.setContentType("String_Node_Str");
  setPageAttributes();
  if (user != null) {
    String stock=request.getParameter("String_Node_Str");
    String amount=request.getParameter("String_Node_Str");
    try {
      Stock stockObj=stockMgr.getStockById(Long.parseLong(stock));
      if (user != null && stockObj != null) {
        BuySellResponse buySellResponse=portfolioMgr.buy(user,stockObj,Integer.parseInt(amount));
        request.setAttribute(HomePageServlet.STOCK,stockObj);
        getServletContext().getRequestDispatcher("String_Node_Str").forward(request,response);
      }
    }
 catch (    NumberFormatException e) {
      logger.error("String_Node_Str" + stock + "String_Node_Str"+ amount,e);
    }
catch (    ServletException e) {
      logger.error("String_Node_Str",e);
    }
  }
}

Fixed version (ground truth):
@Override public void doPost(HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException {
  response.setContentType("String_Node_Str");
  response.setHeader("String_Node_Str","String_Node_Str");
  response.setHeader("String_Node_Str","String_Node_Str");
  response.setDateHeader("String_Node_Str",0);
  loadUserFromCookie(request);
  User user=(User)request.getAttribute(User.USER);
  if (user != null) {
    String stock=request.getParameter("String_Node_Str");
    String amount=request.getParameter("String_Node_Str");
    try {
      Stock stockObj=stockMgr.getStockById(Long.parseLong(stock));
      if (user != null && stockObj != null) {
        portfolioMgr.buy(user,stockObj,Integer.parseInt(amount));
        request.setAttribute(HomePageServlet.STOCK,stockObj);
        getServletContext().getRequestDispatcher("String_Node_Str").forward(request,response);
      }
    }
 catch (    NumberFormatException e) {
      logger.error("String_Node_Str" + stock + "String_Node_Str"+ amount,e);
    }
catch (    ServletException e) {
      logger.error("String_Node_Str",e);
    }
  }
}
Program: 39597
Project: 39597
Buggy source:
public Cookie[] createCookie(long userId,String oauthToken){
  Cookie ck1=new Cookie(COOKIE_ID,String.valueOf(userId));
  Cookie ck2=new Cookie(COOKIE_OAUTHTOKEN,oauthToken);
  ck1.setMaxAge(COOKIE_EXPIRE);
  ck2.setMaxAge(COOKIE_EXPIRE);
  return new Cookie[]{ck1,ck2};
}

Fixed version (ground truth):
public Cookie[] createCookie(long userId,String oauthToken){
  Cookie ck1=new Cookie(COOKIE_ID,String.valueOf(userId));
  Cookie ck2=new Cookie(COOKIE_OAUTHTOKEN,oauthToken);
  Cookie ck3=new Cookie(COOKIE_ACTIVE,String.valueOf(true));
  ck1.setMaxAge(COOKIE_EXPIRE);
  ck2.setMaxAge(COOKIE_EXPIRE);
  ck3.setMaxAge(COOKIE_EXPIRE);
  return new Cookie[]{ck1,ck2,ck3};
}
Program: 39600
Project: 39600
Buggy source:
public void queryStockById(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  String stockIdStr=request.getParameter(STOCK);
  if (user != null && stockIdStr != null && stockIdStr.length() > 0) {
    long stockId=Long.parseLong(stockIdStr);
    TwitterProxy twitterProxy=user == null ? null : twitterProxyFactory.create(user.getOauthToken(),user.getOauthTokenSecret());
    Stock stock=stockMgr.getStockById(stockId);
    if (stock == null) {
      try {
        twitter4j.User twUser=twitterProxy.getTwUser(stockId);
        stock=new Stock();
        stock.setId(twUser.getId());
        stock.setName(twUser.getScreenName());
        stock.setTotal(twUser.getFollowersCount());
        stock.setPictureUrl(twUser.getProfileImageURL().toExternalForm());
        stock.setSold(0.0D);
        stock.setVerified(twUser.isVerified());
        stockMgr.saveStock(stock);
      }
 catch (      TwitterException e) {
        logger.error("String_Node_Str",e);
      }
    }
    ArrayList<SimpleTwitterUser> searchResultList=new ArrayList<SimpleTwitterUser>();
    try {
      searchResultList=twitterProxy.searchUsers(stock.getName());
    }
 catch (    TwitterException e) {
      e.printStackTrace();
    }
    request.setAttribute(GetQuoteServlet.QUOTE_DISPLAY,stock.getName());
    request.setAttribute(STOCK,stock);
    request.setAttribute(STOCK_ID,new Long(stock.getId()));
    request.setAttribute(GetQuoteServlet.OTHER_SEARCH_RESULTS,searchResultList);
  }
}

Fixed version (ground truth):
public void queryStockById(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  String stockIdStr=request.getParameter(STOCK);
  User user=(User)request.getAttribute(User.USER);
  if (user != null && stockIdStr != null && stockIdStr.length() > 0) {
    long stockId=Long.parseLong(stockIdStr);
    TwitterProxy twitterProxy=user == null ? null : twitterProxyFactory.create(user.getOauthToken(),user.getOauthTokenSecret());
    Stock stock=stockMgr.getStockById(stockId);
    if (stock == null) {
      try {
        twitter4j.User twUser=twitterProxy.getTwUser(stockId);
        stock=new Stock();
        stock.setId(twUser.getId());
        stock.setName(twUser.getScreenName());
        stock.setTotal(twUser.getFollowersCount());
        stock.setPictureUrl(twUser.getProfileImageURL().toExternalForm());
        stock.setSold(0.0D);
        stock.setVerified(twUser.isVerified());
        stockMgr.saveStock(stock);
      }
 catch (      TwitterException e) {
        logger.error("String_Node_Str",e);
      }
    }
    ArrayList<SimpleTwitterUser> searchResultList=new ArrayList<SimpleTwitterUser>();
    try {
      searchResultList=twitterProxy.searchUsers(stock.getName());
    }
 catch (    TwitterException e) {
      e.printStackTrace();
    }
    request.setAttribute(GetQuoteServlet.QUOTE_DISPLAY,stock.getName());
    request.setAttribute(STOCK,stock);
    request.setAttribute(STOCK_ID,new Long(stock.getId()));
    request.setAttribute(GetQuoteServlet.OTHER_SEARCH_RESULTS,searchResultList);
  }
}
Program: 39601
Project: 39601
Buggy source:
@Override protected void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  super.doGet(request,response);
  setPageAttributes();
  response.setContentType("String_Node_Str");
  request.setAttribute("String_Node_Str","String_Node_Str");
  request.setAttribute("String_Node_Str","String_Node_Str");
  long start=0;
  long end=0;
  start=System.currentTimeMillis();
  if (!twitstreet.isInitialized()) {
    getServletContext().getRequestDispatcher("String_Node_Str").forward(request,response);
    return;
  }
  end=System.currentTimeMillis();
  logger.info("String_Node_Str" + (end - start));
  start=System.currentTimeMillis();
  queryStockById(request,response);
  end=System.currentTimeMillis();
  logger.info("String_Node_Str" + (end - start));
  start=System.currentTimeMillis();
  queryStockByQuote(request,response);
  end=System.currentTimeMillis();
  logger.info("String_Node_Str" + (end - start));
  if (getUser() != null) {
    getServletContext().getRequestDispatcher("String_Node_Str").forward(request,response);
  }
 else {
    getServletContext().getRequestDispatcher("String_Node_Str").forward(request,response);
  }
}

Fixed version (ground truth):
@Override protected void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  response.setContentType("String_Node_Str");
  response.setHeader("String_Node_Str","String_Node_Str");
  response.setHeader("String_Node_Str","String_Node_Str");
  response.setDateHeader("String_Node_Str",0);
  request.setAttribute("String_Node_Str","String_Node_Str");
  request.setAttribute("String_Node_Str","String_Node_Str");
  long start=0;
  long end=0;
  start=System.currentTimeMillis();
  if (!twitstreet.isInitialized()) {
    getServletContext().getRequestDispatcher("String_Node_Str").forward(request,response);
    return;
  }
  end=System.currentTimeMillis();
  logger.info("String_Node_Str" + (end - start));
  loadUserFromCookie(request);
  start=System.currentTimeMillis();
  queryStockById(request,response);
  end=System.currentTimeMillis();
  logger.info("String_Node_Str" + (end - start));
  start=System.currentTimeMillis();
  queryStockByQuote(request,response);
  end=System.currentTimeMillis();
  logger.info("String_Node_Str" + (end - start));
  if (request.getAttribute(User.USER) != null) {
    getServletContext().getRequestDispatcher("String_Node_Str").forward(request,response);
  }
 else {
    getServletContext().getRequestDispatcher("String_Node_Str").forward(request,response);
  }
}
Program: 39604
Project: 39604
Buggy source:
private void invalidateCookies(String[] cookieNames,HttpServletRequest request,HttpServletResponse response){
  List<String> cookieNameList=Arrays.asList(cookieNames);
  for (  Cookie cookie : request.getCookies()) {
    if (cookieNameList.contains(cookie.getName())) {
      cookie.setMaxAge(0);
      cookie.setValue("String_Node_Str");
      cookie.setPath("String_Node_Str");
      cookie.setDomain(request.getHeader("String_Node_Str"));
      response.addCookie(cookie);
    }
  }
}

Fixed version (ground truth):
private void invalidateCookies(String[] cookieNames,HttpServletRequest request,HttpServletResponse response){
  List<String> cookieNameList=Arrays.asList(cookieNames);
  for (  Cookie cookie : request.getCookies()) {
    if (cookieNameList.contains(cookie.getName())) {
      if (CallBackServlet.COOKIE_ACTIVE.equalsIgnoreCase(cookie.getName())) {
        cookie.setValue(String.valueOf(false));
      }
      cookie.setMaxAge(0);
      cookie.setDomain(request.getHeader("String_Node_Str"));
      response.addCookie(cookie);
    }
  }
}
Program: 39606
Project: 39606
Buggy source:
public void queryStockById(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  String stockIdStr=request.getParameter(STOCK);
  if (user != null && stockIdStr != null && stockIdStr.length() > 0) {
    long stockId=Long.parseLong(stockIdStr);
    TwitterProxy twitterProxy=user == null ? null : twitterProxyFactory.create(user.getOauthToken(),user.getOauthTokenSecret());
    Stock stock=stockMgr.getStockById(stockId);
    if (stock == null) {
      try {
        twitter4j.User twUser=twitterProxy.getTwUser(stockId);
        stock=new Stock();
        stock.setId(twUser.getId());
        stock.setName(twUser.getScreenName());
        stock.setTotal(twUser.getFollowersCount());
        stock.setPictureUrl(twUser.getProfileImageURL().toExternalForm());
        stock.setSold(0.0D);
        stock.setVerified(twUser.isVerified());
        stockMgr.saveStock(stock);
      }
 catch (      TwitterException e) {
        logger.error("String_Node_Str",e);
      }
    }
    ArrayList<SimpleTwitterUser> searchResultList=new ArrayList<SimpleTwitterUser>();
    try {
      searchResultList=twitterProxy.searchUsers(stock.getName());
    }
 catch (    TwitterException e) {
      e.printStackTrace();
    }
    request.setAttribute(HomePageServlet.QUOTE_DISPLAY,stock.getName());
    request.setAttribute(STOCK,stock);
    request.setAttribute(STOCK_ID,new Long(stock.getId()));
    request.setAttribute(HomePageServlet.OTHER_SEARCH_RESULTS,searchResultList);
  }
}

Fixed version (ground truth):
public void queryStockById(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  String stockIdStr=request.getParameter(STOCK);
  User user=(User)request.getAttribute(User.USER);
  if (user != null && stockIdStr != null && stockIdStr.length() > 0) {
    long stockId=Long.parseLong(stockIdStr);
    TwitterProxy twitterProxy=user == null ? null : twitterProxyFactory.create(user.getOauthToken(),user.getOauthTokenSecret());
    Stock stock=stockMgr.getStockById(stockId);
    if (stock == null) {
      try {
        twitter4j.User twUser=twitterProxy.getTwUser(stockId);
        stock=new Stock();
        stock.setId(twUser.getId());
        stock.setName(twUser.getScreenName());
        stock.setTotal(twUser.getFollowersCount());
        stock.setPictureUrl(twUser.getProfileImageURL().toExternalForm());
        stock.setSold(0.0D);
        stock.setVerified(twUser.isVerified());
        stockMgr.saveStock(stock);
      }
 catch (      TwitterException e) {
        logger.error("String_Node_Str",e);
      }
    }
    ArrayList<SimpleTwitterUser> searchResultList=new ArrayList<SimpleTwitterUser>();
    try {
      searchResultList=twitterProxy.searchUsers(stock.getName());
    }
 catch (    TwitterException e) {
      e.printStackTrace();
    }
    request.setAttribute(HomePageServlet.QUOTE_DISPLAY,stock.getName());
    request.setAttribute(STOCK,stock);
    request.setAttribute(STOCK_ID,new Long(stock.getId()));
    request.setAttribute(HomePageServlet.OTHER_SEARCH_RESULTS,searchResultList);
  }
}
Program: 39608
Project: 39608
Buggy source:
public void doPost(HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException {
  super.doPost(request,response);
  try {
    getServletContext().getRequestDispatcher("String_Node_Str").forward(request,response);
  }
 catch (  ServletException e) {
    logger.error("String_Node_Str",e);
  }
}

Fixed version (ground truth):
public void doPost(HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException {
  response.setContentType("String_Node_Str");
  response.setHeader("String_Node_Str","String_Node_Str");
  response.setHeader("String_Node_Str","String_Node_Str");
  response.setDateHeader("String_Node_Str",0);
  loadUserFromCookie(request);
  try {
    getServletContext().getRequestDispatcher("String_Node_Str").forward(request,response);
  }
 catch (  ServletException e) {
    logger.error("String_Node_Str",e);
  }
}
Program: 39609
Project: 39609
Buggy source:
public void loadUserFromCookie(HttpServletRequest request){
  if (request.getAttribute(User.USER) != null) {
    return;
  }
  Cookie[] cookies=request.getCookies() == null ? new Cookie[]{} : request.getCookies();
  boolean idFound=false;
  boolean oAuthFound=false;
  boolean active=false;
  String idStr="String_Node_Str";
  String oAuth="String_Node_Str";
  User user=null;
  for (  Cookie cookie : cookies) {
    if (cookie.getName().equals(CallBackServlet.COOKIE_ID)) {
      idStr=cookie.getValue();
      idFound=true;
    }
    if (cookie.getName().equals(CallBackServlet.COOKIE_OAUTHTOKEN)) {
      oAuth=cookie.getValue();
      oAuthFound=true;
    }
    if (idFound && oAuthFound && active) {
      try {
        long id=Long.parseLong(idStr);
        user=userMgr.getUserById(id);
        if (user != null && oAuth.equals(user.getOauthToken())) {
          request.setAttribute(User.USER,user);
          request.getSession().setAttribute(User.USER_ID,user.getId());
          break;
        }
      }
 catch (      NumberFormatException nfe) {
      }
      break;
    }
  }
}

Fixed version (ground truth):
public void loadUserFromCookie(HttpServletRequest request){
  if (request.getAttribute(User.USER) != null) {
    return;
  }
  Cookie[] cookies=request.getCookies() == null ? new Cookie[]{} : request.getCookies();
  boolean idFound=false;
  boolean oAuthFound=false;
  boolean active=false;
  String idStr="String_Node_Str";
  String oAuth="String_Node_Str";
  User user=null;
  for (  Cookie cookie : cookies) {
    if (cookie.getName().equals(CallBackServlet.COOKIE_ID)) {
      idStr=cookie.getValue();
      idFound=true;
    }
    if (cookie.getName().equals(CallBackServlet.COOKIE_OAUTHTOKEN)) {
      oAuth=cookie.getValue();
      oAuthFound=true;
    }
    if (idFound && oAuthFound) {
      try {
        long id=Long.parseLong(idStr);
        user=userMgr.getUserById(id);
        if (user != null && oAuth.equals(user.getOauthToken())) {
          request.setAttribute(User.USER,user);
          request.getSession().setAttribute(User.USER_ID,user.getId());
          break;
        }
      }
 catch (      NumberFormatException nfe) {
      }
      break;
    }
  }
}