nus-yam/ex-repair huggingface dataset:
Program: 156101
Project: 156101
Buggy source:
protected Position position(Date time,boolean valid,double lat,double lon,double altitude,double speed,double course){
  Position position=new Position();
  position.setDeviceTime(time);
  position.setFixTime(time);
  position.setValid(valid);
  position.setLatitude(lat);
  position.setLongitude(lon);
  position.setAltitude(altitude);
  position.setSpeed(speed);
  position.setCourse(course);
  return position;
}

Fixed version (ground truth):
protected Position position(String time,boolean valid,double lat,double lon) throws ParseException {
  Position position=new Position();
  if (time != null) {
    DateFormat dateFormat=new SimpleDateFormat("String_Node_Str");
    position.setTime(dateFormat.parse(time));
  }
  position.setValid(valid);
  position.setLatitude(lat);
  position.setLongitude(lon);
  return position;
}
Program: 156102
Project: 156102
Buggy source:
protected String text(String... data){
  return String.join("String_Node_Str",data);
}

Fixed version (ground truth):
protected String text(String... data){
  return concatenateStrings(data);
}
Program: 156103
Project: 156103
Buggy source:
protected ChannelBuffer buffer(String... data){
  return ChannelBuffers.copiedBuffer(String.join("String_Node_Str",data),Charset.defaultCharset());
}

Fixed version (ground truth):
protected ChannelBuffer buffer(String... data){
  return ChannelBuffers.copiedBuffer(concatenateStrings(data),Charset.defaultCharset());
}
Program: 156104
Project: 156104
Buggy source:
@Test public void testDecode() throws Exception {
  Gt06ProtocolDecoder decoder=new Gt06ProtocolDecoder(new Gt06Protocol());
  verifyNothing(decoder,binary("String_Node_Str"));
  verifyAttributes(decoder,binary("String_Node_Str"));
  verifyPosition(decoder,binary("String_Node_Str"));
  verifyPosition(decoder,binary("String_Node_Str"));
  verifyNothing(decoder,binary("String_Node_Str"));
  verifyNothing(decoder,binary("String_Node_Str"));
  verifyNothing(decoder,binary("String_Node_Str"));
  verifyPosition(decoder,binary("String_Node_Str"));
  verifyPosition(decoder,binary("String_Node_Str"));
  verifyPosition(decoder,binary("String_Node_Str"));
  verifyNothing(decoder,binary("String_Node_Str"));
  verifyPosition(decoder,binary("String_Node_Str"));
  verifyPosition(decoder,binary("String_Node_Str"));
  verifyNothing(decoder,binary("String_Node_Str"));
  verifyNothing(decoder,binary("String_Node_Str"));
  verifyPosition(decoder,binary("String_Node_Str"));
}

Fixed version (ground truth):
@Test public void testDecode() throws Exception {
  Gt06ProtocolDecoder decoder=new Gt06ProtocolDecoder(new Gt06Protocol());
  verifyNothing(decoder,binary("String_Node_Str"));
  verifyAttributes(decoder,binary("String_Node_Str"));
  verifyPosition(decoder,binary("String_Node_Str"),position("String_Node_Str",true,54.94535,24.01762));
  verifyPosition(decoder,binary("String_Node_Str"));
  verifyPosition(decoder,binary("String_Node_Str"));
  verifyNothing(decoder,binary("String_Node_Str"));
  verifyNothing(decoder,binary("String_Node_Str"));
  verifyNothing(decoder,binary("String_Node_Str"));
  verifyPosition(decoder,binary("String_Node_Str"));
  verifyPosition(decoder,binary("String_Node_Str"));
  verifyPosition(decoder,binary("String_Node_Str"));
  verifyNothing(decoder,binary("String_Node_Str"));
  verifyPosition(decoder,binary("String_Node_Str"));
  verifyPosition(decoder,binary("String_Node_Str"));
  verifyNothing(decoder,binary("String_Node_Str"));
  verifyNothing(decoder,binary("String_Node_Str"));
  verifyPosition(decoder,binary("String_Node_Str"));
}
Program: 156105
Project: 156105
Buggy source:
public boolean hasNext(){
  if (matcher.group(position) != null) {
    return true;
  }
 else {
    position++;
    return false;
  }
}

Fixed version (ground truth):
public boolean hasNext(int number){
  if (matcher.group(position) != null) {
    return true;
  }
 else {
    position+=number;
    return false;
  }
}
Program: 156107
Project: 156107
Buggy source:
private String readSerialNumber(ChannelBuffer buf){
  int b1=buf.readUnsignedByte();
  int b2=buf.readUnsignedByte();
  if (b2 > 0x80)   b2-=0x80;
  int b3=buf.readUnsignedByte();
  if (b3 > 0x80)   b3-=0x80;
  int b4=buf.readUnsignedByte();
  String serialNumber=String.format("String_Node_Str",b1,b2,b3,b4);
  return String.valueOf(Long.parseLong(serialNumber));
}

Fixed version (ground truth):
private String readSerialNumber(ChannelBuffer buf){
  int b1=buf.readUnsignedByte();
  int b2=buf.readUnsignedByte();
  if (b2 > 0x80) {
    b2-=0x80;
  }
  int b3=buf.readUnsignedByte();
  if (b3 > 0x80) {
    b3-=0x80;
  }
  int b4=buf.readUnsignedByte();
  String serialNumber=String.format("String_Node_Str",b1,b2,b3,b4);
  return String.valueOf(Long.parseLong(serialNumber));
}
Program: 156111
Project: 156111
Buggy source:
private boolean identify(ChannelBuffer buf,Channel channel){
  StringBuilder builder=new StringBuilder();
  for (int i=0; i < 7; i++) {
    int b=buf.readUnsignedByte();
    int d1=(b & 0xf0) >> 4;
    if (d1 == 0xf)     break;
    builder.append(d1);
    int d2=b & 0x0f;
    if (d2 == 0xf)     break;
    builder.append(d2);
  }
  String id=builder.toString();
  if (id.length() == 14 && identify(id + Checksum.luhn(Long.parseLong(id)),channel,null,false)) {
    return true;
  }
  return identify(id,channel);
}

