nus-yam/ex-repair huggingface dataset:
Program: 155946
Project: 155946
Buggy source:
@Override protected Object decode(ChannelHandlerContext ctx,Channel channel,ByteBuf buf) throws Exception {
  if (buf.readableBytes() < KEEP_ALIVE_LENGTH) {
    return null;
  }
  if (buf.getUnsignedByte(buf.readerIndex()) == 0xD0) {
    ByteBuf frame=buf.readRetainedSlice(KEEP_ALIVE_LENGTH);
    if (channel != null) {
      channel.writeAndFlush(new NetworkMessage(frame,channel.remoteAddress()));
    }
    return frame;
  }
 else {
    int index=BufferUtil.indexOf("String_Node_Str",buf);
    if (index != -1) {
      ByteBuf frame=buf.readRetainedSlice(index - buf.readerIndex());
      buf.skipBytes(2);
      return frame;
    }
  }
  return null;
}

Fixed version (ground truth):
@Override protected Object decode(ChannelHandlerContext ctx,Channel channel,ByteBuf buf) throws Exception {
  if (buf.readableBytes() < KEEP_ALIVE_LENGTH) {
    return null;
  }
  if (buf.getUnsignedByte(buf.readerIndex()) == 0xD0) {
    ByteBuf frame=buf.readRetainedSlice(KEEP_ALIVE_LENGTH);
    if (channel != null) {
      frame.retain();
      channel.writeAndFlush(new NetworkMessage(frame,channel.remoteAddress()));
    }
    return frame;
  }
 else {
    int index=BufferUtil.indexOf("String_Node_Str",buf);
    if (index != -1) {
      ByteBuf frame=buf.readRetainedSlice(index - buf.readerIndex());
      buf.skipBytes(2);
      return frame;
    }
  }
  return null;
}
Program: 155947
Project: 155947
Buggy source:
@Override public void channelRead(ChannelHandlerContext ctx,Object msg) throws Exception {
  NetworkMessage networkMessage=(NetworkMessage)msg;
  Object originalMessage=networkMessage.getMessage();
  try {
    Object decodedMessage=decode(ctx.channel(),networkMessage.getRemoteAddress(),originalMessage);
    onMessageEvent(ctx.channel(),networkMessage.getRemoteAddress(),originalMessage,decodedMessage);
    if (decodedMessage == null) {
      decodedMessage=handleEmptyMessage(ctx.channel(),networkMessage.getRemoteAddress(),originalMessage);
    }
    if (decodedMessage != null) {
      if (decodedMessage instanceof Collection) {
        for (        Object o : (Collection)decodedMessage) {
          saveOriginal(o,originalMessage);
          ctx.fireChannelRead(o);
        }
      }
 else {
        saveOriginal(decodedMessage,originalMessage);
        ctx.fireChannelRead(decodedMessage);
      }
    }
  }
  finally {
    if (originalMessage instanceof ReferenceCounted) {
      ((ReferenceCounted)originalMessage).release();
    }
  }
}

Fixed version (ground truth):
@Override public void channelRead(ChannelHandlerContext ctx,Object msg) throws Exception {
  NetworkMessage networkMessage=(NetworkMessage)msg;
  Object originalMessage=networkMessage.getMessage();
  try {
    Object decodedMessage=decode(ctx.channel(),networkMessage.getRemoteAddress(),originalMessage);
    onMessageEvent(ctx.channel(),networkMessage.getRemoteAddress(),originalMessage,decodedMessage);
    if (decodedMessage == null) {
      decodedMessage=handleEmptyMessage(ctx.channel(),networkMessage.getRemoteAddress(),originalMessage);
    }
    if (decodedMessage != null) {
      if (decodedMessage instanceof Collection) {
        for (        Object o : (Collection)decodedMessage) {
          saveOriginal(o,originalMessage);
          ctx.fireChannelRead(o);
        }
      }
 else {
        saveOriginal(decodedMessage,originalMessage);
        ctx.fireChannelRead(decodedMessage);
      }
    }
  }
  finally {
    ReferenceCountUtil.release(originalMessage);
  }
}
Program: 155948
Project: 155948
Buggy source:
@Override protected Object decode(Channel channel,SocketAddress remoteAddress,Object msg) throws Exception {
  Parser parser=new Parser(PATTERN,(String)msg);
  if (!parser.matches()) {
    return null;
  }
  String type=parser.next();
  DeviceSession deviceSession=getDeviceSession(channel,remoteAddress,parser.next());
  if (deviceSession == null) {
    return null;
  }
  Position position=new Position(getProtocolName());
  position.setDeviceId(deviceSession.getDeviceId());
  DateBuilder dateBuilder=new DateBuilder();
  dateBuilder.setDateReverse(parser.nextInt(),parser.nextInt(),parser.nextInt());
  position.setValid(true);
  position.setLatitude(parser.nextDouble());
  position.setLongitude(parser.nextDouble());
  dateBuilder.setHour(parser.nextInt()).setMinute(parser.nextInt());
  position.setTime(dateBuilder.getDate());
  return position;
}

