nus-yam/ex-repair huggingface dataset:
Program: 27488
Project: 27488
Buggy source:
@Test public void testEncodeWithQos_1_MessageID() throws Exception {
  String topic="String_Node_Str";
  PublishMessage msg=new PublishMessage();
  msg.setQos(QOSType.LEAST_ONE);
  msg.setMessageID(1);
  msg.setTopicName(topic);
  byte[] payload=new byte[]{0x0A,0x0B,0x0C};
  msg.setPayload(payload);
  m_encoder.encode(null,msg,m_mockProtoEncoder);
  assertEquals(0x32,m_mockProtoEncoder.getBuffer().get());
  assertEquals(26,m_mockProtoEncoder.getBuffer().get());
  verifyString(topic,m_mockProtoEncoder.getBuffer());
  assertEquals(0,m_mockProtoEncoder.getBuffer().get());
  assertEquals(1,m_mockProtoEncoder.getBuffer().get());
  verifyBuff(payload.length,payload,m_mockProtoEncoder.getBuffer());
}

Fixed version (ground truth):
@Test public void testEncodeWithQos_1_MessageID() throws Exception {
  String topic="String_Node_Str";
  PublishMessage msg=new PublishMessage();
  msg.setQos(QOSType.LEAST_ONE);
  msg.setMessageID(1);
  msg.setTopicName(topic);
  byte[] payload=new byte[]{0x0A,0x0B,0x0C};
  msg.setPayload(payload);
  m_encoder.encode(null,msg,m_mockProtoEncoder);
  assertEquals(0x32,m_mockProtoEncoder.getBuffer().get());
  assertEquals(14,m_mockProtoEncoder.getBuffer().get());
  verifyString(topic,m_mockProtoEncoder.getBuffer());
  assertEquals(0,m_mockProtoEncoder.getBuffer().get());
  assertEquals(1,m_mockProtoEncoder.getBuffer().get());
  verifyBuff(payload.length,payload,m_mockProtoEncoder.getBuffer());
}
Program: 27489
Project: 27489
Buggy source:
@Test public void testEncodeWithQos_0_noMessageID() throws Exception {
  String topic="String_Node_Str";
  PublishMessage msg=new PublishMessage();
  msg.setQos(QOSType.MOST_ONE);
  msg.setTopicName(topic);
  byte[] payload=new byte[]{0x0A,0x0B,0x0C};
  msg.setPayload(payload);
  m_encoder.encode(null,msg,m_mockProtoEncoder);
  assertEquals(0x30,m_mockProtoEncoder.getBuffer().get());
  assertEquals(24,m_mockProtoEncoder.getBuffer().get());
  verifyString(topic,m_mockProtoEncoder.getBuffer());
  verifyBuff(payload.length,payload,m_mockProtoEncoder.getBuffer());
}

Fixed version (ground truth):
@Test public void testEncodeWithQos_0_noMessageID() throws Exception {
  String topic="String_Node_Str";
  PublishMessage msg=new PublishMessage();
  msg.setQos(QOSType.MOST_ONE);
  msg.setTopicName(topic);
  byte[] payload=new byte[]{0x0A,0x0B,0x0C};
  msg.setPayload(payload);
  m_encoder.encode(null,msg,m_mockProtoEncoder);
  assertEquals(0x30,m_mockProtoEncoder.getBuffer().get());
  assertEquals(12,m_mockProtoEncoder.getBuffer().get());
  verifyString(topic,m_mockProtoEncoder.getBuffer());
  verifyBuff(payload.length,payload,m_mockProtoEncoder.getBuffer());
}
Program: 27490
Project: 27490
Buggy source:
protected MessageDecoderResult decodeCommonHeader(AbstractMessage message,IoBuffer in){
  if (in.remaining() < 2) {
    return NEED_DATA;
  }
  byte h1=in.get();
  byte messageType=(byte)((h1 & 0x0010) >> 4);
  boolean dupFlag=((byte)((h1 & 0x0008) >> 3) == 1);
  byte qosLevel=(byte)((h1 & 0x0006) >> 1);
  boolean retainFlag=((byte)(h1 & 0x0001) == 1);
  int remainingLength=Utils.decodeRemainingLenght(in);
  if (remainingLength == -1) {
    return NEED_DATA;
  }
  message.setMessageType(messageType);
  message.setDupFlag(dupFlag);
  message.setQos(AbstractMessage.QOSType.values()[qosLevel]);
  message.setRetainFlag(retainFlag);
  message.setRemainingLength(remainingLength);
  return OK;
}

Fixed version (ground truth):
protected MessageDecoderResult decodeCommonHeader(AbstractMessage message,IoBuffer in){
  if (in.remaining() < 2) {
    return NEED_DATA;
  }
  byte h1=in.get();
  byte messageType=(byte)((h1 & 0x00F0) >> 4);
  boolean dupFlag=((byte)((h1 & 0x0008) >> 3) == 1);
  byte qosLevel=(byte)((h1 & 0x0006) >> 1);
  boolean retainFlag=((byte)(h1 & 0x0001) == 1);
  int remainingLength=Utils.decodeRemainingLenght(in);
  if (remainingLength == -1) {
    return NEED_DATA;
  }
  message.setMessageType(messageType);
  message.setDupFlag(dupFlag);
  message.setQos(AbstractMessage.QOSType.values()[qosLevel]);
  message.setRetainFlag(retainFlag);
  message.setRemainingLength(remainingLength);
  return OK;
}
Program: 27491
Project: 27491
Buggy source:
@Test public void testHeader() throws Exception {
  m_buff=IoBuffer.allocate(14);
  initHeader(m_buff);
  m_buff.flip();
  MessageDecoderResult res=m_msgdec.decode(null,m_buff,m_mockProtoDecoder);
  assertNotNull(m_mockProtoDecoder.getMessage());
  assertEquals(MessageDecoder.OK,res);
  assertEquals(ConnAckMessage.CONNECTION_ACCEPTED,m_mockProtoDecoder.getMessage().getReturnCode());
}

