nus-yam/ex-repair huggingface dataset:
Program: 60241
Project: 60241
Buggy source:
public InputTextControl(final HTMLBaseInputElement modelNode){
  super(modelNode);
  JTextFieldImpl text=(JTextFieldImpl)this.widget;
  if (modelNode.getTitle() != null)   text.setToolTipText(modelNode.getTitle());
  text.setVisible(modelNode.getHidden());
  text.applyComponentOrientation(direction(modelNode.getDir()));
  text.setEditable(new Boolean(modelNode.getContentEditable()));
  text.setEnabled(!modelNode.getDisabled());
  text.setPlaceholder(modelNode.getPlaceholder());
  text.addActionListener(new ActionListener(){
    public void actionPerformed(    ActionEvent event){
      HtmlController.getInstance().onEnterPressed(modelNode,null);
    }
  }
);
}

Fixed version (ground truth):
public InputTextControl(final HTMLBaseInputElement modelNode){
  super(modelNode);
  JTextFieldImpl text=(JTextFieldImpl)this.widget;
  if (modelNode.getTitle() != null)   text.setToolTipText(modelNode.getTitle());
  text.setVisible(modelNode.getHidden());
  text.applyComponentOrientation(direction(modelNode.getDir()));
  text.setEditable(new Boolean(modelNode.getContentEditable() == null ? "String_Node_Str" : modelNode.getContentEditable()));
  text.setEnabled(!modelNode.getDisabled());
  text.setPlaceholder(modelNode.getPlaceholder());
  text.addActionListener(new ActionListener(){
    public void actionPerformed(    ActionEvent event){
      HtmlController.getInstance().onEnterPressed(modelNode,null);
    }
  }
);
}
Program: 60243
Project: 60243
Buggy source:
@Override synchronized public int getFeatureReport(byte[] data,int length){
  if (!m_Open)   throw new IllegalStateException("String_Node_Str");
  if (false) {
    if (!HidD_GetFeature(m_Handle,data,length)) {
      System.out.println(GetLastError());
      return -1;
    }
  }
 else {
    int[] bytes={0};
    OVERLAPPED ol=new OVERLAPPED();
    Pointer buffer=new Memory(data.length);
    if (!DeviceIoControl(m_Handle,IOCTL_HID_GET_FEATURE,buffer,length,buffer,length,bytes,ol)) {
      if (GetLastError() != ERROR_IO_PENDING)       return -1;
    }
    if (!GetOverlappedResult(m_Handle,ol,bytes,true))     return -1;
    int n=bytes[0];
    byte[] t=buffer.getByteArray(0,n);
    System.arraycopy(t,0,data,0,n);
    return n;
  }
  return -1;
}

Fixed version (ground truth):
@Override synchronized public int getFeatureReport(byte[] data,int length){
  if (!m_Open)   throw new IllegalStateException("String_Node_Str");
  if (false) {
    if (!HidD_GetFeature(m_Handle,data,length)) {
      System.out.println(GetLastError());
      return -1;
    }
  }
 else {
    int[] bytes={0};
    OVERLAPPED ol=new OVERLAPPED();
    Pointer buffer=new Memory(data.length);
    if (!DeviceIoControl(m_Handle,IOCTL_HID_GET_FEATURE,buffer,length,buffer,length,bytes,ol)) {
      if (GetLastError() != ERROR_IO_PENDING)       return -1;
    }
    if (!GetOverlappedResult(m_Handle,ol,bytes,true))     return -1;
    int n=bytes[0] + 1;
    byte[] t=buffer.getByteArray(0,n);
    System.arraycopy(t,0,data,0,n);
    return n;
  }
  return -1;
}
Program: 60244
Project: 60244
Buggy source:
@Override synchronized public void close(){
  if (!m_Open)   throw new IllegalStateException("String_Node_Str");
  m_StopThread=true;
  if (m_InputReportLength > 0) {
    m_Thread.interrupt();
    m_SyncShutdown.waitAndSync();
  }
  CloseHandle(m_Handle);
  m_Backend.removeDevice(m_HidDeviceInfo.getDeviceId());
  m_Open=false;
}

Fixed version (ground truth):
@Override synchronized public void close(){
  if (!m_Open)   throw new IllegalStateException("String_Node_Str");
  m_StopThread=true;
  if (m_InputReportLength > 0) {
    CancelIoEx(m_Handle,null);
    m_Thread.interrupt();
    m_SyncShutdown.waitAndSync();
  }
  CloseHandle(m_Handle);
  m_Backend.removeDevice(m_HidDeviceInfo.getDeviceId());
  m_Open=false;
}
Program: 60246
Project: 60246
Buggy source:
static public HidDevice openFromPath(String path,Frontend frontend){
  HidDevice.processPendingEvents();
  CFSetRef device_set=IOHIDManagerCopyDevices(m_HidManager);
  int num_devices=(int)CFSetGetCount(device_set);
  Pointer[] device_array=new Pointer[(int)num_devices];
  CFSetGetValues(device_set,device_array);
  for (int i=0; i < num_devices; i++) {
    IOHIDDeviceRef os_dev=new IOHIDDeviceRef(device_array[i]);
    if (path.equals(HidDevice.createPathForDevide(os_dev))) {
      int ret=IOHIDDeviceOpen(os_dev,kIOHIDOptionsTypeNone);
      if (ret == kIOReturnSuccess) {
        CFRetain(os_dev);
        final HidDevice dev=new HidDevice(os_dev,frontend);
        CFRelease(device_set);
        return dev;
      }
    }
  }
  CFRelease(device_set);
  return null;
}

Fixed version (ground truth):
static public HidDevice openFromPath(String path,Frontend frontend){
  HidDevice.processPendingEvents();
  CFSetRef device_set=IOHIDManagerCopyDevices(m_HidManager);
  int num_devices=(int)CFSetGetCount(device_set);
  Pointer[] device_array=new Pointer[(int)num_devices];
  CFSetGetValues(device_set,device_array);
  for (int i=0; i < num_devices; i++) {
    IOHIDDeviceRef os_dev=new IOHIDDeviceRef(device_array[i]);
    String x=HidDevice.createPathForDevide(os_dev);
    if (path.equals(x)) {
      int ret=IOHIDDeviceOpen(os_dev,kIOHIDOptionsTypeNone);
      if (ret == kIOReturnSuccess) {
        CFRetain(os_dev);
        CFRelease(device_set);
        final HidDevice dev=new HidDevice(os_dev,frontend);
        return dev;
      }
 else {
        System.out.printf("String_Node_Str",(ret >> (32 - 6)) & 0x3f,(ret >> (32 - 6 - 12)) & 0xFFF,ret & 0x3FFF);
      }
    }
  }
  CFRelease(device_set);
  return null;
}
Program: 60247
Project: 60247
Buggy source:
@Override synchronized public int setOutputReport(byte reportID,byte[] data,int length){
  if (!m_Open)   throw new IllegalStateException("String_Node_Str");
  System.out.println("String_Node_Str");
  int wlen=length;
  int offs=0;
  if (reportID != 0) {
    wlen++;
    offs=1;
    m_OutputReportBytes[0]=reportID;
  }
  System.arraycopy(data,0,m_OutputReportBytes,offs,length);
  int len=write(m_DeviceHandle,m_OutputReportBytes,wlen);
  if (len < 0)   return len;
  return len - offs;
}