Fixed version (ground truth):
@Override protected Object decode(Channel channel,SocketAddress remoteAddress,Object msg) throws Exception {
  Parser parser=new Parser(PATTERN,(String)msg);
  if (!parser.matches()) {
    return null;
  }
  parser.next();
  DeviceSession deviceSession=getDeviceSession(channel,remoteAddress,parser.next());
  if (deviceSession == null) {
    return null;
  }
  Position position=new Position(getProtocolName());
  position.setDeviceId(deviceSession.getDeviceId());
  DateBuilder dateBuilder=new DateBuilder();
  dateBuilder.setDateReverse(parser.nextInt(),parser.nextInt(),parser.nextInt());
  position.setValid(true);
  position.setLatitude(parser.nextDouble());
  position.setLongitude(parser.nextDouble());
  dateBuilder.setHour(parser.nextInt()).setMinute(parser.nextInt());
  position.setTime(dateBuilder.getDate());
  return position;
}
Program: 155949
Project: 155949
Buggy source:
private String decodeAlarm(long status){
  if ((status & 0x02000000) > 0) {
    return Position.ALARM_GEOFENCE_ENTER;
  }
  if ((status & 0x04000000) > 0) {
    return Position.ALARM_GEOFENCE_EXIT;
  }
  if ((status & 0x08000000) > 0) {
    return Position.ALARM_LOW_BATTERY;
  }
  if ((status & 0x20000000) > 0) {
    return Position.ALARM_VIBRATION;
  }
  if ((status & 0x80000000) > 0) {
    return Position.ALARM_OVERSPEED;
  }
  if ((status & 0x00010000) > 0) {
    return Position.ALARM_SOS;
  }
  if ((status & 0x00040000) > 0) {
    return Position.ALARM_POWER_CUT;
  }
  return null;
}

Fixed version (ground truth):
private String decodeAlarm(long status){
  if ((status & 0x02000000) != 0) {
    return Position.ALARM_GEOFENCE_ENTER;
  }
  if ((status & 0x04000000) != 0) {
    return Position.ALARM_GEOFENCE_EXIT;
  }
  if ((status & 0x08000000) != 0) {
    return Position.ALARM_LOW_BATTERY;
  }
  if ((status & 0x20000000) != 0) {
    return Position.ALARM_VIBRATION;
  }
  if ((status & 0x80000000) != 0) {
    return Position.ALARM_OVERSPEED;
  }
  if ((status & 0x00010000) != 0) {
    return Position.ALARM_SOS;
  }
  if ((status & 0x00040000) != 0) {
    return Position.ALARM_POWER_CUT;
  }
  return null;
}
Program: 155952
Project: 155952
Buggy source:
@Test public void testDecode() throws Exception {
  EgtsProtocolDecoder decoder=new EgtsProtocolDecoder(new EgtsProtocol());
  verifyNull(decoder,binary(ByteOrder.LITTLE_ENDIAN,"String_Node_Str"));
  verifyPositions(decoder,binary(ByteOrder.LITTLE_ENDIAN,"String_Node_Str"),position("String_Node_Str",true,51.67569,55.59189));
  verifyPositions(decoder,binary(ByteOrder.LITTLE_ENDIAN,"String_Node_Str"));
  verifyPositions(decoder,binary(ByteOrder.LITTLE_ENDIAN,"String_Node_Str"));
}