Fixed version (ground truth):
private boolean identify(ChannelBuffer buf,Channel channel){
  StringBuilder builder=new StringBuilder();
  for (int i=0; i < 7; i++) {
    int b=buf.readUnsignedByte();
    int d1=(b & 0xf0) >> 4;
    if (d1 == 0xf) {
      break;
    }
    builder.append(d1);
    int d2=b & 0x0f;
    if (d2 == 0xf) {
      break;
    }
    builder.append(d2);
  }
  String id=builder.toString();
  if (id.length() == 14 && identify(id + Checksum.luhn(Long.parseLong(id)),channel,null,false)) {
    return true;
  }
  return identify(id,channel);
}
Program: 156113
Project: 156113
Buggy source:
public ServerManager() throws Exception {
  List<String> names=new LinkedList<>();
  String packageName="String_Node_Str";
  String packagePath=packageName.replace('.','/');
  URL packageUrl=Thread.currentThread().getContextClassLoader().getResource(packagePath);
  if (packageUrl.getProtocol().equals("String_Node_Str")) {
    String jarFileName=URLDecoder.decode(packageUrl.getFile(),"String_Node_Str");
    JarFile jf=new JarFile(jarFileName.substring(5,jarFileName.indexOf("String_Node_Str")));
    Enumeration<JarEntry> jarEntries=jf.entries();
    while (jarEntries.hasMoreElements()) {
      String entryName=jarEntries.nextElement().getName();
      if (entryName.startsWith(packagePath) && entryName.length() > packagePath.length() + 5) {
        names.add(entryName.substring(packagePath.length() + 1,entryName.lastIndexOf('.')));
      }
    }
  }
 else {
    File folder=new File(new URI(packageUrl.toString()));
    File[] files=folder.listFiles();
    for (    File actual : files) {
      String entryName=actual.getName();
      names.add(entryName.substring(0,entryName.lastIndexOf('.')));
    }
  }
  for (  String name : names) {
    Class protocolClass=Class.forName(packageName + '.' + name);
    if (BaseProtocol.class.isAssignableFrom(protocolClass)) {
      initProtocolServer((BaseProtocol)protocolClass.newInstance());
    }
  }
  initProtocolDetector();
}

Fixed version (ground truth):
public ServerManager() throws Exception {
  List<String> names=new LinkedList<>();
  String packageName="String_Node_Str";
  String packagePath=packageName.replace('.','/');
  URL packageUrl=Thread.currentThread().getContextClassLoader().getResource(packagePath);
  if (packageUrl.getProtocol().equals("String_Node_Str")) {
    String jarFileName=URLDecoder.decode(packageUrl.getFile(),"String_Node_Str");
    try (JarFile jf=new JarFile(jarFileName.substring(5,jarFileName.indexOf("String_Node_Str")))){
      Enumeration<JarEntry> jarEntries=jf.entries();
      while (jarEntries.hasMoreElements()) {
        String entryName=jarEntries.nextElement().getName();
        if (entryName.startsWith(packagePath) && entryName.length() > packagePath.length() + 5) {
          names.add(entryName.substring(packagePath.length() + 1,entryName.lastIndexOf('.')));
        }
      }
    }
   }
 else {
    File folder=new File(new URI(packageUrl.toString()));
    File[] files=folder.listFiles();
    if (files != null) {
      for (      File actual : files) {
        String entryName=actual.getName();
        names.add(entryName.substring(0,entryName.lastIndexOf('.')));
      }
    }
  }
  for (  String name : names) {
    Class protocolClass=Class.forName(packageName + '.' + name);
    if (BaseProtocol.class.isAssignableFrom(protocolClass)) {
      initProtocolServer((BaseProtocol)protocolClass.newInstance());
    }
  }
  initProtocolDetector();
}
Program: 156115
Project: 156115
Buggy source:
/** 
 * Convert hex to integer (length in hex digits)
 */