Fixed version (ground truth):
@Override synchronized public int setOutputReport(byte reportID,byte[] data,int length){
  if (!m_Open)   throw new IllegalStateException("String_Node_Str");
  if (m_UsesNumberedReports)   m_OutputReportBytes[0]=reportID;
 else   m_OutputReportBytes[0]=0;
  System.arraycopy(data,0,m_OutputReportBytes,1,length);
  int len=write(m_DeviceHandle,m_OutputReportBytes,length + 1);
  if (len < 0)   return len;
  return len - 1;
}
Program: 60249
Project: 60249
Buggy source:
@Override protected void onPostExecute(Integer result){
  super.onPostExecute(result);
  if (result == Results.CODE_OK) {
    mGrid.setAdapter(new LibraryAdapter(context,R.layout.item_library,mLibrary));
    mGrid.setOnItemClickListener(new AdapterView.OnItemClickListener(){
      @Override public void onItemClick(      AdapterView<?> adapterView,      View view,      int position,      long l){
        Intent intent=new Intent(context,AnimeDetailsActivity.class);
        intent.putExtra(AnimeDetailsActivity.ARG_ID,mLibrary.get(position).getAnime().getId());
        intent.putExtra(AnimeDetailsActivity.ARG_ANIME_OBJ,mLibrary.get(position).getAnime());
        ActivityOptionsCompat transition=ActivityOptionsCompat.makeSceneTransitionAnimation((Activity)context,Pair.create(view,"String_Node_Str"),Pair.create((View)parent.getFab(),"String_Node_Str"),Pair.create(view.findViewById(R.id.item_library_paper),"String_Node_Str"));
        Utils.startActivityWithTransition(context,intent,transition);
      }
    }
);
    if (mFlipper.getDisplayedChild() == 0)     mFlipper.showNext();
  }
 else {
    if (errorKind == RetrofitError.Kind.HTTP)     mErrorView.setError(result);
 else     if (errorKind == RetrofitError.Kind.NETWORK)     mErrorView.setErrorDetail(R.string.error_connection);
 else     mErrorView.setErrorDetail(R.string.error_unknown);
    if (mFlipper.getDisplayedChild() == 0) {
      mFlipper.showNext();
      mFlipper.showNext();
    }
 else     if (mFlipper.getDisplayedChild() == 1)     mFlipper.showNext();
  }
}

Fixed version (ground truth):
@Override protected void onPostExecute(Integer result){
  super.onPostExecute(result);
  if (result == Results.CODE_OK) {
    mGrid.setAdapter(new LibraryAdapter(context,R.layout.item_library,mLibrary));
    mGrid.setOnItemClickListener(new AdapterView.OnItemClickListener(){
      @Override public void onItemClick(      AdapterView<?> adapterView,      View view,      int position,      long l){
        Intent intent=new Intent(context,AnimeDetailsActivity.class);
        intent.putExtra(AnimeDetailsActivity.ARG_ID,mLibrary.get(position).getAnime().getId());
        intent.putExtra(AnimeDetailsActivity.ARG_ANIME_OBJ,mLibrary.get(position).getAnime());
        ActivityOptionsCompat transition=ActivityOptionsCompat.makeSceneTransitionAnimation((Activity)context,Pair.create(view.findViewById(R.id.item_library_cover),"String_Node_Str"),Pair.create((View)parent.getFab(),"String_Node_Str"),Pair.create(view,"String_Node_Str"));
        Utils.startActivityWithTransition(context,intent,transition);
      }
    }
);
    if (mFlipper.getDisplayedChild() == 0)     mFlipper.showNext();
  }
 else {
    if (errorKind == RetrofitError.Kind.HTTP)     mErrorView.setError(result);
 else     if (errorKind == RetrofitError.Kind.NETWORK)     mErrorView.setErrorDetail(R.string.error_connection);
 else     mErrorView.setErrorDetail(R.string.error_unknown);
    if (mFlipper.getDisplayedChild() == 0) {
      mFlipper.showNext();
      mFlipper.showNext();
    }
 else     if (mFlipper.getDisplayedChild() == 1)     mFlipper.showNext();
  }
}
Program: 60250
Project: 60250
Buggy source:
@Override public void onItemClick(AdapterView<?> adapterView,View view,int position,long l){
  Intent intent=new Intent(context,AnimeDetailsActivity.class);
  intent.putExtra(AnimeDetailsActivity.ARG_ID,mLibrary.get(position).getAnime().getId());
  intent.putExtra(AnimeDetailsActivity.ARG_ANIME_OBJ,mLibrary.get(position).getAnime());
  ActivityOptionsCompat transition=ActivityOptionsCompat.makeSceneTransitionAnimation((Activity)context,Pair.create(view,"String_Node_Str"),Pair.create((View)parent.getFab(),"String_Node_Str"),Pair.create(view.findViewById(R.id.item_library_paper),"String_Node_Str"));
  Utils.startActivityWithTransition(context,intent,transition);
}

Fixed version (ground truth):
@Override public void onItemClick(AdapterView<?> adapterView,View view,int position,long l){
  Intent intent=new Intent(context,AnimeDetailsActivity.class);
  intent.putExtra(AnimeDetailsActivity.ARG_ID,mLibrary.get(position).getAnime().getId());
  intent.putExtra(AnimeDetailsActivity.ARG_ANIME_OBJ,mLibrary.get(position).getAnime());
  ActivityOptionsCompat transition=ActivityOptionsCompat.makeSceneTransitionAnimation((Activity)context,Pair.create(view.findViewById(R.id.item_library_cover),"String_Node_Str"),Pair.create((View)parent.getFab(),"String_Node_Str"),Pair.create(view,"String_Node_Str"));
  Utils.startActivityWithTransition(context,intent,transition);
}
Program: 60251
Project: 60251
Buggy source:
public LibraryEntry getLibraryEntryIfAnimeExists(String animeId){
  Map<String,String> params=new HashMap<String,String>();
  if (prefMan.getAuthToken() != null)   params.put("String_Node_Str",prefMan.getAuthToken());
  for (  LibraryEntry entry : getLibrary(prefMan.getUsername(),params)) {
    if (entry.getAnime().getId().equals(animeId))     return entry;
  }
  return null;
}