Fixed version (ground truth):
@Test public void testHeader() throws Exception {
  m_buff=IoBuffer.allocate(14);
  initHeader(m_buff);
  m_buff.flip();
  MessageDecoderResult res=m_msgdec.decode(null,m_buff,m_mockProtoDecoder);
  assertNotNull(m_mockProtoDecoder.getMessage());
  assertEquals(MessageDecoder.OK,res);
  assertEquals(ConnAckMessage.CONNECTION_ACCEPTED,m_mockProtoDecoder.getMessage().getReturnCode());
  assertEquals(AbstractMessage.CONNACK,m_mockProtoDecoder.getMessage().getMessageType());
}
Program: 27492
Project: 27492
Buggy source:
@Test public void testBaseHeader_extra_with_user_pwd() throws UnsupportedEncodingException, Exception {
  m_buff=IoBuffer.allocate(55);
  initHeader(m_buff,(byte)53);
  encodeString(m_buff,"String_Node_Str");
  encodeString(m_buff,"String_Node_Str");
  encodeString(m_buff,"String_Node_Str");
  encodeString(m_buff,"String_Node_Str");
  encodeString(m_buff,"String_Node_Str");
  m_buff.flip();
  m_msgdec.decode(null,m_buff,m_mockProtoDecoder);
  verifyBaseHeader(m_mockProtoDecoder.getMessage());
  assertEquals("String_Node_Str",m_mockProtoDecoder.getMessage().getClientID());
  assertEquals("String_Node_Str",m_mockProtoDecoder.getMessage().getWillTopic());
  assertEquals("String_Node_Str",m_mockProtoDecoder.getMessage().getWillMessage());
  assertEquals("String_Node_Str",m_mockProtoDecoder.getMessage().getUsername());
  assertEquals("String_Node_Str",m_mockProtoDecoder.getMessage().getPassword());
}

Fixed version (ground truth):
@Test public void testBaseHeader_extra_with_user_pwd() throws UnsupportedEncodingException, Exception {
  m_buff=IoBuffer.allocate(55);
  initHeader(m_buff,(byte)53);
  encodeString(m_buff,"String_Node_Str");
  encodeString(m_buff,"String_Node_Str");
  encodeString(m_buff,"String_Node_Str");
  encodeString(m_buff,"String_Node_Str");
  encodeString(m_buff,"String_Node_Str");
  m_buff.flip();
  m_msgdec.decode(null,m_buff,m_mockProtoDecoder);
  verifyBaseHeader(m_mockProtoDecoder.getMessage());
  assertEquals(AbstractMessage.CONNECT,m_mockProtoDecoder.getMessage().getMessageType());
  assertEquals("String_Node_Str",m_mockProtoDecoder.getMessage().getClientID());
  assertEquals("String_Node_Str",m_mockProtoDecoder.getMessage().getWillTopic());
  assertEquals("String_Node_Str",m_mockProtoDecoder.getMessage().getWillMessage());
  assertEquals("String_Node_Str",m_mockProtoDecoder.getMessage().getUsername());
  assertEquals("String_Node_Str",m_mockProtoDecoder.getMessage().getPassword());
}
Program: 27493
Project: 27493
Buggy source:
@Test public void testHeader() throws Exception {
  m_buff=IoBuffer.allocate(14);
  int messageId=0xAABB;
  initHeader(m_buff,messageId);
  m_buff.flip();
  MessageDecoderResult res=m_msgdec.decode(null,m_buff,m_mockProtoDecoder);
  assertNotNull(m_mockProtoDecoder.getMessage());
  assertEquals(MessageDecoder.OK,res);
  assertEquals(messageId,m_mockProtoDecoder.getMessage().getMessageID());
}

Fixed version (ground truth):
@Test public void testHeader() throws Exception {
  m_buff=IoBuffer.allocate(14);
  int messageId=0xAABB;
  initHeader(m_buff,messageId);
  m_buff.flip();
  MessageDecoderResult res=m_msgdec.decode(null,m_buff,m_mockProtoDecoder);
  assertNotNull(m_mockProtoDecoder.getMessage());
  assertEquals(MessageDecoder.OK,res);
  assertEquals(messageId,m_mockProtoDecoder.getMessage().getMessageID());
  assertEquals(AbstractMessage.PUBACK,m_mockProtoDecoder.getMessage().getMessageType());
}
Program: 27494
Project: 27494
Buggy source:
@Test public void testHeader() throws Exception {
  m_buff=IoBuffer.allocate(14);
  initHeader(m_buff);
  m_buff.flip();
  MessageDecoderResult res=m_msgdec.decode(null,m_buff,m_mockProtoDecoder);
  assertNotNull(m_mockProtoDecoder.getMessage());
  assertEquals(MessageDecoder.OK,res);
  assertEquals("String_Node_Str",m_mockProtoDecoder.getMessage().getTopicName());
  assertNull(m_mockProtoDecoder.getMessage().getMessageID());
}

Fixed version (ground truth):
@Test public void testHeader() throws Exception {
  m_buff=IoBuffer.allocate(14);
  initHeader(m_buff);
  m_buff.flip();
  MessageDecoderResult res=m_msgdec.decode(null,m_buff,m_mockProtoDecoder);
  assertNotNull(m_mockProtoDecoder.getMessage());
  assertEquals(MessageDecoder.OK,res);
  assertEquals("String_Node_Str",m_mockProtoDecoder.getMessage().getTopicName());
  assertNull(m_mockProtoDecoder.getMessage().getMessageID());
  assertEquals(AbstractMessage.PUBLISH,m_mockProtoDecoder.getMessage().getMessageType());
}
Program: 27495
Project: 27495
Buggy source:
@Test public void testBadQos() throws Exception {
  initHeaderQos(m_buff,0xAABB,QOSType.LEAST_ONE,QOSType.MOST_ONE,QOSType.MOST_ONE);
  m_buff.flip();
  MessageDecoderResult res=m_msgdec.decode(null,m_buff,m_mockProtoDecoder);
  assertEquals(MessageDecoderResult.OK,res);
  assertEquals(0xAABB,m_mockProtoDecoder.getMessage().getMessageID());
  List<QOSType> qoses=m_mockProtoDecoder.getMessage().types();
  assertEquals(3,qoses.size());
  assertEquals(QOSType.LEAST_ONE,qoses.get(0));
  assertEquals(QOSType.MOST_ONE,qoses.get(1));
  assertEquals(QOSType.MOST_ONE,qoses.get(2));
}

Fixed version (ground truth):
@Test public void testBadQos() throws Exception {
  initHeaderQos(m_buff,0xAABB,QOSType.LEAST_ONE,QOSType.MOST_ONE,QOSType.MOST_ONE);
  m_buff.flip();
  MessageDecoderResult res=m_msgdec.decode(null,m_buff,m_mockProtoDecoder);
  assertEquals(MessageDecoderResult.OK,res);
  assertEquals(0xAABB,m_mockProtoDecoder.getMessage().getMessageID());
  List<QOSType> qoses=m_mockProtoDecoder.getMessage().types();
  assertEquals(3,qoses.size());
  assertEquals(QOSType.LEAST_ONE,qoses.get(0));
  assertEquals(QOSType.MOST_ONE,qoses.get(1));
  assertEquals(QOSType.MOST_ONE,qoses.get(2));
  assertEquals(AbstractMessage.SUBACK,m_mockProtoDecoder.getMessage().getMessageType());
}
Program: 27496
Project: 27496
Buggy source:
private void initHeaderQos(IoBuffer buff,int messageID,QOSType... qoss) throws IllegalAccessException {
  buff.clear().put((byte)(AbstractMessage.SUBSCRIBE << 4)).put(Utils.encodeRemainingLength(3));
  Utils.writeWord(buff,messageID);
  for (  QOSType qos : qoss) {
    buff.put((byte)qos.ordinal());
  }
}