Fixed version (ground truth):
@Test public void testDecode() throws Exception {
  EgtsProtocolDecoder decoder=new EgtsProtocolDecoder(new EgtsProtocol());
  verifyNull(decoder,binary(ByteOrder.LITTLE_ENDIAN,"String_Node_Str"));
  verifyNull(decoder,binary(ByteOrder.LITTLE_ENDIAN,"String_Node_Str"));
  verifyPositions(decoder,binary(ByteOrder.LITTLE_ENDIAN,"String_Node_Str"));
  verifyPositions(decoder,binary(ByteOrder.LITTLE_ENDIAN,"String_Node_Str"),position("String_Node_Str",true,51.67569,55.59189));
  verifyPositions(decoder,binary(ByteOrder.LITTLE_ENDIAN,"String_Node_Str"));
  verifyPositions(decoder,binary(ByteOrder.LITTLE_ENDIAN,"String_Node_Str"));
}
Program: 155953
Project: 155953
Buggy source:
@Test public void testDecode() throws Exception {
  MegastekProtocolDecoder decoder=new MegastekProtocolDecoder(new MegastekProtocol());
  verifyNull(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyNull(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyNull(decoder,text("String_Node_Str"));
  verifyNull(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"),position("String_Node_Str",true,22.63675,114.03299));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
}

Fixed version (ground truth):
@Test public void testDecode() throws Exception {
  MegastekProtocolDecoder decoder=new MegastekProtocolDecoder(new MegastekProtocol());
  verifyPosition(decoder,text("String_Node_Str"));
  verifyNull(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyNull(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyNull(decoder,text("String_Node_Str"));
  verifyNull(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"),position("String_Node_Str",true,22.63675,114.03299));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
}
Program: 155954
Project: 155954
Buggy source:
public static byte[] parseHex(String string){
  try {
    return Hex.decodeHex(string);
  }
 catch (  DecoderException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
public static byte[] parseHex(String string){
  try {
    return Hex.decodeHex(string.toCharArray());
  }
 catch (  DecoderException e) {
    throw new RuntimeException(e);
  }
}
Program: 155955
Project: 155955
Buggy source:
private String decodeAlarm(String event){
  if (event.equals('Z')) {
    return Position.ALARM_LOW_BATTERY;
  }
 else   if (event.equals('X')) {
    return Position.ALARM_GEOFENCE_ENTER;
  }
 else   if (event.equals('T')) {
    return Position.ALARM_TAMPERING;
  }
 else   if (event.equals("String_Node_Str")) {
    return Position.ALARM_POWER_OFF;
  }
 else   if (event.equals('X')) {
    return Position.ALARM_GEOFENCE_ENTER;
  }
 else   if (event.equals('8')) {
    return Position.ALARM_SHOCK;
  }
 else   if (event.equals('7') && event.equals('4')) {
    return Position.ALARM_GEOFENCE_EXIT;
  }
 else   if (event.equals('6')) {
    return Position.ALARM_OVERSPEED;
  }
 else   if (event.equals('3')) {
    return Position.ALARM_SOS;
  }
  return null;
}

Fixed version (ground truth):
private String decodeAlarm(String event){
switch (event) {
case "String_Node_Str":
    return Position.ALARM_LOW_BATTERY;
case "String_Node_Str":
  return Position.ALARM_GEOFENCE_ENTER;
case "String_Node_Str":
return Position.ALARM_TAMPERING;
case "String_Node_Str":
return Position.ALARM_POWER_OFF;
case "String_Node_Str":
return Position.ALARM_SHOCK;
case "String_Node_Str":
case "String_Node_Str":
return Position.ALARM_GEOFENCE_EXIT;
case "String_Node_Str":
return Position.ALARM_OVERSPEED;
case "String_Node_Str":
return Position.ALARM_SOS;
default :
return null;
}
}
Program: 155961
Project: 155961
Buggy source:
@Test public void testDecode() throws Exception {
  Vt200ProtocolDecoder decoder=new Vt200ProtocolDecoder(new Vt200Protocol());
  verifyNull(decoder,binary("String_Node_Str"));
  verifyAttributes(decoder,binary("String_Node_Str"));
  verifyPosition(decoder,binary("String_Node_Str"));
  verifyPosition(decoder,binary("String_Node_Str"));
  verifyNull(decoder,binary("String_Node_Str"));
  verifyNull(decoder,binary("String_Node_Str"));
  verifyAttributes(decoder,binary("String_Node_Str"));
  verifyNull(decoder,binary("String_Node_Str"));
  verifyNull(decoder,binary("String_Node_Str"));
  verifyPosition(decoder,binary("String_Node_Str"));
  verifyNull(decoder,binary("String_Node_Str"));
  verifyAttributes(decoder,binary("String_Node_Str"));
  verifyPosition(decoder,binary("String_Node_Str"));
  verifyPosition(decoder,binary("String_Node_Str"));
}

Fixed version (ground truth):
@Test public void testDecode() throws Exception {
  Vt200ProtocolDecoder decoder=new Vt200ProtocolDecoder(new Vt200Protocol());
  verifyPosition(decoder,binary("String_Node_Str"));
  verifyNull(decoder,binary("String_Node_Str"));
  verifyAttributes(decoder,binary("String_Node_Str"));
  verifyPosition(decoder,binary("String_Node_Str"));
  verifyPosition(decoder,binary("String_Node_Str"));
  verifyNull(decoder,binary("String_Node_Str"));
  verifyNull(decoder,binary("String_Node_Str"));
  verifyAttributes(decoder,binary("String_Node_Str"));
  verifyNull(decoder,binary("String_Node_Str"));
  verifyNull(decoder,binary("String_Node_Str"));
  verifyPosition(decoder,binary("String_Node_Str"));
  verifyNull(decoder,binary("String_Node_Str"));
  verifyAttributes(decoder,binary("String_Node_Str"));
  verifyPosition(decoder,binary("String_Node_Str"));
  verifyPosition(decoder,binary("String_Node_Str"));
}
Program: 155962
Project: 155962
Buggy source:
private boolean skipLimit(Position position,Position last){
  if (skipLimit != 0 && last != null) {
    return (position.getFixTime().getTime() - last.getFixTime().getTime()) > skipLimit;
  }
  return false;
}

Fixed version (ground truth):
private boolean skipLimit(Position position,Position last){
  if (skipLimit != 0 && last != null) {
    return (position.getServerTime().getTime() - last.getServerTime().getTime()) > skipLimit;
  }
  return false;
}
Program: 155963
Project: 155963
Buggy source:
@Path("String_Node_Str") @PUT public Response updateTotalDistance(DeviceTotalDistance entity) throws SQLException {
  Context.getPermissionsManager().checkDevice(getUserId(),entity.getDeviceId());
  Context.getDeviceManager().resetTotalDistance(entity);
  LogAction.resetTotalDistance(getUserId(),entity.getDeviceId());
  return Response.noContent().build();
}

Fixed version (ground truth):
@Path("String_Node_Str") @PUT public Response updateTotalDistance(DeviceTotalDistance entity) throws SQLException {
  Context.getPermissionsManager().checkDeviceManagerOrAdmin(getUserId(),entity.getDeviceId());
  Context.getDeviceManager().resetTotalDistance(entity);
  LogAction.resetTotalDistance(getUserId(),entity.getDeviceId());
  return Response.noContent().build();
}
Program: 155964
Project: 155964
Buggy source:
public void checkDevice(long userId,long deviceId) throws SecurityException {
  if (!Context.getDeviceManager().getUserItems(userId).contains(deviceId) && !getUserAdmin(userId)) {
    checkManager(userId);
    for (    long managedUserId : usersManager.getUserItems(userId)) {
      if (Context.getDeviceManager().getUserItems(managedUserId).contains(deviceId)) {
        return;
      }
    }
    throw new SecurityException("String_Node_Str");
  }
}

Fixed version (ground truth):
public void checkDevice(long userId,long deviceId) throws SecurityException {
  if (!Context.getDeviceManager().getUserItems(userId).contains(deviceId)) {
    checkDeviceManagerOrAdmin(userId,deviceId);
  }
}
Program: 155968
Project: 155968
Buggy source:
@Override protected void addSpecificHandlers(ChannelPipeline pipeline){
  pipeline.addLast("String_Node_Str",new CharacterDelimiterFrameDecoder(1024,'\r'));
  pipeline.addLast("String_Node_Str",new StringDecoder());
  pipeline.addLast("String_Node_Str",new GenxProtocolDecoder(GenxProtocol.this));
}

Fixed version (ground truth):
@Override protected void addSpecificHandlers(ChannelPipeline pipeline){
  pipeline.addLast("String_Node_Str",new LineBasedFrameDecoder(1024));
  pipeline.addLast("String_Node_Str",new StringDecoder());
  pipeline.addLast("String_Node_Str",new GenxProtocolDecoder(GenxProtocol.this));
}
Program: 155969
Project: 155969
Buggy source:
@Override public void initTrackerServers(List<TrackerServer> serverList){
  serverList.add(new TrackerServer(new ServerBootstrap(),getName()){
    @Override protected void addSpecificHandlers(    ChannelPipeline pipeline){
      pipeline.addLast("String_Node_Str",new CharacterDelimiterFrameDecoder(1024,'\r'));
      pipeline.addLast("String_Node_Str",new StringDecoder());
      pipeline.addLast("String_Node_Str",new GenxProtocolDecoder(GenxProtocol.this));
    }
  }
);
}

Fixed version (ground truth):
@Override public void initTrackerServers(List<TrackerServer> serverList){
  serverList.add(new TrackerServer(new ServerBootstrap(),getName()){
    @Override protected void addSpecificHandlers(    ChannelPipeline pipeline){
      pipeline.addLast("String_Node_Str",new LineBasedFrameDecoder(1024));
      pipeline.addLast("String_Node_Str",new StringDecoder());
      pipeline.addLast("String_Node_Str",new GenxProtocolDecoder(GenxProtocol.this));
    }
  }
);
}
Program: 155970
Project: 155970
Buggy source:
@Override protected Object decode(Channel channel,SocketAddress remoteAddress,Object msg) throws Exception {
  String[] values=((String)msg).split("String_Node_Str");
  Position position=new Position();
  position.setProtocol(getProtocolName());
  position.setValid(true);
  for (int i=0; i < Math.min(values.length,reportColumns.length); i++) {
switch (reportColumns[i]) {
case 1:
      DeviceSession deviceSession=getDeviceSession(channel,remoteAddress,values[i]);
    if (deviceSession != null) {
      position.setDeviceId(deviceSession.getDeviceId());
    }
  break;
case 2:
position.setTime(new SimpleDateFormat("String_Node_Str").parse(values[i]));
break;
case 3:
position.setLatitude(Double.parseDouble(values[i]));
break;
case 4:
position.setLongitude(Double.parseDouble(values[i]));
break;
default :
break;
}
}
return position;
}

Fixed version (ground truth):
@Override protected Object decode(Channel channel,SocketAddress remoteAddress,Object msg) throws Exception {
  String[] values=((String)msg).split("String_Node_Str");
  Position position=new Position();
  position.setProtocol(getProtocolName());
  position.setValid(true);
  for (int i=0; i < Math.min(values.length,reportColumns.length); i++) {
switch (reportColumns[i]) {
case 1:
      DeviceSession deviceSession=getDeviceSession(channel,remoteAddress,values[i]);
    if (deviceSession != null) {
      position.setDeviceId(deviceSession.getDeviceId());
    }
  break;
case 2:
position.setTime(new SimpleDateFormat("String_Node_Str").parse(values[i]));
break;
case 3:
position.setLatitude(Double.parseDouble(values[i]));
break;
case 4:
position.setLongitude(Double.parseDouble(values[i]));
break;
default :
break;
}
}
return position.getDeviceId() != 0 ? position : null;
}
Program: 155971
Project: 155971
Buggy source:
private boolean decodeGps(Position position,ChannelBuffer buf,boolean hasLength){
  DateBuilder dateBuilder=new DateBuilder(timeZone).setDate(buf.readUnsignedByte(),buf.readUnsignedByte(),buf.readUnsignedByte()).setTime(buf.readUnsignedByte(),buf.readUnsignedByte(),buf.readUnsignedByte());
  position.setTime(dateBuilder.getDate());
  if (hasLength && buf.readUnsignedByte() == 0) {
    return false;
  }
  int length=buf.readUnsignedByte();
  position.set(Position.KEY_SATELLITES,BitUtil.to(length,4));
  length=BitUtil.from(length,4);
  double latitude=buf.readUnsignedInt() / 60.0 / 30000.0;
  double longitude=buf.readUnsignedInt() / 60.0 / 30000.0;
  position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedByte()));
  int flags=buf.readUnsignedShort();
  position.setCourse(BitUtil.to(flags,10));
  position.setValid(BitUtil.check(flags,12));
  if (!BitUtil.check(flags,10)) {
    latitude=-latitude;
  }
  if (BitUtil.check(flags,11)) {
    longitude=-longitude;
  }
  position.setLatitude(latitude);
  position.setLongitude(longitude);
  if (BitUtil.check(flags,14)) {
    position.set(Position.KEY_IGNITION,BitUtil.check(flags,15));
  }
  return true;
}

Fixed version (ground truth):
private boolean decodeGps(Position position,ChannelBuffer buf,boolean hasLength){
  DateBuilder dateBuilder=new DateBuilder(timeZone).setDate(buf.readUnsignedByte(),buf.readUnsignedByte(),buf.readUnsignedByte()).setTime(buf.readUnsignedByte(),buf.readUnsignedByte(),buf.readUnsignedByte());
  position.setTime(dateBuilder.getDate());
  if (hasLength && buf.readUnsignedByte() == 0) {
    return false;
  }
  position.set(Position.KEY_SATELLITES,BitUtil.to(buf.readUnsignedByte(),4));
  double latitude=buf.readUnsignedInt() / 60.0 / 30000.0;
  double longitude=buf.readUnsignedInt() / 60.0 / 30000.0;
  position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedByte()));
  int flags=buf.readUnsignedShort();
  position.setCourse(BitUtil.to(flags,10));
  position.setValid(BitUtil.check(flags,12));
  if (!BitUtil.check(flags,10)) {
    latitude=-latitude;
  }
  if (BitUtil.check(flags,11)) {
    longitude=-longitude;
  }
  position.setLatitude(latitude);
  position.setLongitude(longitude);
  if (BitUtil.check(flags,14)) {
    position.set(Position.KEY_IGNITION,BitUtil.check(flags,15));
  }
  return true;
}
Program: 155973
Project: 155973
Buggy source:
private Object decodeInf(Channel channel,SocketAddress remoteAddress,String sentence){
  org.traccar.helper.PatternUtil.MatchResult matchResult=org.traccar.helper.PatternUtil.checkPattern(PATTERN_INF.pattern(),sentence);
  Parser parser=new Parser(PATTERN_INF,sentence);
  Position position=initPosition(parser,channel,remoteAddress);
  if (position == null) {
    return null;
  }
  position.set(Position.KEY_STATUS,parser.next());
  position.set(Position.KEY_RSSI,parser.nextInt());
  parser.next();
  position.set(Position.KEY_BATTERY,parser.nextDouble(0));
  position.set(Position.KEY_CHARGE,parser.nextInt(0) == 1);
  position.set(Position.KEY_BATTERY_LEVEL,parser.nextInt());
  position.set(Position.PREFIX_TEMP + 1,parser.next());
  position.set(Position.PREFIX_ADC + 1,parser.next());
  position.set(Position.PREFIX_ADC + 2,parser.next());
  position.set(Position.KEY_INPUT,parser.next());
  position.set(Position.KEY_OUTPUT,parser.next());
  getLastLocation(position,parser.nextDateTime());
  position.set(Position.KEY_INDEX,parser.nextHexInt(0));
  return position;
}

Fixed version (ground truth):
private Object decodeInf(Channel channel,SocketAddress remoteAddress,String sentence){
  Parser parser=new Parser(PATTERN_INF,sentence);
  Position position=initPosition(parser,channel,remoteAddress);
  if (position == null) {
    return null;
  }
  position.set(Position.KEY_STATUS,parser.next());
  position.set(Position.KEY_RSSI,parser.nextInt());
  parser.next();
  position.set(Position.KEY_BATTERY,parser.nextDouble(0));
  position.set(Position.KEY_CHARGE,parser.nextInt(0) == 1);
  position.set(Position.KEY_BATTERY_LEVEL,parser.nextInt());
  position.set(Position.PREFIX_TEMP + 1,parser.next());
  position.set(Position.PREFIX_ADC + 1,parser.next());
  position.set(Position.PREFIX_ADC + 2,parser.next());
  position.set(Position.KEY_INPUT,parser.next());
  position.set(Position.KEY_OUTPUT,parser.next());
  getLastLocation(position,parser.nextDateTime());
  position.set(Position.KEY_INDEX,parser.nextHexInt(0));
  return position;
}
Program: 155975
Project: 155975
Buggy source:
private Collection<Permission> getPermissions(Class<? extends BaseModel> owner,Class<? extends BaseModel> property) throws SQLException, ClassNotFoundException {
  return QueryBuilder.create(dataSource,getQuery(ACTION_SELECT_ALL,owner,property)).executePermissionsQuery();
}

Fixed version (ground truth):
public Collection<Permission> getPermissions(Class<? extends BaseModel> owner,Class<? extends BaseModel> property) throws SQLException, ClassNotFoundException {
  return QueryBuilder.create(dataSource,getQuery(ACTION_SELECT_ALL,owner,property)).executePermissionsQuery();
}
Program: 155980
Project: 155980
Buggy source:
private File createFile(String uniqueId,String name) throws IOException {
  Path filePath=Paths.get(path,uniqueId,name);
  Files.createDirectories(filePath.getParent());
  return filePath.toFile();
}

Fixed version (ground truth):
private File createFile(String uniqueId,String name) throws IOException {
  Path filePath=Paths.get(path,uniqueId,name);
  Path directoryPath=filePath.getParent();
  if (directoryPath != null) {
    Files.createDirectories(directoryPath);
  }
  return filePath.toFile();
}
Program: 155982
Project: 155982
Buggy source:
public void checkUserLimit(long userId) throws SecurityException {
  int userLimit=users.get(userId).getUserLimit();
  if (userLimit != -1 && userPermissions.get(userId).size() >= userLimit) {
    throw new SecurityException("String_Node_Str");
  }
}

Fixed version (ground truth):
public void checkUserLimit(long userId) throws SecurityException {
  int userLimit=users.get(userId).getUserLimit();
  if (userLimit != -1 && getUserPermissions(userId).size() >= userLimit) {
    throw new SecurityException("String_Node_Str");
  }
}
Program: 155983
Project: 155983
Buggy source:
public void checkManager(long userId,long managedUserId) throws SecurityException {
  checkManager(userId);
  if (!userPermissions.get(userId).contains(managedUserId)) {
    throw new SecurityException("String_Node_Str");
  }
}

Fixed version (ground truth):
public void checkManager(long userId,long managedUserId) throws SecurityException {
  checkManager(userId);
  if (!getUserPermissions(userId).contains(managedUserId)) {
    throw new SecurityException("String_Node_Str");
  }
}
Program: 155984
Project: 155984
Buggy source:
public boolean hasKey(String key){
  if (useEnvVars && System.getenv().containsKey(getEnvVarName(key))) {
    return true;
  }
  return properties.containsKey(key);
}

Fixed version (ground truth):
public boolean hasKey(String key){
  return useEnvironmentVariables && System.getenv().containsKey(getEnvironmentVariableName(key)) || properties.containsKey(key);
}
Program: 155985
Project: 155985
Buggy source:
void load(String file) throws IOException {
  String defaultConfigFile=properties.getProperty("String_Node_Str");
  if (defaultConfigFile != null) {
    try (InputStream inputStream=new FileInputStream(defaultConfigFile)){
      properties.loadFromXML(inputStream);
    }
   }
  try (InputStream inputStream=new FileInputStream(file)){
    Properties props=new Properties();
    props.loadFromXML(inputStream);
    properties.putAll(props);
  }
   if ("String_Node_Str".equals(System.getenv("String_Node_Str"))) {
    useEnvVars=true;
  }
 else {
    useEnvVars=properties.getProperty("String_Node_Str","String_Node_Str").equalsIgnoreCase("String_Node_Str");
  }
}

Fixed version (ground truth):
void load(String file) throws IOException {
  Properties mainProperties=new Properties();
  try (InputStream inputStream=new FileInputStream(file)){
    mainProperties.loadFromXML(inputStream);
  }
   String defaultConfigFile=mainProperties.getProperty("String_Node_Str");
  if (defaultConfigFile != null) {
    try (InputStream inputStream=new FileInputStream(defaultConfigFile)){
      properties.loadFromXML(inputStream);
    }
   }
  properties.putAll(mainProperties);
  useEnvironmentVariables=Boolean.parseBoolean(System.getenv("String_Node_Str")) || Boolean.parseBoolean(properties.getProperty("String_Node_Str"));
}
Program: 155986
Project: 155986
Buggy source:
private ChannelBuffer encodeContent(String content){
  ChannelBuffer buf=ChannelBuffers.dynamicBuffer();
  byte[] contentBytes=content.getBytes();
  buf.writeShort(contentBytes.length + 6);
  buf.writeShort(0);
  buf.writeByte(0x04);
  buf.writeByte(0);
  buf.writeBytes(content.getBytes(StandardCharsets.UTF_8));
  return buf;
}

Fixed version (ground truth):
private ChannelBuffer encodeContent(String content){
  ChannelBuffer buf=ChannelBuffers.dynamicBuffer();
  buf.writeShort(content.length() + 6);
  buf.writeShort(0);
  buf.writeByte(0x04);
  buf.writeByte(0);
  buf.writeBytes(content.getBytes(StandardCharsets.US_ASCII));
  return buf;
}
Program: 155988
Project: 155988
Buggy source:
@Override protected Object decode(Channel channel,SocketAddress remoteAddress,Object msg) throws Exception {
  Parser parser=new Parser(PATTERN,(String)msg);
  if (!parser.matches()) {
    return null;
  }
  Position position=new Position();
  position.setProtocol(getProtocolName());
  DeviceSession deviceSession=getDeviceSession(channel,remoteAddress,parser.next());
  if (deviceSession == null) {
    return null;
  }
  position.setDeviceId(deviceSession.getDeviceId());
  int event=parser.nextInt();
  position.set(Position.KEY_EVENT,event);
  position.set(Position.KEY_ALARM,decodeAlarm(event));
  if (event == 11) {
    position.set(Position.KEY_IGNITION,true);
  }
 else   if (event == 12) {
    position.set(Position.KEY_IGNITION,false);
  }
  position.setTime(parser.nextDateTime(Parser.DateTimeFormat.DMY_HMS));
  if (parser.hasNext(6)) {
    position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_MIN_MIN));
    position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_MIN_MIN));
  }
  if (parser.hasNext(2)) {
    position.setLongitude(parser.nextDouble() / 10000);
    position.setLatitude(parser.nextDouble() / 10000);
  }
  position.setValid(parser.nextInt() != 1);
  position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
  position.setCourse(parser.nextDouble());
  if (parser.hasNext()) {
    position.set(Position.KEY_SATELLITES,parser.nextInt());
  }
  position.set(Position.KEY_BATTERY,parser.nextInt());
  if (parser.hasNext()) {
    position.set(Position.KEY_POWER,parser.nextInt());
  }
  return position;
}