public static int readHexInteger(ChannelBuffer buf,int length){
  int result=0;
  for (int i=0; i < length / 2; i++) {
    int b=buf.readUnsignedByte();
    result*=10;
    result+=b >>> 4;
    result*=10;
    result+=b & 0x0f;
  }
  if (length % 2 == 1) {
    int b=buf.getUnsignedByte(buf.readerIndex());
    result*=10;
    result+=b >>> 4;
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Convert hex to integer (length in hex digits)
 */
public static int readHexInteger(ChannelBuffer buf,int length){
  int result=0;
  for (int i=0; i < length / 2; i++) {
    int b=buf.readUnsignedByte();
    result*=10;
    result+=b >>> 4;
    result*=10;
    result+=b & 0x0f;
  }
  if (length % 2 != 0) {
    int b=buf.getUnsignedByte(buf.readerIndex());
    result*=10;
    result+=b >>> 4;
  }
  return result;
}
Program: 156116
Project: 156116
Buggy source:
/** 
 * Return hex string
 */
public static String readHexString(ChannelBuffer buf,int length){
  StringBuilder result=new StringBuilder();
  Formatter formatter=new Formatter(result);
  for (int i=0; i < length / 2; i++) {
    formatter.format("String_Node_Str",buf.readByte());
  }
  if (length % 2 == 1) {
    int b=buf.getUnsignedByte(buf.readerIndex());
    formatter.format("String_Node_Str",b >>> 4);
  }
  return result.toString();
}

Fixed version (ground truth):
/** 
 * Return hex string
 */
public static String readHexString(ChannelBuffer buf,int length){
  StringBuilder result=new StringBuilder();
  Formatter formatter=new Formatter(result);
  for (int i=0; i < length / 2; i++) {
    formatter.format("String_Node_Str",buf.readByte());
  }
  if (length % 2 != 0) {
    int b=buf.getUnsignedByte(buf.readerIndex());
    formatter.format("String_Node_Str",b >>> 4);
  }
  return result.toString();
}
Program: 156117
Project: 156117
Buggy source:
private static int crc16Unreflected(ByteBuffer buf,int crc_in,int[] table){
  int crc16=crc_in;
  while (buf.hasRemaining()) {
    crc16=table[((crc16 >> 8) ^ buf.get()) & 0xff] ^ (crc16 << 8);
  }
  return crc16 & 0xFFFF;
}

Fixed version (ground truth):
private static int crc16Unreflected(ByteBuffer buf,int crcIn,int[] table){
  int crc16=crcIn;
  while (buf.hasRemaining()) {
    crc16=table[((crc16 >> 8) ^ buf.get()) & 0xff] ^ (crc16 << 8);
  }
  return crc16 & 0xFFFF;
}
Program: 156118
Project: 156118
Buggy source:
private static int crc16Reflected(ByteBuffer buf,int crc_in,int[] table){
  int crc16=crc_in;
  while (buf.hasRemaining()) {
    crc16=table[(crc16 ^ buf.get()) & 0xff] ^ (crc16 >> 8);
  }
  return crc16 & 0xFFFF;
}

Fixed version (ground truth):
private static int crc16Reflected(ByteBuffer buf,int crcIn,int[] table){
  int crc16=crcIn;
  while (buf.hasRemaining()) {
    crc16=table[(crc16 ^ buf.get()) & 0xff] ^ (crc16 >> 8);
  }
  return crc16 & 0xFFFF;
}
Program: 156119
Project: 156119
Buggy source:
public PatternBuilder num(String s){
  if (collapse) {
    s=s.replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str");
    s=s.replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str");
  }
  pattern.append(s.replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str").replaceAll("String_Node_Str","String_Node_Str"));
  return this;
}

Fixed version (ground truth):
public PatternBuilder num(String s){
  s=s.replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str");
  s=s.replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str");
  pattern.append(s.replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str").replaceAll("String_Node_Str","String_Node_Str"));
  return this;
}
Program: 156120
Project: 156120
Buggy source:
public void setLastUpdate(Date lastUpdate){
  this.lastUpdate=lastUpdate;
}

Fixed version (ground truth):
public void setLastUpdate(Date lastUpdate){
  if (lastUpdate != null) {
    this.lastUpdate=new Date(lastUpdate.getTime());
  }
 else {
    this.lastUpdate=null;
  }
}
Program: 156121
Project: 156121
Buggy source:
public Date getLastUpdate(){
  return lastUpdate;
}

Fixed version (ground truth):
public Date getLastUpdate(){
  if (lastUpdate != null) {
    return new Date(lastUpdate.getTime());
  }
 else {
    return null;
  }
}
Program: 156122
Project: 156122
Buggy source:
public void setDeviceTime(Date deviceTime){
  this.deviceTime=deviceTime;
}

Fixed version (ground truth):
public void setDeviceTime(Date deviceTime){
  if (deviceTime != null) {
    this.deviceTime=new Date(deviceTime.getTime());
  }
 else {
    this.deviceTime=null;
  }
}
Program: 156123
Project: 156123
Buggy source:
public Date getDeviceTime(){
  return deviceTime;
}

Fixed version (ground truth):
public Date getDeviceTime(){
  if (deviceTime != null) {
    return new Date(deviceTime.getTime());
  }
 else {
    return null;
  }
}
Program: 156124
Project: 156124
Buggy source:
public Date getServerTime(){
  return serverTime;
}

Fixed version (ground truth):
public Date getServerTime(){
  if (serverTime != null) {
    return new Date(serverTime.getTime());
  }
 else {
    return null;
  }
}
Program: 156125
Project: 156125
Buggy source:
public void setServerTime(Date serverTime){
  this.serverTime=serverTime;
}

Fixed version (ground truth):
public void setServerTime(Date serverTime){
  if (serverTime != null) {
    this.serverTime=new Date(serverTime.getTime());
  }
 else {
    this.serverTime=null;
  }
}
Program: 156126
Project: 156126
Buggy source:
public static Map<String,Object> fromJson(JsonObject json){
  Map<String,Object> attributes=new LinkedHashMap<>();
  for (  Map.Entry<String,JsonValue> entry : json.entrySet()) {
switch (entry.getValue().getValueType()) {
case STRING:
      attributes.put(entry.getKey(),((JsonString)entry.getValue()).getString());
    break;
case NUMBER:
  JsonNumber number=(JsonNumber)entry.getValue();
if (number.isIntegral()) {
  attributes.put(entry.getKey(),number.longValue());
}
 else {
  attributes.put(entry.getKey(),number.doubleValue());
}
break;
case TRUE:
attributes.put(entry.getKey(),true);
break;
case FALSE:
attributes.put(entry.getKey(),false);
break;
}
}
return attributes;
}

Fixed version (ground truth):
public static Map<String,Object> fromJson(JsonObject json){
  Map<String,Object> attributes=new LinkedHashMap<>();
  for (  Map.Entry<String,JsonValue> entry : json.entrySet()) {
switch (entry.getValue().getValueType()) {
case STRING:
      attributes.put(entry.getKey(),((JsonString)entry.getValue()).getString());
    break;
case NUMBER:
  JsonNumber number=(JsonNumber)entry.getValue();
if (number.isIntegral()) {
  attributes.put(entry.getKey(),number.longValue());
}
 else {
  attributes.put(entry.getKey(),number.doubleValue());
}
break;
case TRUE:
attributes.put(entry.getKey(),true);
break;
case FALSE:
attributes.put(entry.getKey(),false);
break;
default :
Log.warning(new IllegalArgumentException());
break;
}
}
return attributes;
}
Program: 156127
Project: 156127
Buggy source:
public void setFixTime(Date fixTime){
  this.fixTime=fixTime;
}

Fixed version (ground truth):
public void setFixTime(Date fixTime){
  if (fixTime != null) {
    this.fixTime=new Date(fixTime.getTime());
  }
 else {
    this.fixTime=null;
  }
}
Program: 156128
Project: 156128
Buggy source:
public Date getFixTime(){
  return fixTime;
}

Fixed version (ground truth):
public Date getFixTime(){
  if (fixTime != null) {
    return new Date(fixTime.getTime());
  }
 else {
    return null;
  }
}
Program: 156129
Project: 156129
Buggy source:
public void setPassword(String password){
  this.password=password;
  if (password != null && !password.isEmpty()) {
    Hashing.HashingResult hashingResult=Hashing.createHash(password);
    hashedPassword=hashingResult.hash;
    salt=hashingResult.salt;
  }
}

Fixed version (ground truth):
public void setPassword(String password){
  this.password=password;
  if (password != null && !password.isEmpty()) {
    Hashing.HashingResult hashingResult=Hashing.createHash(password);
    hashedPassword=hashingResult.getHash();
    salt=hashingResult.getSalt();
  }
}
Program: 156130
Project: 156130
Buggy source:
@Override protected Object decode(ChannelHandlerContext ctx,Channel channel,ChannelBuffer buf) throws Exception {
  if (buf.readableBytes() < 12) {
    return null;
  }
  int length=0;
switch (buf.getUnsignedByte(buf.readerIndex())) {
case MSG_LOGIN:
    length=19;
  break;
case MSG_LOCATION:
length=34;
break;
}
if (length != 0 && 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() < 12) {
    return null;
  }
  int length;
switch (buf.getUnsignedByte(buf.readerIndex())) {
case MSG_LOGIN:
    length=19;
  break;
case MSG_LOCATION:
length=34;
break;
default :
length=0;
break;
}
if (length != 0 && buf.readableBytes() >= length) {
return buf.readBytes(length);
}
return null;
}
Program: 156131
Project: 156131
Buggy source:
public static long range(long number,int index,int length){
  return (number >> index) & ((1l << length) - 1);
}

Fixed version (ground truth):
public static long range(long number,int index,int length){
  return (number >> index) & ((1L << length) - 1);
}
Program: 156132
Project: 156132
Buggy source:
public static String nmea(String msg){
  int checksum=0;
  byte bytes[]=msg.getBytes(Charset.defaultCharset());
  for (int i=1; i < msg.length(); i++) {
    checksum^=bytes[i];
  }
  return String.format("String_Node_Str",checksum).toUpperCase();
}

Fixed version (ground truth):
public static String nmea(String msg){
  int checksum=0;
  byte[] bytes=msg.getBytes(Charset.defaultCharset());
  for (int i=1; i < msg.length(); i++) {
    checksum^=bytes[i];
  }
  return String.format("String_Node_Str",checksum).toUpperCase();
}
Program: 156133
Project: 156133
Buggy source:
@Override protected Object decode(Channel channel,SocketAddress remoteAddress,Object msg) throws Exception {
  ChannelBuffer buf=(ChannelBuffer)msg;
  buf.readUnsignedByte();
  buf.readUnsignedByte();
  int sequenceNumber=buf.readUnsignedShort();
  int messageId=buf.readUnsignedShort();
  buf.readUnsignedShort();
  int flags=buf.readUnsignedShort();
  buf.readUnsignedShort();
  if (!identify(String.valueOf(buf.readUnsignedInt()),channel)) {
    return null;
  }
  long timestamp=buf.readUnsignedInt();
  if ((flags & 0x1) == 0x0) {
    sendAcknowledgment(channel,sequenceNumber);
  }
switch (messageId) {
case MSG_UNIT_REPORT:
    return parseUnitReport(buf,sequenceNumber);
case MSG_TG2_REPORT:
  return parseTg2Report(buf,sequenceNumber);
case MSG_POSITION_REPORT:
return parsePositionReport(buf,sequenceNumber,timestamp);
case MSG_POSITION_REPORT_2:
return parsePositionReport2(buf,sequenceNumber,timestamp);
case MSG_SNAPSHOT4:
return parseSnapshot4(buf,sequenceNumber);
case MSG_TRACKING_DATA:
return parseTrackingData(buf,sequenceNumber,timestamp);
}
return null;
}

Fixed version (ground truth):
@Override protected Object decode(Channel channel,SocketAddress remoteAddress,Object msg) throws Exception {
  ChannelBuffer buf=(ChannelBuffer)msg;
  buf.readUnsignedByte();
  buf.readUnsignedByte();
  int sequenceNumber=buf.readUnsignedShort();
  int messageId=buf.readUnsignedShort();
  buf.readUnsignedShort();
  int flags=buf.readUnsignedShort();
  buf.readUnsignedShort();
  if (!identify(String.valueOf(buf.readUnsignedInt()),channel)) {
    return null;
  }
  long timestamp=buf.readUnsignedInt();
  if ((flags & 0x1) == 0x0) {
    sendAcknowledgment(channel,sequenceNumber);
  }
switch (messageId) {
case MSG_UNIT_REPORT:
    return parseUnitReport(buf,sequenceNumber);
case MSG_TG2_REPORT:
  return parseTg2Report(buf,sequenceNumber);
case MSG_POSITION_REPORT:
return parsePositionReport(buf,sequenceNumber,timestamp);
case MSG_POSITION_REPORT_2:
return parsePositionReport2(buf,sequenceNumber,timestamp);
case MSG_SNAPSHOT4:
return parseSnapshot4(buf,sequenceNumber);
case MSG_TRACKING_DATA:
return parseTrackingData(buf,sequenceNumber,timestamp);
default :
Log.warning(new UnsupportedOperationException(String.valueOf(messageId)));
break;
}
return null;
}
Program: 156134
Project: 156134
Buggy source:
private static Date convertTimestamp(long timestamp){
  return new Date((timestamp - LEAP_SECONDS_DELTA) * 1000l);
}

Fixed version (ground truth):
private static Date convertTimestamp(long timestamp){
  return new Date((timestamp - LEAP_SECONDS_DELTA) * 1000);
}
Program: 156135
Project: 156135
Buggy source:
private Object processArray(Channel channel,ChannelBuffer buf){
  List<Position> positions=new LinkedList<>();
  int count=buf.readUnsignedByte();
  for (int i=0; i < count; i++) {
    Position position=parsePosition(buf).getPosition();
    if (position.getFixTime() != null) {
      positions.add(position);
    }
  }
  ChannelBuffer response=ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN,8);
  response.writeBytes(ChannelBuffers.copiedBuffer(ByteOrder.LITTLE_ENDIAN,"String_Node_Str",charset));
  response.writeByte(count);
  sendReply(channel,response);
  if (positions.isEmpty()) {
    return null;
  }
  return positions;
}

Fixed version (ground truth):
private Object processArray(Channel channel,ChannelBuffer buf){
  List<Position> positions=new LinkedList<>();
  int count=buf.readUnsignedByte();
  for (int i=0; i < count; i++) {
    Position position=parsePosition(buf).getPosition();
    if (position.getFixTime() != null) {
      positions.add(position);
    }
  }
  ChannelBuffer response=ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN,8);
  response.writeBytes(ChannelBuffers.copiedBuffer(ByteOrder.LITTLE_ENDIAN,"String_Node_Str",CHARSET));
  response.writeByte(count);
  sendReply(channel,response);
  if (positions.isEmpty()) {
    return null;
  }
  return positions;
}
Program: 156136
Project: 156136
Buggy source:
private Object processSingle(Channel channel,ChannelBuffer buf){
  ParseResult result=parsePosition(buf);
  ChannelBuffer response=ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN,8);
  response.writeBytes(ChannelBuffers.copiedBuffer(ByteOrder.LITTLE_ENDIAN,"String_Node_Str",charset));
  response.writeInt((int)result.getId());
  sendReply(channel,response);
  if (result.getPosition().getFixTime() == null) {
    return null;
  }
  return result.getPosition();
}

Fixed version (ground truth):
private Object processSingle(Channel channel,ChannelBuffer buf){
  ParseResult result=parsePosition(buf);
  ChannelBuffer response=ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN,8);
  response.writeBytes(ChannelBuffers.copiedBuffer(ByteOrder.LITTLE_ENDIAN,"String_Node_Str",CHARSET));
  response.writeInt((int)result.getId());
  sendReply(channel,response);
  if (result.getPosition().getFixTime() == null) {
    return null;
  }
  return result.getPosition();
}
Program: 156137
Project: 156137
Buggy source:
private void sendReply(Channel channel,ChannelBuffer data){
  ChannelBuffer header=ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN,16);
  header.writeBytes(ChannelBuffers.copiedBuffer(ByteOrder.LITTLE_ENDIAN,prefix,charset));
  header.writeInt((int)deviceUniqueId);
  header.writeInt((int)serverId);
  header.writeShort(data.readableBytes());
  header.writeByte(checksum(data));
  header.writeByte(checksum(header));
  if (channel != null) {
    channel.write(ChannelBuffers.copiedBuffer(header,data));
  }
}