Fixed version (ground truth):
private void initHeaderQos(IoBuffer buff,int messageID,QOSType... qoss) throws IllegalAccessException {
  buff.clear().put((byte)(AbstractMessage.SUBACK << 4)).put(Utils.encodeRemainingLength(3));
  Utils.writeWord(buff,messageID);
  for (  QOSType qos : qoss) {
    buff.put((byte)qos.ordinal());
  }
}
Program: 27497
Project: 27497
Buggy source:
@Test public void testMultiTopic() throws Exception {
  m_buff=IoBuffer.allocate(4).setAutoExpand(true);
  Couple c1=new Couple((byte)2,"String_Node_Str");
  Couple c2=new Couple((byte)1,"String_Node_Str");
  initMultiTopic(m_buff,123,c1,c2);
  m_buff.flip();
  MessageDecoderResult res=m_msgdec.decode(null,m_buff,m_mockProtoDecoder);
  assertEquals(MessageDecoderResult.OK,res);
  assertEquals(2,m_mockProtoDecoder.getMessage().subscriptions().size());
}

Fixed version (ground truth):
@Test public void testMultiTopic() throws Exception {
  m_buff=IoBuffer.allocate(4).setAutoExpand(true);
  Couple c1=new Couple((byte)2,"String_Node_Str");
  Couple c2=new Couple((byte)1,"String_Node_Str");
  initMultiTopic(m_buff,123,c1,c2);
  m_buff.flip();
  MessageDecoderResult res=m_msgdec.decode(null,m_buff,m_mockProtoDecoder);
  assertEquals(MessageDecoderResult.OK,res);
  assertEquals(2,m_mockProtoDecoder.getMessage().subscriptions().size());
  assertEquals(AbstractMessage.SUBSCRIBE,m_mockProtoDecoder.getMessage().getMessageType());
}
Program: 27498
Project: 27498
Buggy source:
private void initMultiTopic(IoBuffer buff,int messageID,String... topics) throws IllegalAccessException {
  IoBuffer topicBuffer=IoBuffer.allocate(4).setAutoExpand(true);
  Utils.writeWord(topicBuffer,messageID);
  for (  String topic : topics) {
    topicBuffer.put(Utils.encodeString(topic));
  }
  topicBuffer.flip();
  buff.clear().put((byte)(AbstractMessage.SUBSCRIBE << 4 | (byte)0x02)).put(Utils.encodeRemainingLength(topicBuffer.remaining()));
  buff.put(topicBuffer);
}

Fixed version (ground truth):
private void initMultiTopic(IoBuffer buff,int messageID,String... topics) throws IllegalAccessException {
  IoBuffer topicBuffer=IoBuffer.allocate(4).setAutoExpand(true);
  Utils.writeWord(topicBuffer,messageID);
  for (  String topic : topics) {
    topicBuffer.put(Utils.encodeString(topic));
  }
  topicBuffer.flip();
  buff.clear().put((byte)(AbstractMessage.UNSUBSCRIBE << 4 | (byte)0x02)).put(Utils.encodeRemainingLength(topicBuffer.remaining()));
  buff.put(topicBuffer);
}
Program: 27499
Project: 27499
Buggy source:
@Test public void testMultiTopic() throws Exception {
  m_buff=IoBuffer.allocate(4).setAutoExpand(true);
  String topic1="String_Node_Str";
  String topic2="String_Node_Str";
  initMultiTopic(m_buff,123,topic1,topic2);
  m_buff.flip();
  MessageDecoderResult res=m_msgdec.decode(null,m_buff,m_mockProtoDecoder);
  assertEquals(MessageDecoderResult.OK,res);
  assertEquals(2,m_mockProtoDecoder.getMessage().topics().size());
  assertEquals(topic1,m_mockProtoDecoder.getMessage().topics().get(0));
  assertEquals(topic2,m_mockProtoDecoder.getMessage().topics().get(1));
}

Fixed version (ground truth):
@Test public void testMultiTopic() throws Exception {
  m_buff=IoBuffer.allocate(4).setAutoExpand(true);
  String topic1="String_Node_Str";
  String topic2="String_Node_Str";
  initMultiTopic(m_buff,123,topic1,topic2);
  m_buff.flip();
  MessageDecoderResult res=m_msgdec.decode(null,m_buff,m_mockProtoDecoder);
  assertEquals(MessageDecoderResult.OK,res);
  assertEquals(2,m_mockProtoDecoder.getMessage().topics().size());
  assertEquals(topic1,m_mockProtoDecoder.getMessage().topics().get(0));
  assertEquals(topic2,m_mockProtoDecoder.getMessage().topics().get(1));
  assertEquals(AbstractMessage.UNSUBSCRIBE,m_mockProtoDecoder.getMessage().getMessageType());
}
Program: 27500
Project: 27500
Buggy source:
@Override public void onItemClick(AdapterView<?> parent,View view,int position,long id){
  NewsEntity newsEntity=mNewsList != null ? mNewsList.get(position) : null;
  if (newsEntity == null)   return;
  Intent intent=new Intent();
  intent.putExtra("String_Node_Str",newsEntity.id);
  intent.putExtra("String_Node_Str",newsEntity);
  intent.setClass(getActivity(),NewsDetailActivity.class);
  getActivity().startActivity(intent);
  boolean setReadFlag=ZhihuApplication.getNewsReadDataSource().readNews(String.valueOf(newsEntity.id));
  if (setReadFlag) {
    ZhihuUtils.setReadStatus4NewsEntity(mNewsList,newsEntity);
    mAdapter.updateData(mNewsList);
  }
}

Fixed version (ground truth):
@Override public void onItemClick(AdapterView<?> parent,View view,int position,long id){
  NewsEntity newsEntity=mNewsList != null ? mNewsList.get(position) : null;
  if (newsEntity == null)   return;
  Intent intent=new Intent();
  intent.putExtra("String_Node_Str",newsEntity.id);
  intent.putExtra("String_Node_Str",newsEntity);
  intent.setClass(getActivity(),NewsDetailActivity.class);
  startActivity(intent);
  new SetReadFlagTask(newsEntity).executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR);
}
Program: 27501
Project: 27501
Buggy source:
@Override protected NewsListEntity doInBackground(String... params){
  if (params.length == 0)   return null;
  String theKey=params[0];
  String oldContent=((NewsDataSource)getDataSource()).getContent(theKey);
  NewsListEntity newsListEntity=null;
  if (!TextUtils.isEmpty(oldContent)) {
    newsListEntity=(NewsListEntity)GsonUtils.getEntity(oldContent,NewsListEntity.class);
    if (newsListEntity != null) {
      ZhihuUtils.setReadStatus4NewsList(newsListEntity.stories);
    }
    return newsListEntity;
  }
 else {
    String newContent=null;
    try {
      newContent=getUrl(Constants.Url.URLDEFORE + ZhihuUtils.getAddedDate(theKey));
      newsListEntity=(NewsListEntity)GsonUtils.getEntity(newContent,NewsListEntity.class);
      isRefreshSuccess=!ListUtils.isEmpty(newsListEntity.stories);
    }
 catch (    IOException e) {
      e.printStackTrace();
      this.isRefreshSuccess=false;
      this.mException=e;
    }
catch (    Exception e) {
      e.printStackTrace();
      this.isRefreshSuccess=false;
      this.mException=e;
    }
    isContentSame=checkIsContentSame(oldContent,newContent);
    if (isRefreshSuccess && !isContentSame) {
      ((NewsDataSource)getDataSource()).insertOrUpdateNewsList(Constants.NEWS_LIST,theKey,newContent);
    }
    if (newsListEntity != null) {
      ZhihuUtils.setReadStatus4NewsList(newsListEntity.stories);
    }
    return newsListEntity;
  }
}