Fixed version (ground truth):
public LibraryEntry getLibraryEntryIfAnimeExists(String animeId){
  Map<String,String> params=new HashMap<String,String>();
  if (prefMan.getAuthToken() != null)   params.put("String_Node_Str",prefMan.getAuthToken());
  LibraryEntry libEntry=null;
  for (  LibraryEntry entry : getLibrary(prefMan.getUsername(),params)) {
    if (entry.getAnime().getId().equals(animeId))     libEntry=entry;
  }
  return libEntry;
}
Program: 60252
Project: 60252
Buggy source:
@Override protected void onPostExecute(String result){
  super.onPostExecute(result);
  if (result.equals(Results.RESULT_SUCCESS)) {
    Picasso.with(context).load(user.getAvatar()).transform(new CircleTransformation()).into(mAvatar);
    Picasso.with(context).load(user.getCoverImage()).into(mCoverImage);
  }
 else {
  }
}

Fixed version (ground truth):
@Override protected void onPostExecute(String result){
  super.onPostExecute(result);
  if (result.equals(Results.RESULT_SUCCESS)) {
    Picasso.with(context).load(user.getAvatar()).transform(new CircleTransformation()).into(mAvatar);
    Picasso.with(context).load(user.getCoverImage()).transform(new UserCoverTransformation()).into(mCoverImage);
  }
 else {
  }
}
Program: 60253
Project: 60253
Buggy source:
@Override protected Integer doInBackground(Void... voids){
  try {
    user=api.getUser(username);
    coverBitmap=Picasso.with(context).load(user.getCoverImage()).get();
    darkMutedColor=Palette.generate(coverBitmap).getDarkMutedColor(R.color.apptheme_primary);
    return Results.CODE_OK;
  }
 catch (  RetrofitError e) {
    errorKind=e.getKind();
    if (e.getKind() == RetrofitError.Kind.NETWORK) {
      Log.e(TAG,e.getMessage());
      return Results.CODE_NETWORK_ERROR;
    }
 else     if (e.getKind() == RetrofitError.Kind.HTTP) {
      Log.e(TAG,e.getMessage());
      return e.getResponse().getStatus();
    }
 else {
      Log.e(TAG,e.getMessage());
      return Results.CODE_UNKNOWN;
    }
  }
catch (  Exception e) {
    e.printStackTrace();
    return Results.CODE_UNKNOWN;
  }
}

Fixed version (ground truth):
@Override protected Integer doInBackground(Void... voids){
  try {
    user=api.getUser(username);
    coverBitmap=Picasso.with(context).load(user.getCoverImage()).transform(new UserCoverTransformation()).get();
    darkMutedColor=Palette.generate(coverBitmap).getDarkMutedColor(R.color.apptheme_primary);
    return Results.CODE_OK;
  }
 catch (  RetrofitError e) {
    errorKind=e.getKind();
    if (e.getKind() == RetrofitError.Kind.NETWORK) {
      Log.e(TAG,e.getMessage());
      return Results.CODE_NETWORK_ERROR;
    }
 else     if (e.getKind() == RetrofitError.Kind.HTTP) {
      Log.e(TAG,e.getMessage());
      return e.getResponse().getStatus();
    }
 else {
      Log.e(TAG,e.getMessage());
      return Results.CODE_UNKNOWN;
    }
  }
catch (  Exception e) {
    e.printStackTrace();
    return Results.CODE_UNKNOWN;
  }
}
Program: 60255
Project: 60255
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  prefMan=new PrefManager(this);
  if (!prefMan.isAuthenticated()) {
    startActivity(new Intent(this,LoginActivity.class));
    finish();
  }
  setContentView(R.layout.activity_main);
  mNavigationDrawerFragment=(NavigationDrawerFragment)getFragmentManager().findFragmentById(R.id.navigation_drawer);
  mTitle=getTitle();
  mNavigationDrawerFragment.setUp(R.id.navigation_drawer,(DrawerLayout)findViewById(R.id.drawer_layout));
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  prefMan=new PrefManager(this);
  if (!prefMan.isAuthenticated()) {
    startActivity(new Intent(this,LoginActivity.class));
    finish();
  }
  setContentView(R.layout.activity_main);
  mNavigationDrawerFragment=(NavigationDrawerFragment)getFragmentManager().findFragmentById(R.id.navigation_drawer);
  mTitle=getTitle();
  mNavigationDrawerFragment.setUp(R.id.navigation_drawer,(DrawerLayout)findViewById(R.id.drawer_layout));
  onNavigationDrawerItemSelected(0);
}
Program: 60256
Project: 60256
Buggy source:
@Override public void onNavigationDrawerItemSelected(int position){
  FragmentManager fragmentManager=getFragmentManager();
  fragmentManager.beginTransaction().replace(R.id.container,new FeedFragment()).commit();
}

Fixed version (ground truth):
@Override public void onNavigationDrawerItemSelected(int position){
  FragmentManager fragmentManager=getFragmentManager();
  Fragment fragment=null;
switch (position) {
case 1000:
    fragment=new ProfileFragment();
  mTitle=getString(R.string.title_profile);
break;
case 0:
fragment=new FeedFragment();
mTitle=getString(R.string.title_feed);
break;
}
if (fragment != null) fragmentManager.beginTransaction().replace(R.id.container,fragment).commit();
getActionBar().setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.apptheme_primary)));
}
Program: 60257
Project: 60257
Buggy source:
@Override public View onCreateView(LayoutInflater inflater,@Nullable ViewGroup container,@Nullable Bundle savedInstanceState){
  View rootView=inflater.inflate(R.layout.fragment_main,null);
  final EditText mId=(EditText)rootView.findViewById(R.id.anime_id);
  Button mGo=(Button)rootView.findViewById(R.id.load_by_id);
  mGo.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View view){
      Intent intent=new Intent(getActivity(),AnimeDetailsActivity.class);
      intent.putExtra(AnimeDetailsActivity.ARG_ID,Integer.parseInt(mId.getText().toString()));
      startActivity(intent);
    }
  }
);
  return rootView;
}

Fixed version (ground truth):
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  View rootView=inflater.inflate(R.layout.fragment_main,null);
  final EditText mId=(EditText)rootView.findViewById(R.id.anime_id);
  Button mGo=(Button)rootView.findViewById(R.id.load_by_id);
  mGo.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View view){
      Intent intent=new Intent(getActivity(),AnimeDetailsActivity.class);
      intent.putExtra(AnimeDetailsActivity.ARG_ID,Integer.parseInt(mId.getText().toString()));
      startActivity(intent);
    }
  }
);
  return rootView;
}
Program: 60258
Project: 60258
Buggy source:
@Override public void onClick(View view){
  getFragmentManager().beginTransaction().replace(R.id.container,new ProfileFragment()).commit();
  mDrawerLayout.closeDrawer(mFragmentContainerView);
}

Fixed version (ground truth):
@Override public void onClick(View view){
  getFragmentManager().beginTransaction().replace(R.id.container,new ProfileFragment()).commit();
  mDrawerLayout.closeDrawer(mFragmentContainerView);
  selectItem(ITEM_POSITION_PROFILE);
}
Program: 60259
Project: 60259
Buggy source:
@Override public void onItemClick(AdapterView<?> adapterView,View view,int i,long l){
  prefMan.setAuthToken(null);
  prefMan.setUsername(null);
  startActivity(new Intent(getActivity(),LoginActivity.class));
}