Fixed version (ground truth):
private void sendReply(Channel channel,ChannelBuffer data){
  ChannelBuffer header=ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN,16);
  header.writeBytes(ChannelBuffers.copiedBuffer(ByteOrder.LITTLE_ENDIAN,prefix,CHARSET));
  header.writeInt((int)deviceUniqueId);
  header.writeInt((int)serverId);
  header.writeShort(data.readableBytes());
  header.writeByte(checksum(data));
  header.writeByte(checksum(header));
  if (channel != null) {
    channel.write(ChannelBuffers.copiedBuffer(header,data));
  }
}
Program: 156138
Project: 156138
Buggy source:
@Override protected Object decode(Channel channel,SocketAddress remoteAddress,Object msg) throws Exception {
  ChannelBuffer buf=(ChannelBuffer)msg;
  prefix=buf.toString(buf.readerIndex(),4,charset);
  buf.skipBytes(prefix.length());
  serverId=buf.readUnsignedInt();
  deviceUniqueId=buf.readUnsignedInt();
  int length=buf.readUnsignedShort();
  buf.skipBytes(2);
  if (length == 0) {
    return null;
  }
  String type=buf.toString(buf.readerIndex(),3,charset);
  buf.skipBytes(type.length());
switch (type) {
case "String_Node_Str":
    return processSingle(channel,buf);
case "String_Node_Str":
  return processArray(channel,buf);
case "String_Node_Str":
return processHandshake(channel,buf);
}
return null;
}