Fixed version (ground truth):
@Override protected Boolean doInBackground(String... params){
  return ZhihuApplication.getNewsReadDataSource().readNews(String.valueOf(mNewsEntity.id));
}
Program: 27502
Project: 27502
Buggy source:
@Override public void onPostExecute(NewsListEntity result){
  if (!isAdded())   return;
  mPullToRefreshLayout.setRefreshComplete();
  if (getView() != null) {
    setListShown(true);
  }
  if (result != null) {
    mNewsList=new ArrayList<NewsEntity>();
    NewsEntity tagNewsEntity=new NewsEntity();
    tagNewsEntity.isTag=true;
    tagNewsEntity.title=result.date;
    mNewsList.add(tagNewsEntity);
    mNewsList.addAll(result.stories);
    mCurrentDate=result.date;
    setAdapter(mNewsList);
  }
}

Fixed version (ground truth):
@Override protected void onPostExecute(Boolean result){
  super.onPostExecute(result);
  if (result) {
    ZhihuUtils.setReadStatus4NewsEntity(mNewsList,mNewsEntity);
    mAdapter.updateData(mNewsList);
  }
}
Program: 27503
Project: 27503
Buggy source:
@Override public void onPostExecute(ArrayList<NewsEntity> resultList,boolean isRefreshSuccess,boolean isContentSame){
  if (isAdded()) {
    mPullToRefreshLayout.setRefreshComplete();
    if (getView() != null) {
      setListShown(true);
    }
    if (isRefreshSuccess && !isContentSame) {
      mNewsList=resultList;
      if (mAdapter != null) {
        mAdapter.updateData(mNewsList);
      }
 else {
        mAdapter=new NewsAdapter(getActivity(),mNewsList);
        mListView.setAdapter(mAdapter);
      }
    }
  }
}

Fixed version (ground truth):
@Override public void onPostExecute(ArrayList<NewsEntity> resultList,boolean isRefreshSuccess,boolean isContentSame){
  if (isAdded()) {
    mPullToRefreshLayout.setRefreshComplete();
    if (getView() != null) {
      setListShown(true);
    }
    if (isRefreshSuccess && !isContentSame) {
      mNewsList=resultList;
      setAdapter(mNewsList);
    }
  }
}
Program: 27504
Project: 27504
Buggy source:
@SuppressLint("String_Node_Str") @Override protected void onActivityResult(int requestCode,int resultCode,Intent data){
  super.onActivityResult(requestCode,resultCode,data);
  if (requestCode == Constants.REQUESTCODE_SETTING) {
    NewsListFragment fragment=(NewsListFragment)getSupportFragmentManager().findFragmentById(android.R.id.content);
    fragment.updateList();
    SharedPreferences mPerferences=PreferenceManager.getDefaultSharedPreferences(this);
    if (isDarkTheme != mPerferences.getBoolean("String_Node_Str",false)) {
      recreateActivity();
    }
  }
}

Fixed version (ground truth):
@SuppressLint("String_Node_Str") @Override protected void onActivityResult(int requestCode,int resultCode,Intent data){
  super.onActivityResult(requestCode,resultCode,data);
  if (requestCode == Constants.REQUESTCODE_SETTING) {
    SharedPreferences mPerferences=PreferenceManager.getDefaultSharedPreferences(this);
    if (isDarkTheme != mPerferences.getBoolean("String_Node_Str",false)) {
      recreateActivity();
    }
  }
}
Program: 27505
Project: 27505
Buggy source:
@Override protected void onCreate(Bundle arg0){
  super.onCreate(arg0);
  getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  Bundle bundle=new Bundle();
  bundle.putString("String_Node_Str",getIntent().getStringExtra("String_Node_Str"));
  Fragment newFragment=getFragment();
  newFragment.setArguments(bundle);
  if (newFragment != null) {
    getSupportFragmentManager().beginTransaction().replace(android.R.id.content,newFragment).commit();
  }
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  if (savedInstanceState == null) {
    mImageUrl=getIntent().getStringExtra("String_Node_Str");
    Bundle bundle=new Bundle();
    bundle.putString("String_Node_Str",mImageUrl);
    Fragment newFragment=getFragment();
    newFragment.setArguments(bundle);
    if (newFragment != null) {
      getSupportFragmentManager().beginTransaction().replace(android.R.id.content,newFragment).commit();
    }
  }
 else {
    mImageUrl=savedInstanceState.getString(NEWS_DETAIL_IMAGE);
  }
}
Program: 27506
Project: 27506
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  Bundle bundle=getArguments();
  mImageUrl=bundle != null ? bundle.getString("String_Node_Str") : "String_Node_Str";
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  if (savedInstanceState == null) {
    Bundle bundle=getArguments();
    mImageUrl=bundle != null ? bundle.getString("String_Node_Str") : "String_Node_Str";
  }
 else {
    mImageUrl=savedInstanceState.getString(IMAGE_URL);
  }
}
Program: 27508
Project: 27508
Buggy source:
@Override protected void doRefresh(){
  new GetNewsDetailTask(getActivity(),this).executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR,String.valueOf(mNewsId));
}

Fixed version (ground truth):
@Override protected void doRefresh(){
  if (!isAdded()) {
    new GetNewsDetailTask(getActivity(),this).executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR,String.valueOf(mNewsId));
  }
}
Program: 27509
Project: 27509
Buggy source:
@Override public Optional<LightEmissionProperty> getFor(Location<World> location){
  net.minecraft.world.World world=(net.minecraft.world.World)location.getExtent();
  Block block=(Block)location.getBlockType();
  final BlockState blockState=location.getBlock();
  return Optional.of(new LightEmissionProperty(block.getLightValue(BlockUtil.toNative(blockState),world,VecHelper.toBlockPos(location))));
}