Fixed version (ground truth):
@Override public void onItemClick(AdapterView<?> adapterView,View view,int position,long l){
switch (position) {
case 0:
    Toast.makeText(context,"String_Node_Str",Toast.LENGTH_LONG).show();
  break;
case 1:
prefMan.logout();
startActivity(new Intent(getActivity(),LoginActivity.class));
getActivity().finish();
break;
}
}
Program: 60261
Project: 60261
Buggy source:
@Override public void reset() throws IOException {
  super.reset();
  jieba.reset();
}

Fixed version (ground truth):
@Override public void reset() throws IOException {
  super.reset();
  jieba.reset(this.input);
}
Program: 60262
Project: 60262
Buggy source:
@Override public Tokenizer create(AttributeFactory arg0,Reader in){
  System.out.println("String_Node_Str");
  return new JiebaTokenizer(in,segMode);
}

Fixed version (ground truth):
@Override public Tokenizer create(AttributeFactory arg0,Reader in){
  return new JiebaTokenizer(in,segMode);
}
Program: 60263
Project: 60263
Buggy source:
@Override protected TokenStreamComponents createComponents(String arg0,Reader in){
  return new TokenStreamComponents(new JiebaTokenizer(in,this.segMode));
}

Fixed version (ground truth):
@Override protected TokenStreamComponents createComponents(String field,Reader in){
  return new TokenStreamComponents(new JiebaTokenizer(in,this.segMode));
}
Program: 60264
Project: 60264
Buggy source:
protected JiebaTokenizer(Reader input,String segModeName){
  super(input);
  this.offsetAtt=addAttribute(OffsetAttribute.class);
  this.termAtt=addAttribute(CharTermAttribute.class);
  this.typeAtt=addAttribute(TypeAttribute.class);
  this.jiebaTagger=new JiebaSegmenter();
  if (null == segModeName) {
    segMode=SegMode.SEARCH;
  }
 else {
    segMode=SegMode.valueOf(segModeName);
  }
  StringBuilder bdr=new StringBuilder();
  try {
    BufferedReader reader=new BufferedReader(input);
    String line=null;
    while (null != (line=reader.readLine())) {
      bdr.append(line).append("String_Node_Str");
    }
    reader.close();
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
  List<SegToken> list=jiebaTagger.process(bdr.toString().trim(),segMode);
  tokens=list.iterator();
}

Fixed version (ground truth):
protected JiebaTokenizer(Reader input,String segModeName){
  super(input);
  this.offsetAtt=addAttribute(OffsetAttribute.class);
  this.termAtt=addAttribute(CharTermAttribute.class);
  this.typeAtt=addAttribute(TypeAttribute.class);
  jieba=new JiebaAdapter(input,segModeName);
}
Program: 60265
Project: 60265
Buggy source:
@Override public void reset() throws IOException {
  super.reset();
  jiebaTagger=new JiebaSegmenter();
}

Fixed version (ground truth):
@Override public void reset() throws IOException {
  super.reset();
  jieba.reset();
}
Program: 60266
Project: 60266
Buggy source:
@Override public boolean incrementToken() throws IOException {
  clearAttributes();
  if (tokens.hasNext()) {
    SegToken token=tokens.next();
    termAtt.append(token.word.getToken());
    termAtt.setLength(token.word.length());
    offsetAtt.setOffset(token.startOffset,token.endOffset);
    endPosition=token.endOffset;
    typeAtt.setType(token.word.getTokenType());
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean incrementToken() throws IOException {
  clearAttributes();
  if (jieba.hasNext()) {
    SegToken token=jieba.next();
    termAtt.append(token.word.getToken());
    termAtt.setLength(token.word.length());
    offsetAtt.setOffset(token.startOffset,token.endOffset);
    endPosition=token.endOffset;
    typeAtt.setType(token.word.getTokenType());
    return true;
  }
  return false;
}
Program: 60267
Project: 60267
Buggy source:
@Override public Tokenizer create(AttributeFactory arg0,Reader in){
  return new JiebaTokenizer(in,segMode);
}

Fixed version (ground truth):
@Override public Tokenizer create(AttributeFactory arg0,Reader in){
  System.out.println("String_Node_Str");
  return new JiebaTokenizer(in,segMode);
}
Program: 60268
Project: 60268
Buggy source:
private void appendEquals(String key,String op,Object value){
  Class<T> clazz=dao.getEntityClass();
  if (key.equals(Operator.ID)) {
    Object dbId=IdUtil.toDbId(clazz,(String)value);
    append(Operator.ID,op,dbId);
  }
 else   if (key.indexOf("String_Node_Str") != -1) {
    append(key,op,value);
  }
 else {
    Field f=null;
    try {
      f=FieldsCache.getInstance().getField(clazz,key);
    }
 catch (    FieldException ex) {
      logger.error(ex.getMessage(),ex);
    }
    if (f.getAnnotation(Id.class) != null) {
      Object dbId=IdUtil.toDbId(clazz,(String)value);
      append(Operator.ID,op,dbId);
    }
 else     if (value instanceof BuguEntity) {
      BuguEntity ent=(BuguEntity)value;
      Object refObj=ReferenceUtil.toDbReference(clazz,key,ent.getClass(),ent.getId());
      append(key,op,refObj);
    }
 else     if (f.getType().isEnum()) {
      append(key,op,value.toString());
    }
 else {
      append(key,op,value);
    }
  }
}

Fixed version (ground truth):
private void appendEquals(String key,String op,Object value){
  Class<T> clazz=dao.getEntityClass();
  if (key.equals(Operator.ID)) {
    Object dbId=IdUtil.toDbId(clazz,(String)value);
    append(Operator.ID,op,dbId);
  }
 else   if (key.indexOf("String_Node_Str") != -1) {
    append(key,op,value);
  }
 else {
    Field f=null;
    try {
      f=FieldsCache.getInstance().getField(clazz,key);
    }
 catch (    FieldException ex) {
      logger.error(ex.getMessage(),ex);
    }
    if (f.getAnnotation(Id.class) != null) {
      Object dbId=IdUtil.toDbId(clazz,(String)value);
      append(Operator.ID,op,dbId);
    }
 else     if (value instanceof BuguEntity) {
      BuguEntity ent=(BuguEntity)value;
      Object refObj=ReferenceUtil.toDbReference(clazz,key,ent.getClass(),ent.getId());
      append(key,op,refObj);
    }
 else     if (f.getType().isEnum()) {
      if (value != null) {
        append(key,op,value.toString());
      }
 else {
        append(key,op,null);
      }
    }
 else {
      append(key,op,value);
    }
  }
}
Program: 60269
Project: 60269
Buggy source:
private WriteResult doSave(BuguEntity ent){
  if (hasCustomListener) {
    notifyUpdated(ent);
  }
  return getCollection().save(MapperUtil.toDBObject(ent));
}

Fixed version (ground truth):
private WriteResult doSave(BuguEntity ent){
  WriteResult wr=getCollection().save(MapperUtil.toDBObject(ent));
  if (hasCustomListener) {
    notifyUpdated(ent);
  }
  return wr;
}
Program: 60270
Project: 60270
Buggy source:
/** 
 * Drop the collection.  It will automatically drop all indexes from this collection.
 */
public void drop(){
  if (!listenerList.isEmpty()) {
    List<T> list=findAll();
    for (    T t : list) {
      remove(t);
    }
  }
 else {
    getCollection().drop();
    getCollection().dropIndexes();
  }
}

Fixed version (ground truth):
/** 
 * Drop the collection.  It will automatically drop all indexes from this collection.
 */
public void drop(){
  if (!listenerList.isEmpty()) {
    List<T> list=findAll();
    for (    T t : list) {
      remove(t);
    }
  }
  getCollection().drop();
  getCollection().dropIndexes();
}
Program: 60271
Project: 60271
Buggy source:
private WriteResult removeMulti(DBObject condition){
  if (!listenerList.isEmpty()) {
    DBCursor cursor=getCollection().find(condition);
    List<T> list=MapperUtil.toList(clazz,cursor);
    for (    T t : list) {
      notifyDeleted((BuguEntity)t);
    }
  }
  return getCollection().remove(condition);
}

Fixed version (ground truth):
private WriteResult removeMulti(DBObject condition){
  List<T> list=null;
  if (!listenerList.isEmpty()) {
    DBCursor cursor=getCollection().find(condition);
    list=MapperUtil.toList(clazz,cursor);
  }
  WriteResult wr=getCollection().remove(condition);
  if (!listenerList.isEmpty() && list != null) {
    for (    T t : list) {
      notifyDeleted((BuguEntity)t);
    }
  }
  return wr;
}
Program: 60272
Project: 60272
Buggy source:
public BuguDao(Class<T> clazz){
  this.clazz=clazz;
  Entity entity=clazz.getAnnotation(Entity.class);
  SplitType st=entity.split();
  if (st == SplitType.NONE) {
    split=false;
    String name=MapperUtil.getEntityName(clazz);
    initCollection(name);
  }
 else {
    split=true;
  }
  keys=getLazyFields();
  if (hasCascadeDelete()) {
    listenerList.add(new CascadeDeleteListener(clazz));
  }
}

Fixed version (ground truth):
public BuguDao(Class<T> clazz){
  this.clazz=clazz;
  Entity entity=clazz.getAnnotation(Entity.class);
  SplitType st=entity.split();
  if (st == SplitType.NONE) {
    String name=MapperUtil.getEntityName(clazz);
    initCollection(name);
  }
  keys=getLazyFields();
  if (hasCascadeDelete()) {
    listenerList.add(new CascadeDeleteListener(clazz));
  }
}
Program: 60273
Project: 60273
Buggy source:
public DBCollection getCollection(){
  if (split) {
    return local.get();
  }
 else {
    return coll;
  }
}

Fixed version (ground truth):
public DBCollection getCollection(){
  return local.get();
}
Program: 60274
Project: 60274
Buggy source:
protected void setCollection(DBCollection coll){
  if (split) {
    local.set(coll);
  }
 else {
    this.coll=coll;
  }
}

Fixed version (ground truth):
protected void setCollection(DBCollection coll){
  local.set(coll);
}
Program: 60275
Project: 60275
Buggy source:
public BuguFS createWithConnection(String connectionName){
  return create(Default.NAME,GridFS.DEFAULT_BUCKET,GridFS.DEFAULT_CHUNKSIZE);
}

Fixed version (ground truth):
public BuguFS createWithConnection(String connectionName){
  return create(connectionName,GridFS.DEFAULT_BUCKET,GridFS.DEFAULT_CHUNKSIZE);
}
Program: 60276
Project: 60276
Buggy source:
private WriteResult execute(DBObject condition){
  List ids=null;
  if (!dao.getListenerList().isEmpty()) {
    ids=dao.getCollection().distinct(Operator.ID,condition);
  }
  WriteResult wr=dao.getCollection().update(condition,modifier,false,true);
  if (!dao.getListenerList().isEmpty() && ids != null) {
    DBObject in=new BasicDBObject(Operator.IN,ids);
    DBCursor cursor=dao.getCollection().find(new BasicDBObject(Operator.ID,in));
    List<T> list=MapperUtil.toList(dao.getEntityClass(),cursor);
    for (    T t : list) {
      dao.notifyUpdated((BuguEntity)t);
    }
  }
  return wr;
}

Fixed version (ground truth):
private WriteResult execute(DBObject condition){
  List ids=null;
  if (dao.hasUserListener) {
    ids=dao.getCollection().distinct(Operator.ID,condition);
  }
  WriteResult wr=dao.getCollection().update(condition,modifier,false,true);
  if (dao.hasUserListener && ids != null) {
    DBObject in=new BasicDBObject(Operator.IN,ids);
    DBCursor cursor=dao.getCollection().find(new BasicDBObject(Operator.ID,in));
    List<T> list=MapperUtil.toList(dao.getEntityClass(),cursor);
    for (    T t : list) {
      dao.notifyUpdated((BuguEntity)t);
    }
  }
  return wr;
}
Program: 60277
Project: 60277
Buggy source:
/** 
 * Adds a value to an array unless the value is already present,  in which case does nothing to that array.
 * @param key
 * @param value
 * @return 
 */
public BuguUpdater<T> addToSet(String key,Object value){
  append(Operator.ADD_TO_SET,key,value);
  return this;
}

Fixed version (ground truth):
/** 
 * Adds a value to an array unless the value is already present,  in which case does nothing to that array.
 * @param key
 * @param value
 * @return 
 */
public BuguUpdater<T> addToSet(String key,Object value){
  value=checkArrayValue(key,value);
  append(Operator.ADD_TO_SET,key,value);
  return this;
}
Program: 60278
Project: 60278
Buggy source:
@Override public void init(ServletConfig config) throws ServletException {
  super.init(config);
  String p=config.getInitParameter("String_Node_Str");
  password=StringUtil.encodeMD5(p);
  allowBucket=config.getInitParameter("String_Node_Str");
  forbidBucket=config.getInitParameter("String_Node_Str");
  if (!StringUtil.isEmpty(allowBucket) && !StringUtil.isEmpty(forbidBucket)) {
    throw new ServletException("String_Node_Str");
  }
  String md5=config.getInitParameter("String_Node_Str");
  contentMD5=Boolean.getBoolean(md5);
}

Fixed version (ground truth):
@Override public void init(ServletConfig config) throws ServletException {
  super.init(config);
  String p=config.getInitParameter("String_Node_Str");
  password=StringUtil.encodeMD5(p);
  allowBucket=config.getInitParameter("String_Node_Str");
  forbidBucket=config.getInitParameter("String_Node_Str");
  if (!StringUtil.isEmpty(allowBucket) && !StringUtil.isEmpty(forbidBucket)) {
    throw new ServletException("String_Node_Str");
  }
  String md5=config.getInitParameter("String_Node_Str");
  if (!StringUtil.isEmpty(md5)) {
    contentMD5=Boolean.getBoolean(md5);
  }
}
Program: 60279
Project: 60279
Buggy source:
private double sum(String key,DBObject query){
  double result=0;
  BuguAggregation agg=this.aggregate();
  agg.match(query);
  String json="String_Node_Str" + key + "String_Node_Str";
  agg.group(json);
  Iterator it=agg.results().iterator();
  if (it.hasNext()) {
    DBObject dbo=(DBObject)it.next();
    result=(Double)dbo.get("String_Node_Str");
  }
  return result;
}

Fixed version (ground truth):
private double sum(String key,DBObject query){
  double result=0;
  BuguAggregation agg=this.aggregate();
  agg.match(query);
  String json="String_Node_Str" + key + "String_Node_Str";
  agg.group(json);
  Iterator it=agg.results().iterator();
  if (it.hasNext()) {
    DBObject dbo=(DBObject)it.next();
    String s=dbo.get("String_Node_Str").toString();
    result=Double.parseDouble(s);
  }
  return result;
}
Program: 60280
Project: 60280
Buggy source:
private double min(String key,DBObject query){
  double result=0;
  BuguAggregation agg=this.aggregate();
  agg.match(query);
  String json="String_Node_Str" + key + "String_Node_Str";
  agg.group(json);
  Iterator it=agg.results().iterator();
  if (it.hasNext()) {
    DBObject dbo=(DBObject)it.next();
    result=(Double)dbo.get("String_Node_Str");
  }
  return result;
}

Fixed version (ground truth):
private double min(String key,DBObject query){
  double result=0;
  BuguAggregation agg=this.aggregate();
  agg.match(query);
  String json="String_Node_Str" + key + "String_Node_Str";
  agg.group(json);
  Iterator it=agg.results().iterator();
  if (it.hasNext()) {
    DBObject dbo=(DBObject)it.next();
    String s=dbo.get("String_Node_Str").toString();
    result=Double.parseDouble(s);
  }
  return result;
}
Program: 60281
Project: 60281
Buggy source:
private double max(String key,DBObject query){
  double result=0;
  BuguAggregation agg=this.aggregate();
  agg.match(query);
  String json="String_Node_Str" + key + "String_Node_Str";
  agg.group(json);
  Iterator it=agg.results().iterator();
  if (it.hasNext()) {
    DBObject dbo=(DBObject)it.next();
    result=(Double)dbo.get("String_Node_Str");
  }
  return result;
}

Fixed version (ground truth):
private double max(String key,DBObject query){
  double result=0;
  BuguAggregation agg=this.aggregate();
  agg.match(query);
  String json="String_Node_Str" + key + "String_Node_Str";
  agg.group(json);
  Iterator it=agg.results().iterator();
  if (it.hasNext()) {
    DBObject dbo=(DBObject)it.next();
    String s=dbo.get("String_Node_Str").toString();
    result=Double.parseDouble(s);
  }
  return result;
}
Program: 60282
Project: 60282
Buggy source:
/** 
 * Convert to JSON string.
 * @param obj
 * @return 
 */
public static String toJsonString(Object obj){
  if (obj == null) {
    return null;
  }
  BasicDBObject bdbo;
  if (obj instanceof DBObject) {
    bdbo=(BasicDBObject)obj;
  }
 else {
    DBObject dbo=MapperUtil.toDBObject(obj);
    bdbo=(BasicDBObject)dbo;
  }
  return bdbo.toString();
}

Fixed version (ground truth):
/** 
 * Convert to JSON string.
 * @param obj
 * @return 
 */
public static String toJsonString(Object obj){
  if (obj == null) {
    return null;
  }
  BasicDBObject bdbo;
  if (obj instanceof DBObject) {
    bdbo=(BasicDBObject)obj;
  }
 else {
    DBObject dbo=MapperUtil.toDBObject(obj,true);
    bdbo=(BasicDBObject)dbo;
  }
  return bdbo.toString();
}
Program: 60283
Project: 60283
Buggy source:
public T result(){
  try {
    checkSingle();
  }
 catch (  DBQueryException ex) {
    logger.error(ex.getMessage(),ex);
  }
  DBCollection coll=dao.getCollection();
  DBObject dbo;
  if (fieldsSpecified) {
    dbo=coll.findOne(condition,fields);
  }
 else   if (slices != null) {
    dbo=coll.findOne(condition,slices);
  }
 else {
    dbo=coll.findOne(condition);
  }
  return MapperUtil.fromDBObject(dao.getEntityClass(),dbo);
}

Fixed version (ground truth):
public T result(){
  try {
    checkSingle();
  }
 catch (  DBQueryException ex) {
    logger.error(ex.getMessage(),ex);
  }
  DBCollection coll=dao.getCollection();
  DBObject dbo;
  if (fieldsSpecified) {
    dbo=coll.findOne(condition,fields);
  }
 else   if (slices != null) {
    dbo=coll.findOne(condition,slices);
  }
 else {
    dbo=coll.findOne(condition);
  }
  return MapperUtil.fromDBObject(dao.getEntityClass(),dbo,withoutCascade);
}
Program: 60284
Project: 60284
Buggy source:
@Override public List<T> results(){
  DBCollection coll=dao.getCollection();
  DBCursor cursor;
  if (fieldsSpecified) {
    cursor=coll.find(condition,fields);
  }
 else {
    cursor=coll.find(condition,dao.getKeyFields());
  }
  if (orderBy != null) {
    cursor.sort(SortUtil.getSort(orderBy));
  }
  if (pageNumber > 0 && pageSize > 0) {
    cursor.skip((pageNumber - 1) * pageSize).limit(pageSize);
  }
  return MapperUtil.toList(dao.getEntityClass(),cursor);
}

Fixed version (ground truth):
@Override public List<T> results(){
  DBCollection coll=dao.getCollection();
  DBCursor cursor;
  if (fieldsSpecified) {
    cursor=coll.find(condition,fields);
  }
 else {
    cursor=coll.find(condition,dao.getKeyFields());
  }
  if (orderBy != null) {
    cursor.sort(SortUtil.getSort(orderBy));
  }
  if (pageNumber > 0 && pageSize > 0) {
    cursor.skip((pageNumber - 1) * pageSize).limit(pageSize);
  }
  return MapperUtil.toList(dao.getEntityClass(),cursor,withoutCascade);
}
Program: 60285
Project: 60285
Buggy source:
public DBObject toDBObject(){
  DBObject dbo=new BasicDBObject();
  dbo.put(SPHERICAL,spherical);
  if (limit != 0) {
    dbo.put(LIMIT,limit);
  }
  if (num != 0) {
    dbo.put(NUM,num);
  }
  if (maxDistance != 0) {
    dbo.put(MAX_DISTANCE,maxDistance);
  }
  if (minDistance != 0) {
    dbo.put(MIN_DISTANCE,minDistance);
  }
  if (query != null) {
    dbo.put(QUERY,(DBObject)JSON.parse(query));
  }
  if (near != null) {
    dbo.put(NEAR,MapperUtil.toDBObject(near));
  }
  if (distanceField != null) {
    dbo.put(DISTANCE_FIELD,distanceField);
  }
  if (includeLocs != null) {
    dbo.put(INCLUDE_LOCS,includeLocs);
  }
  return dbo;
}

Fixed version (ground truth):
public DBObject toDBObject(){
  DBObject dbo=new BasicDBObject();
  dbo.put(SPHERICAL,spherical);
  if (limit != 0) {
    dbo.put(LIMIT,limit);
  }
  if (num != 0) {
    dbo.put(NUM,num);
  }
  if (maxDistance != 0) {
    dbo.put(MAX_DISTANCE,maxDistance);
  }
  if (minDistance != 0) {
    dbo.put(MIN_DISTANCE,minDistance);
  }
  if (query != null) {
    dbo.put(QUERY,(DBObject)JSON.parse(query));
  }
  if (near != null) {
    dbo.put(NEAR,MapperUtil.toDBObject(near,true));
  }
  if (distanceField != null) {
    dbo.put(DISTANCE_FIELD,distanceField);
  }
  if (includeLocs != null) {
    dbo.put(INCLUDE_LOCS,includeLocs);
  }
  return dbo;
}
Program: 60286
Project: 60286
Buggy source:
@Override public void decode(Object obj){
  String refId=ReferenceUtil.fromDbReference(ref,value);
  Class<?> clazz=FieldUtil.getRealType(field);
  BuguEntity refObj;
  if (ref.cascade().toUpperCase().indexOf(Default.CASCADE_READ) == -1) {
    refObj=(BuguEntity)ConstructorCache.getInstance().create(clazz);
    refObj.setId(refId);
  }
 else {
    InternalDao dao=DaoCache.getInstance().get(clazz);
    refObj=(BuguEntity)dao.findOneLazily(refId);
  }
  FieldUtil.set(obj,field,refObj);
}

Fixed version (ground truth):
@Override public void decode(Object obj){
  String refId=ReferenceUtil.fromDbReference(ref,value);
  Class<?> clazz=FieldUtil.getRealType(field);
  BuguEntity refObj=null;
  if (ref.cascade().toUpperCase().indexOf(Default.CASCADE_READ) == -1 || withoutCascade) {
    refObj=(BuguEntity)ConstructorCache.getInstance().create(clazz);
    refObj.setId(refId);
  }
 else {
    InternalDao dao=DaoCache.getInstance().get(clazz);
    refObj=(BuguEntity)dao.findOneLazily(refId,true);
  }
  FieldUtil.set(obj,field,refObj);
}
Program: 60287
Project: 60287
Buggy source:
private Object decodeArray(Object val,Class elementClass){
  elementClass=FieldUtil.getRealType(elementClass,field);
  List list=(ArrayList)val;
  int size=list.size();
  if (size <= 0) {
    return null;
  }
  Object arr=Array.newInstance(elementClass,size);
  if (refList.cascade().toUpperCase().indexOf(Default.CASCADE_READ) == -1) {
    for (int i=0; i < size; i++) {
      Object item=list.get(i);
      if (item != null) {
        String refId=ReferenceUtil.fromDbReference(refList,item);
        BuguEntity refObj=(BuguEntity)ConstructorCache.getInstance().create(elementClass);
        refObj.setId(refId);
        Array.set(arr,i,refObj);
      }
 else {
        Array.set(arr,i,null);
      }
    }
  }
 else {
    List<String> idList=new ArrayList<String>();
    for (int i=0; i < size; i++) {
      Object item=list.get(i);
      if (item != null) {
        String refId=ReferenceUtil.fromDbReference(refList,item);
        idList.add(refId);
      }
    }
    InternalDao dao=DaoCache.getInstance().get(elementClass);
    BuguQuery query=dao.query().in(Operator.ID,idList);
    String sort=refList.sort();
    if (!sort.equals(Default.SORT)) {
      query.sort(sort);
    }
    List<BuguEntity> entityList=query.results();
    if (entityList.size() != size) {
      size=entityList.size();
      arr=Array.newInstance(elementClass,size);
    }
    for (int i=0; i < size; i++) {
      Array.set(arr,i,entityList.get(i));
    }
  }
  return arr;
}

Fixed version (ground truth):
private Object decodeArray(Object val,Class elementClass){
  elementClass=FieldUtil.getRealType(elementClass,field);
  List list=(ArrayList)val;
  int size=list.size();
  if (size <= 0) {
    return null;
  }
  Object arr=Array.newInstance(elementClass,size);
  if (refList.cascade().toUpperCase().indexOf(Default.CASCADE_READ) == -1 || withoutCascade) {
    for (int i=0; i < size; i++) {
      Object item=list.get(i);
      if (item != null) {
        String refId=ReferenceUtil.fromDbReference(refList,item);
        BuguEntity refObj=(BuguEntity)ConstructorCache.getInstance().create(elementClass);
        refObj.setId(refId);
        Array.set(arr,i,refObj);
      }
 else {
        Array.set(arr,i,null);
      }
    }
  }
 else {
    List<String> idList=new ArrayList<String>();
    for (int i=0; i < size; i++) {
      Object item=list.get(i);
      if (item != null) {
        String refId=ReferenceUtil.fromDbReference(refList,item);
        idList.add(refId);
      }
    }
    InternalDao dao=DaoCache.getInstance().get(elementClass);
    BuguQuery query=dao.query().in(Operator.ID,idList);
    query.setWithoutCascade(true);
    String sort=refList.sort();
    if (!sort.equals(Default.SORT)) {
      query.sort(sort);
    }
    List<BuguEntity> entityList=query.results();
    if (entityList.size() != size) {
      size=entityList.size();
      arr=Array.newInstance(elementClass,size);
    }
    for (int i=0; i < size; i++) {
      Array.set(arr,i,entityList.get(i));
    }
  }
  return arr;
}
Program: 60288
Project: 60288
Buggy source:
private List decodeCollection(Object val,Class elementClass){
  elementClass=FieldUtil.getRealType(elementClass,field);
  Collection collection=(Collection)val;
  List<BuguEntity> result=new ArrayList<BuguEntity>();
  if (refList.cascade().toUpperCase().indexOf(Default.CASCADE_READ) == -1) {
    for (    Object item : collection) {
      if (item != null) {
        String refId=ReferenceUtil.fromDbReference(refList,item);
        BuguEntity refObj=(BuguEntity)ConstructorCache.getInstance().create(elementClass);
        refObj.setId(refId);
        result.add(refObj);
      }
    }
  }
 else {
    List<String> idList=new ArrayList<String>();
    for (    Object item : collection) {
      if (item != null) {
        String refId=ReferenceUtil.fromDbReference(refList,item);
        idList.add(refId);
      }
    }
    InternalDao dao=DaoCache.getInstance().get(elementClass);
    BuguQuery query=dao.query().in(Operator.ID,idList);
    String sort=refList.sort();
    if (!sort.equals(Default.SORT)) {
      query.sort(sort);
    }
    result=query.results();
  }
  return result;
}

Fixed version (ground truth):
private List decodeCollection(Object val,Class elementClass){
  elementClass=FieldUtil.getRealType(elementClass,field);
  Collection collection=(Collection)val;
  List<BuguEntity> result=new ArrayList<BuguEntity>();
  if (refList.cascade().toUpperCase().indexOf(Default.CASCADE_READ) == -1 || withoutCascade) {
    for (    Object item : collection) {
      if (item != null) {
        String refId=ReferenceUtil.fromDbReference(refList,item);
        BuguEntity refObj=(BuguEntity)ConstructorCache.getInstance().create(elementClass);
        refObj.setId(refId);
        result.add(refObj);
      }
    }
  }
 else {
    List<String> idList=new ArrayList<String>();
    for (    Object item : collection) {
      if (item != null) {
        String refId=ReferenceUtil.fromDbReference(refList,item);
        idList.add(refId);
      }
    }
    InternalDao dao=DaoCache.getInstance().get(elementClass);
    BuguQuery query=dao.query().in(Operator.ID,idList);
    query.setWithoutCascade(true);
    String sort=refList.sort();
    if (!sort.equals(Default.SORT)) {
      query.sort(sort);
    }
    result=query.results();
  }
  return result;
}
Program: 60290
Project: 60290
Buggy source:
@Override public Object encode(){
  BuguEntity entity=(BuguEntity)value;
  if (ref.cascade().toUpperCase().indexOf(Default.CASCADE_CREATE) != -1 || ref.cascade().toUpperCase().indexOf(Default.CASCADE_UPDATE) != -1) {
    Class<?> cls=FieldUtil.getRealType(field);
    InternalDao dao=DaoCache.getInstance().get(cls);
    dao.save(entity);
  }
  return ReferenceUtil.toDbReference(ref,entity.getClass(),entity.getId());
}

Fixed version (ground truth):
@Override public Object encode(){
  BuguEntity entity=(BuguEntity)value;
  if (!withoutCascade) {
    if (ref.cascade().toUpperCase().indexOf(Default.CASCADE_CREATE) != -1 || ref.cascade().toUpperCase().indexOf(Default.CASCADE_UPDATE) != -1) {
      Class<?> cls=FieldUtil.getRealType(field);
      InternalDao dao=DaoCache.getInstance().get(cls);
      dao.saveWithoutCascade(entity,true);
    }
  }
  return ReferenceUtil.toDbReference(ref,entity.getClass(),entity.getId());
}
Program: 60292
Project: 60292
Buggy source:
private Object encodeArray(Class type,Object val){
  Class<?> cls=FieldUtil.getRealType(type,field);
  InternalDao dao=DaoCache.getInstance().get(cls);
  int len=Array.getLength(val);
  List<Object> result=new ArrayList<Object>();
  for (int i=0; i < len; i++) {
    BuguEntity entity=(BuguEntity)Array.get(val,i);
    if (entity != null) {
      if (cascadeCU) {
        dao.save(entity);
      }
      result.add(ReferenceUtil.toDbReference(refList,entity.getClass(),entity.getId()));
    }
  }
  return result;
}

Fixed version (ground truth):
private Object encodeArray(Class type,Object val){
  Class<?> cls=FieldUtil.getRealType(type,field);
  InternalDao dao=DaoCache.getInstance().get(cls);
  int len=Array.getLength(val);
  List<Object> result=new ArrayList<Object>();
  for (int i=0; i < len; i++) {
    BuguEntity entity=(BuguEntity)Array.get(val,i);
    if (entity != null) {
      if (!withoutCascade && cascadeCU) {
        dao.saveWithoutCascade(entity,true);
      }
      result.add(ReferenceUtil.toDbReference(refList,entity.getClass(),entity.getId()));
    }
  }
  return result;
}
Program: 60293
Project: 60293
Buggy source:
private Object encodeCollection(Class type,Object val){
  Collection<BuguEntity> collection=(Collection<BuguEntity>)val;
  List<Object> result=new ArrayList<Object>();
  Class<?> cls=FieldUtil.getRealType(type,field);
  InternalDao dao=DaoCache.getInstance().get(cls);
  for (  BuguEntity entity : collection) {
    if (entity != null) {
      if (cascadeCU) {
        dao.save(entity);
      }
      result.add(ReferenceUtil.toDbReference(refList,entity.getClass(),entity.getId()));
    }
  }
  return result;
}

Fixed version (ground truth):
private Object encodeCollection(Class type,Object val){
  Collection<BuguEntity> collection=(Collection<BuguEntity>)val;
  List<Object> result=new ArrayList<Object>();
  Class<?> cls=FieldUtil.getRealType(type,field);
  InternalDao dao=DaoCache.getInstance().get(cls);
  for (  BuguEntity entity : collection) {
    if (entity != null) {
      if (!withoutCascade && cascadeCU) {
        dao.saveWithoutCascade(entity,true);
      }
      result.add(ReferenceUtil.toDbReference(refList,entity.getClass(),entity.getId()));
    }
  }
  return result;
}
Program: 60294
Project: 60294
Buggy source:
/** 
 * @param key
 * @param point
 * @param maxDistance maximum meters
 * @param minDistance minimum meters
 * @return 
 */
public GeoQuery<T> nearSphere(String key,Point point,double maxDistance,double minDistance){
  DBObject geometry=new BasicDBObject();
  geometry.put(Operator.GEOMETRY,MapperUtil.toDBObject(point));
  geometry.put(Operator.MAX_DISTANCE,maxDistance);
  geometry.put(Operator.MIN_DISTANCE,minDistance);
  append(key,Operator.NEAR_SPHERE,geometry);
  return this;
}

Fixed version (ground truth):
/** 
 * @param key
 * @param point
 * @param maxDistance maximum meters
 * @param minDistance minimum meters
 * @return 
 */
public GeoQuery<T> nearSphere(String key,Point point,double maxDistance,double minDistance){
  DBObject geometry=new BasicDBObject();
  geometry.put(Operator.GEOMETRY,MapperUtil.toDBObject(point,true));
  geometry.put(Operator.MAX_DISTANCE,maxDistance);
  geometry.put(Operator.MIN_DISTANCE,minDistance);
  append(key,Operator.NEAR_SPHERE,geometry);
  return this;
}