Fixed version (ground truth):
@Override protected Object decode(Channel channel,SocketAddress remoteAddress,Object msg) throws Exception {
  ChannelBuffer buf=(ChannelBuffer)msg;
  prefix=buf.toString(buf.readerIndex(),4,CHARSET);
  buf.skipBytes(prefix.length());
  serverId=buf.readUnsignedInt();
  deviceUniqueId=buf.readUnsignedInt();
  int length=buf.readUnsignedShort();
  buf.skipBytes(2);
  if (length == 0) {
    return null;
  }
  String type=buf.toString(buf.readerIndex(),3,CHARSET);
  buf.skipBytes(type.length());
switch (type) {
case "String_Node_Str":
    return processSingle(channel,buf);
case "String_Node_Str":
  return processArray(channel,buf);
case "String_Node_Str":
return processHandshake(channel,buf);
}
return null;
}
Program: 156139
Project: 156139
Buggy source:
private Object processHandshake(Channel channel,ChannelBuffer buf){
  buf.readByte();
  if (identify(buf.toString(Charset.defaultCharset()),channel)) {
    sendReply(channel,ChannelBuffers.copiedBuffer(ByteOrder.LITTLE_ENDIAN,"String_Node_Str",charset));
  }
  return null;
}

Fixed version (ground truth):
private Object processHandshake(Channel channel,ChannelBuffer buf){
  buf.readByte();
  if (identify(buf.toString(Charset.defaultCharset()),channel)) {
    sendReply(channel,ChannelBuffers.copiedBuffer(ByteOrder.LITTLE_ENDIAN,"String_Node_Str",CHARSET));
  }
  return null;
}
Program: 156140
Project: 156140
Buggy source:
private static double convertCoordinate(long coordinate){
  int sign=1;
  if (coordinate > 0x7fffffffl) {
    sign=-1;
    coordinate=0xffffffffl - coordinate;
  }
  long degrees=coordinate / 1000000;
  double minutes=(coordinate % 1000000) / 10000.0;
  return sign * (degrees + minutes / 60);
}

Fixed version (ground truth):
private static double convertCoordinate(long coordinate){
  int sign=1;
  if (coordinate > 0x7fffffffL) {
    sign=-1;
    coordinate=0xffffffffL - coordinate;
  }
  long degrees=coordinate / 1000000;
  double minutes=(coordinate % 1000000) / 10000.0;
  return sign * (degrees + minutes / 60);
}
Program: 156144
Project: 156144
Buggy source:
public static Map<String,Object> fromJson(JsonObject json){
  Map<String,Object> attributes=new LinkedHashMap<>();
  for (  Map.Entry<String,JsonValue> entry : json.entrySet()) {
switch (entry.getValue().getValueType()) {
case STRING:
      attributes.put(entry.getKey(),((JsonString)entry.getValue()).getString());
    break;
case NUMBER:
  JsonNumber number=(JsonNumber)entry.getValue();
if (number.isIntegral()) {
  attributes.put(entry.getKey(),number.longValue());
}
 else {
  attributes.put(entry.getKey(),number.doubleValue());
}
break;
case TRUE:
attributes.put(entry.getKey(),true);
break;
case FALSE:
attributes.put(entry.getKey(),false);
break;
default :
Log.warning(new IllegalArgumentException());
break;
}
}
return attributes;
}

Fixed version (ground truth):
public static Map<String,Object> fromJson(JsonObject json){
  Map<String,Object> attributes=new LinkedHashMap<>();
  for (  Map.Entry<String,JsonValue> entry : json.entrySet()) {
    JsonValue.ValueType type=entry.getValue().getValueType();
switch (type) {
case STRING:
      attributes.put(entry.getKey(),((JsonString)entry.getValue()).getString());
    break;
case NUMBER:
  JsonNumber number=(JsonNumber)entry.getValue();
if (number.isIntegral()) {
  attributes.put(entry.getKey(),number.longValue());
}
 else {
  attributes.put(entry.getKey(),number.doubleValue());
}
break;
case TRUE:
attributes.put(entry.getKey(),true);
break;
case FALSE:
attributes.put(entry.getKey(),false);
break;
default :
Log.warning(new IllegalArgumentException(type.name()));
break;
}
}
return attributes;
}
Program: 156145
Project: 156145
Buggy source:
@Override protected Object decode(ChannelHandlerContext ctx,Channel channel,ChannelBuffer buf) throws Exception {
  int available=buf.readableBytes();
  if (available < MESSAGE_MINIMUM_LENGTH) {
    return null;
  }
  int length=0;
switch (buf.getUnsignedByte(4)) {
case CellocatorProtocolDecoder.MSG_CLIENT_STATUS:
    length=70;
  break;
case CellocatorProtocolDecoder.MSG_CLIENT_PROGRAMMING:
length=31;
break;
case CellocatorProtocolDecoder.MSG_CLIENT_SERIAL_LOG:
length=70;
break;
case CellocatorProtocolDecoder.MSG_CLIENT_SERIAL:
if (available >= 19) {
length=19 + buf.getUnsignedShort(16);
}
break;
case CellocatorProtocolDecoder.MSG_CLIENT_MODULAR:
length=15 + buf.getUnsignedByte(13);
break;
default :
Log.warning(new UnsupportedOperationException());
break;
}
if (length > 0 && available >= length) {
return buf.readBytes(length);
}
return null;
}