Fixed version (ground truth):
@Override public Optional<LightEmissionProperty> getFor(Location<World> location){
}
Program: 27510
Project: 27510
Buggy source:
@Override protected Optional<MatterProperty> getForBlock(IBlockState block){
  if (block.getBlock() instanceof BlockLiquid || block.getBlock() instanceof BlockFluidBase || block.getBlock() instanceof IFluidBlock) {
    return Optional.of(LIQUID);
  }
 else   if (block.getMaterial() == Material.AIR) {
    return Optional.of(GAS);
  }
 else {
    return Optional.of(SOLID);
  }
}

Fixed version (ground truth):
@Override protected Optional<MatterProperty> getForBlock(@Nullable Location<?> location,IBlockState block){
  if (block.getBlock() instanceof BlockLiquid || block.getBlock() instanceof BlockFluidBase || block.getBlock() instanceof IFluidBlock) {
    return Optional.of(LIQUID);
  }
 else   if (block.getMaterial() == Material.AIR) {
    return Optional.of(GAS);
  }
 else {
    return Optional.of(SOLID);
  }
}
Program: 27511
Project: 27511
Buggy source:
private static NotifyNeighborBlockEvent callNeighborNotifyEvent(Event event){
  NotifyNeighborBlockEvent spongeEvent=(NotifyNeighborBlockEvent)event;
  LocatableBlock locatableBlock=spongeEvent.getCause().first(LocatableBlock.class).orElse(null);
  TileEntity tileEntitySource=spongeEvent.getCause().first(TileEntity.class).orElse(null);
  Location<World> sourceLocation;
  IBlockState state;
  if (locatableBlock != null) {
    sourceLocation=locatableBlock.getLocation();
    state=(IBlockState)locatableBlock.getBlockState();
  }
 else   if (tileEntitySource != null) {
    sourceLocation=tileEntitySource.getLocation();
    state=(IBlockState)sourceLocation.getBlock();
  }
 else {
    return spongeEvent;
  }
  EnumSet<EnumFacing> facings=EnumSet.noneOf(EnumFacing.class);
  for (  Map.Entry<Direction,BlockState> mapEntry : spongeEvent.getNeighbors().entrySet()) {
    if (mapEntry.getKey() != Direction.NONE) {
      facings.add(DirectionFacingProvider.getInstance().get(mapEntry.getKey()).get());
    }
  }
  if (facings.isEmpty()) {
    return spongeEvent;
  }
  BlockPos pos=((IMixinLocation)(Object)sourceLocation).getBlockPos();
  net.minecraft.world.World world=(net.minecraft.world.World)sourceLocation.getExtent();
  final NeighborNotifyEvent forgeEvent=new NeighborNotifyEvent(world,pos,state,facings,false);
  ((IMixinEventBus)MinecraftForge.EVENT_BUS).post(forgeEvent,true);
  if (forgeEvent.isCanceled()) {
    spongeEvent.setCancelled(true);
  }
  return spongeEvent;
}

Fixed version (ground truth):
private static NotifyNeighborBlockEvent callNeighborNotifyEvent(Event event){
  NotifyNeighborBlockEvent spongeEvent=(NotifyNeighborBlockEvent)event;
  LocatableBlock locatableBlock=spongeEvent.getCause().first(LocatableBlock.class).orElse(null);
  TileEntity tileEntitySource=spongeEvent.getCause().first(TileEntity.class).orElse(null);
  Location<World> sourceLocation;
  IBlockState state;
  if (locatableBlock != null) {
    sourceLocation=locatableBlock.getLocation();
    state=(IBlockState)locatableBlock.getBlockState();
  }
 else   if (tileEntitySource != null) {
    sourceLocation=tileEntitySource.getLocation();
    state=(IBlockState)sourceLocation.getBlock();
  }
 else {
    return spongeEvent;
  }
  EnumSet<EnumFacing> facings=EnumSet.noneOf(EnumFacing.class);
  for (  Map.Entry<Direction,BlockState> mapEntry : spongeEvent.getNeighbors().entrySet()) {
    if (mapEntry.getKey() != Direction.NONE) {
      facings.add(DirectionFacingProvider.getInstance().get(mapEntry.getKey()).get());
    }
  }
  if (facings.isEmpty()) {
    return spongeEvent;
  }
  BlockPos pos=VecHelper.toBlockPos(sourceLocation);
  net.minecraft.world.World world=(net.minecraft.world.World)sourceLocation.getExtent();
  final NeighborNotifyEvent forgeEvent=new NeighborNotifyEvent(world,pos,state,facings,false);
  ((IMixinEventBus)MinecraftForge.EVENT_BUS).post(forgeEvent,true);
  if (forgeEvent.isCanceled()) {
    spongeEvent.setCancelled(true);
  }
  return spongeEvent;
}
Program: 27512
Project: 27512
Buggy source:
/** 
 * @author gabizou - April 8th, 2018
 * @reason This overwrites the forge handling to cater to Sponge's villager handling.There have been too many bugs with the re-assignment of VillagerProfessions and mods not registering them normally, which ends up causing sync issues between the forge professions and sponge professions. This aims to have failsafes for handling with Sponge's system.
 */
@SuppressWarnings("String_Node_Str") @Overwrite public void populateBuyingList(){
  final VillagerRegistry.VillagerProfession professionForge=this.getProfessionForge();
  if (this.careerId != 0 && this.careerLevel != 0) {
    ++this.careerLevel;
  }
 else {
    this.careerId=professionForge.getRandomCareer(this.rand) + 1;
    this.careerLevel=1;
  }
  if (this.buyingList == null) {
    this.buyingList=new MerchantRecipeList();
  }
  int careerNumberId=this.careerId - 1;
  int careerLevel=this.careerLevel - 1;
  final VillagerRegistry.VillagerCareer career=professionForge.getCareer(careerNumberId);
  final IMixinVillagerCareer mixinCareer=(IMixinVillagerCareer)career;
  if (mixinCareer.isDelayed() && SpongeImpl.isMainThread()) {
    mixinCareer.performDelayedInit();
  }
  if (false) {
    SpongeForgeVillagerRegistry.populateOffers(this,career,careerLevel,rand);
    return;
  }
  SpongeForgeVillagerRegistry.spongePopupateList(this,professionForge,careerNumberId,careerLevel,this.rand);
}

Fixed version (ground truth):
/** 
 * @author gabizou - April 8th, 2018
 * @reason This overwrites the forge handling to cater to Sponge's villager handling.There have been too many bugs with the re-assignment of VillagerProfessions and mods not registering them normally, which ends up causing sync issues between the forge professions and sponge professions. This aims to have failsafes for handling with Sponge's system.
 */