Fixed version (ground truth):
@Override protected Object decode(Channel channel,SocketAddress remoteAddress,Object msg) throws Exception {
  Parser parser=new Parser(PATTERN,(String)msg);
  if (!parser.matches()) {
    return null;
  }
  Position position=new Position();
  position.setProtocol(getProtocolName());
  DeviceSession deviceSession=getDeviceSession(channel,remoteAddress,parser.next());
  if (deviceSession == null) {
    return null;
  }
  position.setDeviceId(deviceSession.getDeviceId());
  int event=parser.nextInt();
  position.set(Position.KEY_EVENT,event);
  position.set(Position.KEY_ALARM,decodeAlarm(event));
  if (event == 11) {
    position.set(Position.KEY_IGNITION,true);
  }
 else   if (event == 12) {
    position.set(Position.KEY_IGNITION,false);
  }
  position.setTime(parser.nextDateTime(Parser.DateTimeFormat.DMY_HMS));
  if (parser.hasNext(6)) {
    position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_MIN_MIN));
    position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_MIN_MIN));
  }
  if (parser.hasNext(2)) {
    position.setLongitude(parser.nextDouble() / 10000);
    position.setLatitude(parser.nextDouble() / 10000);
  }
  position.setValid(parser.nextInt() != 1);
  position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
  position.setCourse(parser.nextDouble());
  if (parser.hasNext()) {
    position.set(Position.KEY_SATELLITES,parser.nextInt());
  }
  position.set(Position.KEY_BATTERY,parser.nextInt());
  return position;
}
Program: 155989
Project: 155989
Buggy source:
@Test public void testDecode() throws Exception {
  TelicProtocolDecoder decoder=new TelicProtocolDecoder(new TelicProtocol());
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyNothing(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyNothing(decoder,text("String_Node_Str"));
  verifyNothing(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyNothing(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyNothing(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"),position("String_Node_Str",true,47.53410,16.66530));
  verifyPosition(decoder,text("String_Node_Str"));
}

Fixed version (ground truth):
@Test public void testDecode() throws Exception {
  TelicProtocolDecoder decoder=new TelicProtocolDecoder(new TelicProtocol());
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyNothing(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyNothing(decoder,text("String_Node_Str"));
  verifyNothing(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyNothing(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyNothing(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"),position("String_Node_Str",true,47.53410,16.66530));
  verifyPosition(decoder,text("String_Node_Str"));
}
Program: 155990
Project: 155990
Buggy source:
public TaipProtocolDecoder(TaipProtocol protocol,boolean sendResponse){
  super(protocol);
}

Fixed version (ground truth):
public TaipProtocolDecoder(TaipProtocol protocol){
  super(protocol);
}
Program: 155991
Project: 155991
Buggy source:
@Test public void testDecode() throws Exception {
  TaipProtocolDecoder decoder=new TaipProtocolDecoder(new TaipProtocol(),false);
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"),position("String_Node_Str",true,-26.82523,-65.23682));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"),position("String_Node_Str",true,25.78391,-80.29452));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
}

Fixed version (ground truth):
@Test public void testDecode() throws Exception {
  TaipProtocolDecoder decoder=new TaipProtocolDecoder(new TaipProtocol());
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"),position("String_Node_Str",true,-26.82523,-65.23682));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"),position("String_Node_Str",true,25.78391,-80.29452));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
}
Program: 155992
Project: 155992
Buggy source:
private void decodeLocation(Position position,Parser parser){
  int hdop=parser.nextInt();
  position.setValid(hdop > 0);
  position.set(Position.KEY_HDOP,hdop);
  position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
  position.setCourse(parser.nextDouble());
  position.setAltitude(parser.nextDouble());
  if (parser.hasNext(8)) {
    position.setValid(true);
    position.setLongitude(parser.nextDouble());
    position.setLatitude(parser.nextDouble());
    position.setTime(parser.nextDateTime());
  }
 else {
    getLastLocation(position,null);
  }
  if (parser.hasNext(6)) {
    int mcc=parser.nextInt();
    int mnc=parser.nextInt();
    if (parser.hasNext(2)) {
      position.setNetwork(new Network(CellTower.from(mcc,mnc,parser.nextInt(),parser.nextInt())));
    }
 else {
      position.setNetwork(new Network(CellTower.from(mcc,mnc,parser.nextInt(16),parser.nextInt(16))));
    }
  }
  position.set(Position.KEY_ODOMETER,parser.nextDouble() * 1000);
}

Fixed version (ground truth):
private void decodeLocation(Position position,Parser parser){
  int hdop=parser.nextInt();
  position.setValid(hdop > 0);
  position.set(Position.KEY_HDOP,hdop);
  position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
  position.setCourse(parser.nextDouble());
  position.setAltitude(parser.nextDouble());
  if (parser.hasNext(8)) {
    position.setValid(true);
    position.setLongitude(parser.nextDouble());
    position.setLatitude(parser.nextDouble());
    position.setTime(parser.nextDateTime());
  }
 else {
    getLastLocation(position,null);
  }
  if (parser.hasNext(6)) {
    int mcc=parser.nextInt();
    int mnc=parser.nextInt();
    if (parser.hasNext(2)) {
      position.setNetwork(new Network(CellTower.from(mcc,mnc,parser.nextInt(),parser.nextInt())));
    }
    if (parser.hasNext(2)) {
      position.setNetwork(new Network(CellTower.from(mcc,mnc,parser.nextInt(16),parser.nextInt(16))));
    }
  }
  position.set(Position.KEY_ODOMETER,parser.nextDouble() * 1000);
}
Program: 155995
Project: 155995
Buggy source:
private static String formatUrl(String key){
  String url="String_Node_Str";
  if (key != null) {
    url+="String_Node_Str" + key;
  }
  return url;
}

Fixed version (ground truth):
private static String formatUrl(String key,String language){
  String url="String_Node_Str";
  url+="String_Node_Str";
  if (key != null) {
    url+="String_Node_Str" + key;
  }
  if (language != null) {
    url+="String_Node_Str" + language;
  }
  return url;
}
Program: 155996
Project: 155996
Buggy source:
public GeocodeFarmGeocoder(String key,int cacheSize){
  super(formatUrl(key),cacheSize);
}

Fixed version (ground truth):
public GeocodeFarmGeocoder(String key,String language,int cacheSize){
  super(formatUrl(key,language),cacheSize);
}
Program: 155997
Project: 155997
Buggy source:
private static String formatUrl(String url,String key){
  if (url == null) {
    url="String_Node_Str";
  }
  if (key != null) {
    url+="String_Node_Str" + key;
  }
  return url;
}

Fixed version (ground truth):
private static String formatUrl(String url,String key){
  if (url == null) {
    url="String_Node_Str";
  }
  url+="String_Node_Str";
  if (key != null) {
    url+="String_Node_Str" + key;
  }
  return url;
}
Program: 155998
Project: 155998
Buggy source:
@Override protected Object decode(Channel channel,SocketAddress remoteAddress,Object msg) throws Exception {
  String[] sentences=((String)msg).split("String_Node_Str");
  List<Position> positions=new ArrayList<>();
  Map<Integer,BitBuffer> buffers=new HashMap<>();
  for (  String sentence : sentences) {
    if (!sentence.isEmpty()) {
      Parser parser=new Parser(PATTERN,sentence);
      if (parser.matches()) {
        int count=parser.nextInt();
        int index=parser.nextInt();
        int id=parser.nextInt();
        Position position=null;
        if (count == 1) {
          BitBuffer bits=new BitBuffer();
          bits.writeEncoded(parser.next().getBytes());
          position=decodePayload(channel,remoteAddress,bits);
        }
 else {
          BitBuffer bits=buffers.get(id);
          if (bits == null) {
            bits=new BitBuffer();
            buffers.put(id,bits);
          }
          bits.writeEncoded(parser.next().getBytes());
          if (count == index) {
            position=decodePayload(channel,remoteAddress,bits);
            buffers.remove(id);
          }
        }
        if (position != null) {
          positions.add(position);
        }
      }
    }
  }
  return positions;
}

Fixed version (ground truth):
@Override protected Object decode(Channel channel,SocketAddress remoteAddress,Object msg) throws Exception {
  String[] sentences=((String)msg).split("String_Node_Str");
  List<Position> positions=new ArrayList<>();
  Map<Integer,BitBuffer> buffers=new HashMap<>();
  for (  String sentence : sentences) {
    if (!sentence.isEmpty()) {
      Parser parser=new Parser(PATTERN,sentence);
      if (parser.matches()) {
        int count=parser.nextInt();
        int index=parser.nextInt();
        int id=parser.nextInt();
        Position position=null;
        if (count == 1) {
          BitBuffer bits=new BitBuffer();
          bits.writeEncoded(parser.next().getBytes(StandardCharsets.US_ASCII));
          position=decodePayload(channel,remoteAddress,bits);
        }
 else {
          BitBuffer bits=buffers.get(id);
          if (bits == null) {
            bits=new BitBuffer();
            buffers.put(id,bits);
          }
          bits.writeEncoded(parser.next().getBytes(StandardCharsets.US_ASCII));
          if (count == index) {
            position=decodePayload(channel,remoteAddress,bits);
            buffers.remove(id);
          }
        }
        if (position != null) {
          positions.add(position);
        }
      }
    }
  }
  return positions;
}
Program: 155999
Project: 155999
Buggy source:
@Override protected Object decode(ChannelHandlerContext ctx,Channel channel,ChannelBuffer buf) throws Exception {
  if (buf.readableBytes() < 5) {
    return null;
  }
  int length;
  if (firstPacket) {
    firstPacket=false;
    length=buf.getUnsignedMedium(buf.readerIndex() + 2);
  }
 else {
    length=buf.getUnsignedMedium(buf.readerIndex() + 1);
  }
  length+=BLOCK_LENGTH;
  if (length % BLOCK_LENGTH != 0) {
    length=(length / BLOCK_LENGTH + 1) * BLOCK_LENGTH;
  }
  if (buf.readableBytes() >= length || buf.readableBytes() % ACK_LENGTH == 0) {
    if (buf != currentBuffer || buf.readableBytes() > acknowledgedBytes) {
      sendResponse(channel);
      currentBuffer=buf;
      acknowledgedBytes=buf.readableBytes();
    }
  }
  if (buf.readableBytes() >= length) {
    return buf.readBytes(length);
  }
  return null;
}

Fixed version (ground truth):
@Override protected Object decode(ChannelHandlerContext ctx,Channel channel,ChannelBuffer buf) throws Exception {
  if (buf.readableBytes() < 5) {
    return null;
  }
  int length;
  if (firstPacket) {
    firstPacket=false;
    length=buf.getUnsignedMedium(buf.readerIndex() + 2);
  }
 else {
    length=buf.getUnsignedMedium(buf.readerIndex() + 1);
  }
  length+=BLOCK_LENGTH;
  if (length % BLOCK_LENGTH != 0) {
    length=(length / BLOCK_LENGTH + 1) * BLOCK_LENGTH;
  }
  if ((buf.readableBytes() >= length || buf.readableBytes() % ACK_LENGTH == 0) && (buf != currentBuffer || buf.readableBytes() > acknowledgedBytes)) {
    sendResponse(channel);
    currentBuffer=buf;
    acknowledgedBytes=buf.readableBytes();
  }
  if (buf.readableBytes() >= length) {
    return buf.readBytes(length);
  }
  return null;
}
Program: 156000
Project: 156000
Buggy source:
@Override protected Object decode(ChannelHandlerContext ctx,Channel channel,ChannelBuffer buf) throws Exception {
  char marker=(char)buf.getByte(buf.readerIndex());
  while (marker != '*' && marker != '$' && marker != 'X' && buf.readableBytes() > 0) {
    buf.skipBytes(1);
    if (buf.readableBytes() > 0) {
      marker=(char)buf.getByte(buf.readerIndex());
    }
  }
  if (marker == '*') {
    int index=buf.indexOf(buf.readerIndex(),buf.writerIndex(),(byte)'#');
    if (index != -1) {
      return buf.readBytes(index + 1 - buf.readerIndex());
    }
  }
 else   if (marker == '$') {
    if (messageLength == 0) {
      if (buf.readableBytes() == MESSAGE_LONG) {
        messageLength=MESSAGE_LONG;
      }
 else {
        messageLength=MESSAGE_SHORT;
      }
    }
    if (buf.readableBytes() >= messageLength) {
      return buf.readBytes(messageLength);
    }
  }
 else   if (marker == 'X') {
    if (buf.readableBytes() >= MESSAGE_SHORT) {
      return buf.readBytes(MESSAGE_SHORT);
    }
  }
  return null;
}

Fixed version (ground truth):
@Override protected Object decode(ChannelHandlerContext ctx,Channel channel,ChannelBuffer buf) throws Exception {
  char marker=(char)buf.getByte(buf.readerIndex());
  while (marker != '*' && marker != '$' && marker != 'X' && buf.readableBytes() > 0) {
    buf.skipBytes(1);
    if (buf.readableBytes() > 0) {
      marker=(char)buf.getByte(buf.readerIndex());
    }
  }
switch (marker) {
case '*':
    int index=buf.indexOf(buf.readerIndex(),buf.writerIndex(),(byte)'#');
  if (index != -1) {
    return buf.readBytes(index + 1 - buf.readerIndex());
  }
break;
case '$':
if (messageLength == 0) {
if (buf.readableBytes() == MESSAGE_LONG) {
  messageLength=MESSAGE_LONG;
}
 else {
  messageLength=MESSAGE_SHORT;
}
}
if (buf.readableBytes() >= messageLength) {
return buf.readBytes(messageLength);
}
break;
case 'X':
if (buf.readableBytes() >= MESSAGE_SHORT) {
return buf.readBytes(MESSAGE_SHORT);
}
break;
default :
throw new IllegalArgumentException();
}
return null;
}