Fixed version (ground truth):
@Override protected Object decode(ChannelHandlerContext ctx,Channel channel,ChannelBuffer buf) throws Exception {
  int available=buf.readableBytes();
  if (available < MESSAGE_MINIMUM_LENGTH) {
    return null;
  }
  int length=0;
  int type=buf.getUnsignedByte(4);
switch (type) {
case CellocatorProtocolDecoder.MSG_CLIENT_STATUS:
    length=70;
  break;
case CellocatorProtocolDecoder.MSG_CLIENT_PROGRAMMING:
length=31;
break;
case CellocatorProtocolDecoder.MSG_CLIENT_SERIAL_LOG:
length=70;
break;
case CellocatorProtocolDecoder.MSG_CLIENT_SERIAL:
if (available >= 19) {
length=19 + buf.getUnsignedShort(16);
}
break;
case CellocatorProtocolDecoder.MSG_CLIENT_MODULAR:
length=15 + buf.getUnsignedByte(13);
break;
default :
Log.warning(new UnsupportedOperationException(String.valueOf(type)));
break;
}
if (length > 0 && available >= length) {
return buf.readBytes(length);
}
return null;
}
Program: 156146
Project: 156146
Buggy source:
@Override protected Object encodeCommand(Command command){
switch (command.getType()) {
case Command.TYPE_POSITION_STOP:
    return formatCommand(command,"String_Node_Str",Command.KEY_UNIQUE_ID);
case Command.TYPE_POSITION_SINGLE:
  return formatCommand(command,"String_Node_Str",Command.KEY_UNIQUE_ID);
case Command.TYPE_POSITION_PERIODIC:
return formatCommand(command,"String_Node_Str",this,Command.KEY_UNIQUE_ID,Command.KEY_FREQUENCY);
case Command.TYPE_ENGINE_STOP:
return formatCommand(command,"String_Node_Str",Command.KEY_UNIQUE_ID);
case Command.TYPE_ENGINE_RESUME:
return formatCommand(command,"String_Node_Str",Command.KEY_UNIQUE_ID);
case Command.TYPE_ALARM_ARM:
return formatCommand(command,"String_Node_Str",Command.KEY_UNIQUE_ID);
case Command.TYPE_ALARM_DISARM:
return formatCommand(command,"String_Node_Str",Command.KEY_UNIQUE_ID);
}
return null;
}

Fixed version (ground truth):
@Override protected Object encodeCommand(Command command){
switch (command.getType()) {
case Command.TYPE_POSITION_STOP:
    return formatCommand(command,"String_Node_Str",Command.KEY_UNIQUE_ID);
case Command.TYPE_POSITION_SINGLE:
  return formatCommand(command,"String_Node_Str",Command.KEY_UNIQUE_ID);
case Command.TYPE_POSITION_PERIODIC:
return formatCommand(command,"String_Node_Str",this,Command.KEY_UNIQUE_ID,Command.KEY_FREQUENCY);
case Command.TYPE_ENGINE_STOP:
return formatCommand(command,"String_Node_Str",Command.KEY_UNIQUE_ID);
case Command.TYPE_ENGINE_RESUME:
return formatCommand(command,"String_Node_Str",Command.KEY_UNIQUE_ID);
case Command.TYPE_ALARM_ARM:
return formatCommand(command,"String_Node_Str",Command.KEY_UNIQUE_ID);
case Command.TYPE_ALARM_DISARM:
return formatCommand(command,"String_Node_Str",Command.KEY_UNIQUE_ID);
default :
Log.warning(new UnsupportedOperationException(command.getType()));
break;
}
return null;
}
Program: 156147
Project: 156147
Buggy source:
@Override protected Object encodeCommand(Command command){
switch (command.getType()) {
case Command.TYPE_ENGINE_STOP:
    return encodeContent("String_Node_Str");
case Command.TYPE_ENGINE_RESUME:
  return encodeContent("String_Node_Str");
}
return null;
}

Fixed version (ground truth):
@Override protected Object encodeCommand(Command command){
switch (command.getType()) {
case Command.TYPE_ENGINE_STOP:
    return encodeContent("String_Node_Str");
case Command.TYPE_ENGINE_RESUME:
  return encodeContent("String_Node_Str");
default :
Log.warning(new UnsupportedOperationException(command.getType()));
break;
}
return null;
}
Program: 156148
Project: 156148
Buggy source:
@Override protected Object encodeCommand(Command command){
switch (command.getType()) {
case Command.TYPE_ENGINE_STOP:
    return formatCommand(command,"String_Node_Str",Command.KEY_UNIQUE_ID);
case Command.TYPE_ENGINE_RESUME:
  return formatCommand(command,"String_Node_Str",Command.KEY_UNIQUE_ID);
case Command.TYPE_ALARM_ARM:
return formatCommand(command,"String_Node_Str",Command.KEY_UNIQUE_ID);
case Command.TYPE_ALARM_DISARM:
return formatCommand(command,"String_Node_Str",Command.KEY_UNIQUE_ID);
}
return null;
}

Fixed version (ground truth):
@Override protected Object encodeCommand(Command command){
switch (command.getType()) {
case Command.TYPE_ENGINE_STOP:
    return formatCommand(command,"String_Node_Str",Command.KEY_UNIQUE_ID);
case Command.TYPE_ENGINE_RESUME:
  return formatCommand(command,"String_Node_Str",Command.KEY_UNIQUE_ID);
case Command.TYPE_ALARM_ARM:
return formatCommand(command,"String_Node_Str",Command.KEY_UNIQUE_ID);
case Command.TYPE_ALARM_DISARM:
return formatCommand(command,"String_Node_Str",Command.KEY_UNIQUE_ID);
default :
Log.warning(new UnsupportedOperationException(command.getType()));
break;
}
return null;
}
Program: 156150
Project: 156150
Buggy source:
@Override protected Object decode(ChannelHandlerContext ctx,Channel channel,ChannelBuffer buf) throws Exception {
  int available=buf.readableBytes();
  if (available < MESSAGE_MINIMUM_LENGTH) {
    return null;
  }
  int length=0;
switch (buf.getUnsignedByte(4)) {
case CellocatorProtocolDecoder.MSG_CLIENT_STATUS:
    length=70;
  break;
case CellocatorProtocolDecoder.MSG_CLIENT_PROGRAMMING:
length=31;
break;
case CellocatorProtocolDecoder.MSG_CLIENT_SERIAL_LOG:
length=70;
break;
case CellocatorProtocolDecoder.MSG_CLIENT_SERIAL:
if (available >= 19) {
length=19 + buf.getUnsignedShort(16);
}
break;
case CellocatorProtocolDecoder.MSG_CLIENT_MODULAR:
length=15 + buf.getUnsignedByte(13);
break;
}
if (length > 0 && available >= length) {
return buf.readBytes(length);
}
return null;
}