@SuppressWarnings("String_Node_Str") @Overwrite public void populateBuyingList(){
  final VillagerRegistry.VillagerProfession professionForge=this.getProfessionForge();
  if (this.careerId != 0 && this.careerLevel != 0) {
    ++this.careerLevel;
  }
 else {
    this.careerId=professionForge.getRandomCareer(this.rand) + 1;
    this.careerLevel=1;
  }
  if (this.buyingList == null) {
    this.buyingList=new MerchantRecipeList();
  }
  int careerNumberId=this.careerId - 1;
  int careerLevel=this.careerLevel - 1;
  final VillagerRegistry.VillagerCareer career=professionForge.getCareer(careerNumberId);
  final IMixinVillagerCareer mixinCareer=(IMixinVillagerCareer)career;
  if (mixinCareer.isDelayed() && SpongeImpl.isMainThread()) {
    mixinCareer.performDelayedInit();
  }
  if (mixinCareer.isModded()) {
    SpongeForgeVillagerRegistry.populateOffers(this,career,careerLevel,rand);
    return;
  }
  SpongeForgeVillagerRegistry.spongePopupateList(this,professionForge,careerNumberId,careerLevel,this.rand);
}
Program: 27513
Project: 27513
Buggy source:
@SuppressWarnings("String_Node_Str") public static void spongePopupateList(IMixinEntityVillagerForge mixinEntityVillager,VillagerRegistry.VillagerProfession professionForge,int careerNumberId,int careerLevel,Random rand){
  if (mixinEntityVillager.getProfession() == null) {
    mixinEntityVillager.setProfession(SpongeForgeVillagerRegistry.fromNative(professionForge));
  }
  final Profession profession=mixinEntityVillager.getProfession().get();
  final VillagerRegistry.VillagerCareer career=professionForge.getCareer(careerNumberId);
  final List<Career> careers=((SpongeProfession)profession).getUnderlyingCareers();
  if (careers.size() <= careerNumberId) {
    final List<Career> underlyingCareers=((SpongeProfession)profession).getUnderlyingCareers();
    underlyingCareers.clear();
    final IMixinVillagerProfession mixinProfession=(IMixinVillagerProfession)professionForge;
    for (    VillagerRegistry.VillagerCareer villagerCareer : mixinProfession.getCareers()) {
      fromNative(villagerCareer);
    }
    if (careers.size() <= careerNumberId) {
      printMismatch(careerNumberId,profession,careers,mixinProfession);
      populateOffers(mixinEntityVillager,career,careerLevel,rand);
      return;
    }
  }
  final SpongeCareer spongeCareer=(SpongeCareer)careers.get(careerNumberId);
  SpongeVillagerRegistry.getInstance().populateOffers((Merchant)mixinEntityVillager,(List<TradeOffer>)(List<?>)mixinEntityVillager.getForgeTrades(),spongeCareer,careerLevel,rand);
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public static void spongePopupateList(IMixinEntityVillagerForge mixinEntityVillager,VillagerRegistry.VillagerProfession professionForge,int careerNumberId,int careerLevel,Random rand){
  if (!mixinEntityVillager.getProfession().isPresent()) {
    mixinEntityVillager.setProfession(SpongeForgeVillagerRegistry.fromNative(professionForge));
  }
  final Profession profession=mixinEntityVillager.getProfession().get();
  final VillagerRegistry.VillagerCareer career=professionForge.getCareer(careerNumberId);
  final List<Career> careers=((SpongeProfession)profession).getUnderlyingCareers();
  if (careers.size() <= careerNumberId) {
    final List<Career> underlyingCareers=((SpongeProfession)profession).getUnderlyingCareers();
    underlyingCareers.clear();
    final IMixinVillagerProfession mixinProfession=(IMixinVillagerProfession)professionForge;
    for (    VillagerRegistry.VillagerCareer villagerCareer : mixinProfession.getCareers()) {
      fromNative(villagerCareer);
    }
    if (careers.size() <= careerNumberId) {
      printMismatch(careerNumberId,profession,careers,mixinProfession);
      populateOffers(mixinEntityVillager,career,careerLevel,rand);
      return;
    }
  }
  final SpongeCareer spongeCareer=(SpongeCareer)careers.get(careerNumberId);
  SpongeVillagerRegistry.getInstance().populateOffers((Merchant)mixinEntityVillager,(List<TradeOffer>)(List<?>)mixinEntityVillager.getForgeTrades(),spongeCareer,careerLevel + 1,rand);
}
Program: 27514
Project: 27514
Buggy source:
/** 
 * @author gabizou - May 23rd, 2018
 * @reason - Even though Dedicated server does handle this change, I'm inlining theblock check for the player since
 * @param player
 * @param pos
 * @return True if the block is modifiable
 */
@Override @Overwrite @Override public boolean isBlockModifiable(EntityPlayer player,BlockPos pos){
  if (super.isBlockModifiable(player,pos)) {
    return true;
  }
  if (!this.isFake() && ServerUtils.isCallingFromMainThread()) {
    try (CauseStackManager.StackFrame frame=Sponge.getCauseStackManager().pushCauseFrame()){
      frame.addContext(EventContextKeys.USED_ITEM,ItemStackUtil.snapshotOf(player.getActiveItemStack()));
      return SpongeCommonEventFactory.callChangeBlockEventPre(this,pos,player).isCancelled();
    }
   }
  return false;
}

Fixed version (ground truth):
/** 
 * @author gabizou - May 23rd, 2018
 * @reason - Even though Dedicated server does handle this change, I'm inlining theblock check for the player since
 * @param player
 * @param pos
 * @return True if the block is modifiable
 */
@Overwrite @Override public boolean isBlockModifiable(EntityPlayer player,BlockPos pos){
  if (super.isBlockModifiable(player,pos)) {
    return true;
  }
  if (!this.isFake() && ServerUtils.isCallingFromMainThread()) {
    try (CauseStackManager.StackFrame frame=Sponge.getCauseStackManager().pushCauseFrame()){
      frame.addContext(EventContextKeys.USED_ITEM,ItemStackUtil.snapshotOf(player.getActiveItemStack()));
      return SpongeCommonEventFactory.callChangeBlockEventPre(this,pos,player).isCancelled();
    }
   }
  return false;
}
Program: 27515
Project: 27515
Buggy source:
@Override public Class<?> getCustomResourcePackClass(){
  if (getSource().isDirectory()) {
    return FMLFolderResourcePack.class;
  }
  return FMLFileResourcePack.class;
}

Fixed version (ground truth):
@Override public Class<?> getCustomResourcePackClass(){
  if (this.getSource().isDirectory()) {
    return FMLFolderResourcePack.class;
  }
  return FMLFileResourcePack.class;
}
Program: 27516
Project: 27516
Buggy source:
@Subscribe public void onPreInit(FMLPreInitializationEvent event){
  try {
    SpongeImpl.getGame().getEventManager().registerListeners(SpongeImpl.getPlugin().getInstance().get(),SpongeInternalListeners.getInstance());
    registerService(ChunkTicketManager.class,new SpongeChunkTicketManager());
    SpongeBootstrap.initializeServices();
    SpongeBootstrap.initializeCommands();
    SpongeImpl.getRegistry().preInit();
    SpongeModMessageHandler.init();
    Preconditions.checkArgument(Class.forName("String_Node_Str").getSuperclass().equals(SpongeEntityAICommonSuperclass.class));
    MinecraftForge.EVENT_BUS.register(new SpongeEventHooks());
    SpongeInternalListeners.getInstance().registerServiceCallback(PermissionService.class,input -> input.registerContextCalculator(new SpongeContextCalculator()));
    MinecraftForge.EVENT_BUS.register(this);
    MinecraftForge.EVENT_BUS.register(this.game.getChannelRegistrar());
    if (event.getSide().isServer()) {
      SpongeHooks.enableThreadContentionMonitoring();
    }
  }
 catch (  Throwable t) {
    this.controller.errorOccurred(this,t);
  }
}

Fixed version (ground truth):
@Subscribe public void onPreInit(FMLPreInitializationEvent event){
  try {
    SpongeImpl.getGame().getEventManager().registerListeners(SpongeImpl.getPlugin().getInstance().get(),SpongeInternalListeners.getInstance());
    this.registerService(ChunkTicketManager.class,new SpongeChunkTicketManager());
    SpongeBootstrap.initializeServices();
    SpongeBootstrap.initializeCommands();
    SpongeImpl.getRegistry().preInit();
    SpongeModMessageHandler.init();
    Preconditions.checkArgument(Class.forName("String_Node_Str").getSuperclass().equals(SpongeEntityAICommonSuperclass.class));
    MinecraftForge.EVENT_BUS.register(new SpongeEventHooks());
    SpongeInternalListeners.getInstance().registerServiceCallback(PermissionService.class,input -> input.registerContextCalculator(new SpongeContextCalculator()));
    MinecraftForge.EVENT_BUS.register(this);
    MinecraftForge.EVENT_BUS.register(this.game.getChannelRegistrar());
    if (event.getSide().isServer()) {
      SpongeHooks.enableThreadContentionMonitoring();
    }
  }
 catch (  Throwable t) {
    this.controller.errorOccurred(this,t);
  }
}
Program: 27518
Project: 27518
Buggy source:
public static LoadChunkEvent createLoadChunkEvent(ChunkEvent.Load forgeEvent){
  final boolean isMainThread=Sponge.isServerAvailable() && Sponge.getServer().isMainThread();
  if (isMainThread) {
    Sponge.getCauseStackManager().pushCause(forgeEvent.getWorld());
  }
  final Cause cause=isMainThread ? Sponge.getCauseStackManager().getCurrentCause() : Cause.of(EventContext.empty(),forgeEvent.getWorld());
  return SpongeEventFactory.createLoadChunkEvent(cause,(Chunk)forgeEvent.getChunk());
}

Fixed version (ground truth):
private static LoadChunkEvent createLoadChunkEvent(ChunkEvent.Load forgeEvent){
  final boolean isMainThread=Sponge.isServerAvailable() && Sponge.getServer().isMainThread();
  if (isMainThread) {
    Sponge.getCauseStackManager().pushCause(forgeEvent.getWorld());
  }
  final Cause cause=isMainThread ? Sponge.getCauseStackManager().getCurrentCause() : Cause.of(EventContext.empty(),forgeEvent.getWorld());
  return SpongeEventFactory.createLoadChunkEvent(cause,(Chunk)forgeEvent.getChunk());
}
Program: 27519
Project: 27519
Buggy source:
public static ChangeInventoryEvent.Pickup.Pre callEntityItemPickupEvent(Event event){
  ChangeInventoryEvent.Pickup.Pre spongeEvent=(ChangeInventoryEvent.Pickup.Pre)event;
  EntityItem entityItem=(EntityItem)spongeEvent.getTargetEntity();
  EntityItemPickupEvent forgeEvent=new EntityItemPickupEvent((EntityPlayer)spongeEvent.getCause().first(Player.class).get(),entityItem);
  ((IMixinEventBus)MinecraftForge.EVENT_BUS).post(forgeEvent,true);
  if (forgeEvent.isCanceled()) {
    spongeEvent.setCancelled(true);
  }
  return spongeEvent;
}

Fixed version (ground truth):
private static ChangeInventoryEvent.Pickup.Pre callEntityItemPickupEvent(Event event){
  final ChangeInventoryEvent.Pickup.Pre spongeEvent=(ChangeInventoryEvent.Pickup.Pre)event;
  if (spongeEvent.getTargetEntity() instanceof EntityItem) {
    final EntityItem entityItem=(EntityItem)spongeEvent.getTargetEntity();
    final Player player=spongeEvent.getCause().first(Player.class).orElse(null);
    if (player != null) {
      final EntityItemPickupEvent forgeEvent=new EntityItemPickupEvent((EntityPlayer)player,entityItem);
      ((IMixinEventBus)MinecraftForge.EVENT_BUS).post(forgeEvent,true);
      if (forgeEvent.isCanceled()) {
        spongeEvent.setCancelled(true);
      }
    }
  }
  return spongeEvent;
}
Program: 27520
Project: 27520
Buggy source:
private static void handleCustomStack(SpawnEntityEvent event){
  ListIterator<org.spongepowered.api.entity.Entity> it=event.getEntities().listIterator();
  while (it.hasNext()) {
    Entity entity=(Entity)it.next();
    if (entity.getClass().equals(EntityItem.class)) {
      ItemStack stack=((EntityItem)entity).getItem();
      if (stack.isEmpty()) {
        continue;
      }
      Item item=stack.getItem();
      if (item == null) {
        FMLLog.warning("String_Node_Str" + "String_Node_Str",entity.posX,entity.posY,entity.posZ);
        entity.setDead();
        event.setCancelled(true);
        continue;
      }
      if (item.hasCustomEntity(stack)) {
        Entity newEntity=item.createEntity(entity.getEntityWorld(),entity,stack);
        if (newEntity != null) {
          entity.setDead();
          EntityJoinWorldEvent cancelledEvent=new EntityJoinWorldEvent(entity,entity.getEntityWorld());
          cancelledEvent.setCanceled(true);
          ((IMixinEventBus)MinecraftForge.EVENT_BUS).post(cancelledEvent,true);
          if (!cancelledEvent.isCanceled()) {
            SpongeImpl.getLogger().error("String_Node_Str");
          }
          it.set((org.spongepowered.api.entity.Entity)newEntity);
          continue;
        }
      }
    }
  }
}

Fixed version (ground truth):
private static void handleCustomStack(SpawnEntityEvent event){
  ListIterator<org.spongepowered.api.entity.Entity> it=event.getEntities().listIterator();
  while (it.hasNext()) {
    Entity entity=(Entity)it.next();
    if (entity instanceof EntityItem) {
      final ItemStack stack=((EntityItem)entity).getItem();
      if (stack.isEmpty()) {
        FMLLog.warning("String_Node_Str" + "String_Node_Str",entity.posX,entity.posY,entity.posZ);
        entity.setDead();
        continue;
      }
      final Item item=stack.getItem();
      if (item.hasCustomEntity(stack)) {
        final Entity newEntity=item.createEntity(entity.getEntityWorld(),entity,stack);
        if (newEntity != null) {
          entity.setDead();
          final EntityJoinWorldEvent cancelledEvent=new EntityJoinWorldEvent(entity,entity.getEntityWorld());
          cancelledEvent.setCanceled(true);
          ((IMixinEventBus)MinecraftForge.EVENT_BUS).post(cancelledEvent,true);
          if (!cancelledEvent.isCanceled()) {
            SpongeImpl.getLogger().error("String_Node_Str");
          }
          it.set((org.spongepowered.api.entity.Entity)newEntity);
        }
      }
    }
  }
}
Program: 27522
Project: 27522
Buggy source:
public static UnloadChunkEvent createUnloadChunkEvent(ChunkEvent.Unload forgeEvent){
  final boolean isMainThread=Sponge.isServerAvailable() && Sponge.getServer().isMainThread();
  if (isMainThread) {
    Sponge.getCauseStackManager().pushCause(forgeEvent.getWorld());
  }
  final Cause cause=isMainThread ? Sponge.getCauseStackManager().getCurrentCause() : Cause.of(EventContext.empty(),forgeEvent.getWorld());
  return SpongeEventFactory.createUnloadChunkEvent(cause,(Chunk)forgeEvent.getChunk());
}

Fixed version (ground truth):
private static UnloadChunkEvent createUnloadChunkEvent(ChunkEvent.Unload forgeEvent){
  final boolean isMainThread=Sponge.isServerAvailable() && Sponge.getServer().isMainThread();
  if (isMainThread) {
    Sponge.getCauseStackManager().pushCause(forgeEvent.getWorld());
  }
  final Cause cause=isMainThread ? Sponge.getCauseStackManager().getCurrentCause() : Cause.of(EventContext.empty(),forgeEvent.getWorld());
  return SpongeEventFactory.createUnloadChunkEvent(cause,(Chunk)forgeEvent.getChunk());
}
Program: 27523
Project: 27523
Buggy source:
public static Event createSpongeEvent(net.minecraftforge.fml.common.eventhandler.Event forgeEvent){
  if (forgeEvent instanceof BlockEvent.MultiPlaceEvent) {
    return createChangeBlockEventPlace((BlockEvent.MultiPlaceEvent)forgeEvent);
  }
  if (forgeEvent instanceof BlockEvent.PlaceEvent) {
    return createChangeBlockEventPlace((BlockEvent.PlaceEvent)forgeEvent);
  }
  if (forgeEvent instanceof BlockEvent.BreakEvent) {
    return createChangeBlockEventPre((BlockEvent.BreakEvent)forgeEvent);
  }
  if (forgeEvent instanceof ServerChatEvent) {
    return createMessageChannelEventChat((ServerChatEvent)forgeEvent);
  }
  if (forgeEvent instanceof PlayerSleepInBedEvent) {
    return createSleepingEventPre((PlayerSleepInBedEvent)forgeEvent);
  }
  if (forgeEvent instanceof ChunkEvent.Load) {
    return createLoadChunkEvent((ChunkEvent.Load)forgeEvent);
  }
  if (forgeEvent instanceof ChunkEvent.Unload) {
    return createUnloadChunkEvent((ChunkEvent.Unload)forgeEvent);
  }
  return null;
}

Fixed version (ground truth):
public static Event createSpongeEvent(net.minecraftforge.fml.common.eventhandler.Event forgeEvent){
  return propgateCancellation(createSpongeEventImpl(forgeEvent),forgeEvent);
}
Program: 27526
Project: 27526
Buggy source:
public static void handlePrefireLogic(Event event){
  if (event instanceof SpawnEntityEvent) {
    handleCustomStack((SpawnEntityEvent)event);
  }
}

Fixed version (ground truth):
static void handlePrefireLogic(Event event){
  if (event instanceof SpawnEntityEvent) {
    handleCustomStack((SpawnEntityEvent)event);
  }
}
Program: 27528
Project: 27528
Buggy source:
private static InteractEntityEvent.Secondary callEntityInteractEvent(Event event){
  InteractEntityEvent.Secondary spongeEvent=(InteractEntityEvent.Secondary)event;
  Optional<Player> player=spongeEvent.getCause().first(Player.class);
  if (!player.isPresent()) {
    return null;
  }
  final EntityPlayerMP entityPlayerMP=EntityUtil.toNative(player.get());
  final EnumHand hand=entityPlayerMP.getActiveHand();
  final EntityPlayer entityPlayer=(EntityPlayer)player.get();
  final Entity entity=(Entity)spongeEvent.getTargetEntity();
  final Vector3d hitVec=spongeEvent.getInteractionPoint().orElse(null);
  PlayerInteractEvent forgeEvent=null;
  if (hitVec != null) {
    forgeEvent=new PlayerInteractEvent.EntityInteractSpecific(entityPlayer,hand,entity,VecHelper.toVec3d(hitVec));
  }
 else {
    forgeEvent=new PlayerInteractEvent.EntityInteract(entityPlayer,hand,entity);
  }
  ((IMixinEventBus)MinecraftForge.EVENT_BUS).post(forgeEvent,true);
  if (forgeEvent.isCanceled()) {
    spongeEvent.setCancelled(true);
  }
  return spongeEvent;
}

Fixed version (ground truth):
private static InteractEntityEvent.Secondary callEntityInteractEvent(Event event){
  InteractEntityEvent.Secondary spongeEvent=(InteractEntityEvent.Secondary)event;
  Optional<Player> player=spongeEvent.getCause().first(Player.class);
  if (!player.isPresent()) {
    return null;
  }
  final EntityPlayerMP entityPlayerMP=EntityUtil.toNative(player.get());
  final EnumHand hand=entityPlayerMP.getActiveHand();
  final EntityPlayer entityPlayer=(EntityPlayer)player.get();
  final Entity entity=(Entity)spongeEvent.getTargetEntity();
  final Vector3d hitVec=spongeEvent.getInteractionPoint().orElse(null);
  PlayerInteractEvent forgeEvent;
  if (hitVec != null) {
    forgeEvent=new PlayerInteractEvent.EntityInteractSpecific(entityPlayer,hand,entity,VecHelper.toVec3d(hitVec));
  }
 else {
    forgeEvent=new PlayerInteractEvent.EntityInteract(entityPlayer,hand,entity);
  }
  ((IMixinEventBus)MinecraftForge.EVENT_BUS).post(forgeEvent,true);
  if (forgeEvent.isCanceled()) {
    spongeEvent.setCancelled(true);
  }
  return spongeEvent;
}