Fixed version (ground truth):
@Override protected Object decode(ChannelHandlerContext ctx,Channel channel,ChannelBuffer buf) throws Exception {
  int available=buf.readableBytes();
  if (available < MESSAGE_MINIMUM_LENGTH) {
    return null;
  }
  int length=0;
switch (buf.getUnsignedByte(4)) {
case CellocatorProtocolDecoder.MSG_CLIENT_STATUS:
    length=70;
  break;
case CellocatorProtocolDecoder.MSG_CLIENT_PROGRAMMING:
length=31;
break;
case CellocatorProtocolDecoder.MSG_CLIENT_SERIAL_LOG:
length=70;
break;
case CellocatorProtocolDecoder.MSG_CLIENT_SERIAL:
if (available >= 19) {
length=19 + buf.getUnsignedShort(16);
}
break;
case CellocatorProtocolDecoder.MSG_CLIENT_MODULAR:
length=15 + buf.getUnsignedByte(13);
break;
default :
Log.warning(new UnsupportedOperationException());
break;
}
if (length > 0 && available >= length) {
return buf.readBytes(length);
}
return null;
}
Program: 156151
Project: 156151
Buggy source:
public float readFloat(ChannelBuffer buf){
switch (buf.getUnsignedByte(buf.readerIndex()) >> 6) {
case 0:
    previousFloat=buf.readInt() << 2;
  break;
case 1:
previousFloat=(previousFloat & 0xffffff00) + ((buf.readUnsignedByte() & 0x3f) << 2);
break;
case 2:
previousFloat=(previousFloat & 0xffff0000) + ((buf.readUnsignedShort() & 0x3fff) << 2);
break;
case 3:
previousFloat=(previousFloat & 0xff000000) + ((buf.readUnsignedMedium() & 0x3fffff) << 2);
break;
}
return Float.intBitsToFloat(previousFloat);
}

Fixed version (ground truth):
public float readFloat(ChannelBuffer buf){
switch (buf.getUnsignedByte(buf.readerIndex()) >> 6) {
case 0:
    previousFloat=buf.readInt() << 2;
  break;
case 1:
previousFloat=(previousFloat & 0xffffff00) + ((buf.readUnsignedByte() & 0x3f) << 2);
break;
case 2:
previousFloat=(previousFloat & 0xffff0000) + ((buf.readUnsignedShort() & 0x3fff) << 2);
break;
case 3:
previousFloat=(previousFloat & 0xff000000) + ((buf.readUnsignedMedium() & 0x3fffff) << 2);
break;
default :
Log.warning(new IllegalArgumentException());
break;
}
return Float.intBitsToFloat(previousFloat);
}
Program: 156153
Project: 156153
Buggy source:
public static int crc16(String type,ByteBuffer buf){
switch (type) {
case CRC16_X25:
    return crc16Reflected(buf,0xFFFF,CRC16_CCITT_TABLE_REVERSE) ^ 0xFFFF;
case CRC16_CCITT_FALSE:
  return crc16Unreflected(buf,0xFFFF,CRC16_CCITT_TABLE);
case CRC16_KERMIT:
return crc16Reflected(buf,0,CRC16_CCITT_TABLE_REVERSE);
case CRC16_XMODEM:
return crc16Unreflected(buf,0,CRC16_CCITT_TABLE);
case CRC16_AUG_CCITT:
return crc16Unreflected(buf,0x1d0f,CRC16_CCITT_TABLE);
case CRC16_GENIBUS:
return crc16Unreflected(buf,0xFFFF,CRC16_CCITT_TABLE) ^ 0xFFFF;
case CRC16_MCRF4XX:
return crc16Reflected(buf,0xFFFF,CRC16_CCITT_TABLE_REVERSE);
}
throw new UnsupportedOperationException();
}

Fixed version (ground truth):
public static int crc16(String type,ByteBuffer buf){
switch (type) {
case CRC16_X25:
    return crc16Reflected(buf,0xFFFF,CRC16_CCITT_TABLE_REVERSE) ^ 0xFFFF;
case CRC16_CCITT_FALSE:
  return crc16Unreflected(buf,0xFFFF,CRC16_CCITT_TABLE);
case CRC16_KERMIT:
return crc16Reflected(buf,0,CRC16_CCITT_TABLE_REVERSE);
case CRC16_XMODEM:
return crc16Unreflected(buf,0,CRC16_CCITT_TABLE);
case CRC16_AUG_CCITT:
return crc16Unreflected(buf,0x1d0f,CRC16_CCITT_TABLE);
case CRC16_GENIBUS:
return crc16Unreflected(buf,0xFFFF,CRC16_CCITT_TABLE) ^ 0xFFFF;
case CRC16_MCRF4XX:
return crc16Reflected(buf,0xFFFF,CRC16_CCITT_TABLE_REVERSE);
default :
throw new UnsupportedOperationException(type);
}
}
Program: 156154
Project: 156154
Buggy source:
public static HashingResult createHash(String password){
  byte[] salt=new byte[SALT_SIZE];
  random.nextBytes(salt);
  byte[] hash=function(password.toCharArray(),salt);
  return new HashingResult(ChannelBufferTools.convertByteArray(hash),ChannelBufferTools.convertByteArray(salt));
}

Fixed version (ground truth):
public static HashingResult createHash(String password){
  byte[] salt=new byte[SALT_SIZE];
  RANDOM.nextBytes(salt);
  byte[] hash=function(password.toCharArray(),salt);
  return new HashingResult(ChannelBufferTools.convertByteArray(hash),ChannelBufferTools.convertByteArray(salt));
}
Program: 156155
Project: 156155
Buggy source:
public PatternBuilder groupEnd(boolean optional){
  return xpr(optional ? "String_Node_Str" : "String_Node_Str");
}

Fixed version (ground truth):
public PatternBuilder groupEnd(boolean optional){
  if (optional) {
    return xpr("String_Node_Str");
  }
 else {
    return xpr("String_Node_Str");
  }
}
Program: 156156
Project: 156156
Buggy source:
public static String toXmlString(Map<String,Object> attributes){
  StringBuilder result=new StringBuilder();
  result.append("String_Node_Str").append(xmlRootNode).append("String_Node_Str");
  for (  Map.Entry<String,Object> entry : attributes.entrySet()) {
    result.append("String_Node_Str").append(entry.getKey()).append("String_Node_Str");
    result.append(format(entry.getValue()));
    result.append("String_Node_Str").append(entry.getKey()).append("String_Node_Str");
  }
  result.append("String_Node_Str").append(xmlRootNode).append("String_Node_Str");
  return result.toString();
}

Fixed version (ground truth):
public static String toXmlString(Map<String,Object> attributes){
  StringBuilder result=new StringBuilder();
  result.append("String_Node_Str").append(XML_ROOT_NODE).append("String_Node_Str");
  for (  Map.Entry<String,Object> entry : attributes.entrySet()) {
    result.append("String_Node_Str").append(entry.getKey()).append("String_Node_Str");
    result.append(format(entry.getValue()));
    result.append("String_Node_Str").append(entry.getKey()).append("String_Node_Str");
  }
  result.append("String_Node_Str").append(XML_ROOT_NODE).append("String_Node_Str");
  return result.toString();
}
Program: 156157
Project: 156157
Buggy source:
private static String format(Object value){
  if (value instanceof Double || value instanceof Float) {
    return decimalFormat.format(value);
  }
 else {
    return value.toString();
  }
}

Fixed version (ground truth):
private static String format(Object value){
  if (value instanceof Double || value instanceof Float) {
    return DECIMAL_FORMAT.format(value);
  }
 else {
    return value.toString();
  }
}
Program: 156161
Project: 156161
Buggy source:
@Override protected Object encodeCommand(Command command){
  ChannelBuffer content=ChannelBuffers.dynamicBuffer();
switch (command.getType()) {
case Command.TYPE_POSITION_SINGLE:
    return encodeContent(CityeasyProtocolDecoder.MSG_LOCATION_REQUEST,content);
case Command.TYPE_POSITION_PERIODIC:
  content.writeShort(((Number)command.getAttributes().get(Command.KEY_FREQUENCY)).intValue());
return encodeContent(CityeasyProtocolDecoder.MSG_LOCATION_INTERVAL,content);
case Command.TYPE_POSITION_STOP:
content.writeShort(0);
return encodeContent(CityeasyProtocolDecoder.MSG_LOCATION_INTERVAL,content);
case Command.TYPE_SET_TIMEZONE:
int timezone=((Number)command.getAttributes().get(Command.KEY_TIMEZONE)).intValue();
content.writeByte(timezone < 0 ? 1 : 0);
content.writeShort(Math.abs(timezone) / 60);
return encodeContent(CityeasyProtocolDecoder.MSG_TIMEZONE,content);
}
return null;
}

Fixed version (ground truth):
@Override protected Object encodeCommand(Command command){
  ChannelBuffer content=ChannelBuffers.dynamicBuffer();
switch (command.getType()) {
case Command.TYPE_POSITION_SINGLE:
    return encodeContent(CityeasyProtocolDecoder.MSG_LOCATION_REQUEST,content);
case Command.TYPE_POSITION_PERIODIC:
  content.writeShort(((Number)command.getAttributes().get(Command.KEY_FREQUENCY)).intValue());
return encodeContent(CityeasyProtocolDecoder.MSG_LOCATION_INTERVAL,content);
case Command.TYPE_POSITION_STOP:
content.writeShort(0);
return encodeContent(CityeasyProtocolDecoder.MSG_LOCATION_INTERVAL,content);
case Command.TYPE_SET_TIMEZONE:
int timezone=((Number)command.getAttributes().get(Command.KEY_TIMEZONE)).intValue();
if (timezone < 0) {
content.writeByte(1);
}
 else {
content.writeByte(0);
}
content.writeShort(Math.abs(timezone) / 60);
return encodeContent(CityeasyProtocolDecoder.MSG_TIMEZONE,content);
default :
Log.warning(new UnsupportedOperationException(command.getType()));
break;
}
return null;
}
Program: 156162
Project: 156162
Buggy source:
@Override protected Object decode(Channel channel,SocketAddress remoteAddress,Object msg) throws Exception {
  ChannelBuffer buf=(ChannelBuffer)msg;
  prefix=buf.toString(buf.readerIndex(),4,CHARSET);
  buf.skipBytes(prefix.length());
  serverId=buf.readUnsignedInt();
  deviceUniqueId=buf.readUnsignedInt();
  int length=buf.readUnsignedShort();
  buf.skipBytes(2);
  if (length == 0) {
    return null;
  }
  String type=buf.toString(buf.readerIndex(),3,CHARSET);
  buf.skipBytes(type.length());
switch (type) {
case "String_Node_Str":
    return processSingle(channel,buf);
case "String_Node_Str":
  return processArray(channel,buf);
case "String_Node_Str":
return processHandshake(channel,buf);
}
return null;
}

Fixed version (ground truth):
@Override protected Object decode(Channel channel,SocketAddress remoteAddress,Object msg) throws Exception {
  ChannelBuffer buf=(ChannelBuffer)msg;
  prefix=buf.toString(buf.readerIndex(),4,CHARSET);
  buf.skipBytes(prefix.length());
  serverId=buf.readUnsignedInt();
  deviceUniqueId=buf.readUnsignedInt();
  int length=buf.readUnsignedShort();
  buf.skipBytes(2);
  if (length == 0) {
    return null;
  }
  String type=buf.toString(buf.readerIndex(),3,CHARSET);
  buf.skipBytes(type.length());
switch (type) {
case "String_Node_Str":
    return processSingle(channel,buf);
case "String_Node_Str":
  return processArray(channel,buf);
case "String_Node_Str":
return processHandshake(channel,buf);
default :
Log.warning(new UnsupportedOperationException(type));
break;
}
return null;
}
Program: 156163
Project: 156163
Buggy source:
@Override public void log(ChannelEvent e){
  if (e instanceof MessageEvent) {
    MessageEvent event=(MessageEvent)e;
    StringBuilder msg=new StringBuilder();
    msg.append("String_Node_Str").append(String.format("String_Node_Str",e.getChannel().getId())).append("String_Node_Str");
    msg.append(((InetSocketAddress)e.getChannel().getLocalAddress()).getPort());
    msg.append(e instanceof DownstreamMessageEvent ? "String_Node_Str" : "String_Node_Str");
    msg.append(((InetSocketAddress)event.getRemoteAddress()).getAddress().getHostAddress()).append("String_Node_Str");
    if (event.getMessage() instanceof ChannelBuffer) {
      msg.append("String_Node_Str");
      msg.append(ChannelBuffers.hexDump((ChannelBuffer)event.getMessage()));
    }
    Log.debug(msg.toString());
  }
}

Fixed version (ground truth):
@Override public void log(ChannelEvent e){
  if (e instanceof MessageEvent) {
    MessageEvent event=(MessageEvent)e;
    StringBuilder msg=new StringBuilder();
    msg.append("String_Node_Str").append(String.format("String_Node_Str",e.getChannel().getId())).append("String_Node_Str");
    msg.append(((InetSocketAddress)e.getChannel().getLocalAddress()).getPort());
    if (e instanceof DownstreamMessageEvent) {
      msg.append("String_Node_Str");
    }
 else {
      msg.append("String_Node_Str");
    }
    msg.append(((InetSocketAddress)event.getRemoteAddress()).getAddress().getHostAddress()).append("String_Node_Str");
    if (event.getMessage() instanceof ChannelBuffer) {
      msg.append("String_Node_Str");
      msg.append(ChannelBuffers.hexDump((ChannelBuffer)event.getMessage()));
    }
    Log.debug(msg.toString());
  }
}