Program: 155977
Project: 155977
Buggy source:
@Override protected Object decode(Channel channel,SocketAddress remoteAddress,Object msg) throws Exception {
  String sentence=(String)msg;
  int beginIndex=sentence.indexOf('(');
  if (beginIndex != -1) {
    sentence=sentence.substring(beginIndex + 1);
  }
  if (channel != null) {
    String id=sentence.substring(0,12);
    String type=sentence.substring(12,16);
    if (type.equals("String_Node_Str") || type.equals("String_Node_Str")) {
      String content=sentence.substring(16);
      if (content.length() >= 15) {
        getDeviceSession(channel,remoteAddress,content.substring(0,15));
      }
      if (type.equals("String_Node_Str")) {
        channel.write("String_Node_Str" + id + "String_Node_Str");
        return null;
      }
 else       if (type.equals("String_Node_Str")) {
        channel.write("String_Node_Str" + id + "String_Node_Str");
      }
    }
  }
  if (sentence.contains("String_Node_Str")) {
    return decodeBattery(channel,remoteAddress,sentence);
  }
 else   if (sentence.contains("String_Node_Str")) {
    return decodeNetwork(channel,remoteAddress,sentence);
  }
  Parser parser=new Parser(PATTERN,sentence);
  if (!parser.matches()) {
    return null;
  }
  DeviceSession deviceSession=getDeviceSession(channel,remoteAddress,parser.next());
  if (deviceSession == null) {
    return null;
  }
  Position position=new Position();
  position.setProtocol(getProtocolName());
  position.setDeviceId(deviceSession.getDeviceId());
  boolean alternative=parser.next() != null;
  decodeType(position,parser.next(),parser.next());
  DateBuilder dateBuilder=new DateBuilder();
  if (alternative) {
    dateBuilder.setDateReverse(parser.nextInt(0),parser.nextInt(0),parser.nextInt(0));
  }
 else {
    dateBuilder.setDate(parser.nextInt(0),parser.nextInt(0),parser.nextInt(0));
  }
  position.setValid(parser.next().equals("String_Node_Str"));
  position.setLatitude(parser.nextCoordinate());
  position.setLongitude(parser.nextCoordinate());
switch (Context.getConfig().getString(getProtocolName() + "String_Node_Str","String_Node_Str")) {
case "String_Node_Str":
    position.setSpeed(parser.nextDouble(0));
  break;
case "String_Node_Str":
position.setSpeed(UnitsConverter.knotsFromMph(parser.nextDouble(0)));
break;
default :
position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble(0)));
break;
}
dateBuilder.setTime(parser.nextInt(0),parser.nextInt(0),parser.nextInt(0));
position.setTime(dateBuilder.getDate());
position.setCourse(parser.nextDouble(0));
String status=parser.next();
if (status != null) {
position.set(Position.KEY_STATUS,status);
int value=Integer.parseInt(new StringBuilder(status).reverse().toString(),2);
position.set(Position.KEY_CHARGE,!BitUtil.check(value,0));
position.set(Position.KEY_IGNITION,BitUtil.check(value,1));
}
position.set(Position.KEY_STATUS,parser.next());
if (parser.hasNext()) {
position.set(Position.KEY_ODOMETER,parser.nextLong(16,0));
}
if (parser.hasNext()) {
position.set(Position.PREFIX_TEMP + 1,parser.nextDouble(0));
}
return position;
}

Fixed version (ground truth):
@Override protected Object decode(Channel channel,SocketAddress remoteAddress,Object msg) throws Exception {
  String sentence=(String)msg;
  int beginIndex=sentence.indexOf('(');
  if (beginIndex != -1) {
    sentence=sentence.substring(beginIndex + 1);
  }
  if (channel != null) {
    String id=sentence.substring(0,12);
    String type=sentence.substring(12,16);
    if (type.equals("String_Node_Str")) {
      channel.write("String_Node_Str" + id + "String_Node_Str");
      return null;
    }
 else     if (type.equals("String_Node_Str")) {
      channel.write("String_Node_Str" + id + "String_Node_Str");
    }
  }
  if (sentence.contains("String_Node_Str")) {
    return decodeBattery(channel,remoteAddress,sentence);
  }
 else   if (sentence.contains("String_Node_Str")) {
    return decodeNetwork(channel,remoteAddress,sentence);
  }
  Parser parser=new Parser(PATTERN,sentence);
  if (!parser.matches()) {
    return null;
  }
  DeviceSession deviceSession=getDeviceSession(channel,remoteAddress,parser.next());
  if (deviceSession == null) {
    return null;
  }
  Position position=new Position();
  position.setProtocol(getProtocolName());
  position.setDeviceId(deviceSession.getDeviceId());
  boolean alternative=parser.next() != null;
  decodeType(position,parser.next(),parser.next());
  DateBuilder dateBuilder=new DateBuilder();
  if (alternative) {
    dateBuilder.setDateReverse(parser.nextInt(0),parser.nextInt(0),parser.nextInt(0));
  }
 else {
    dateBuilder.setDate(parser.nextInt(0),parser.nextInt(0),parser.nextInt(0));
  }
  position.setValid(parser.next().equals("String_Node_Str"));
  position.setLatitude(parser.nextCoordinate());
  position.setLongitude(parser.nextCoordinate());
switch (Context.getConfig().getString(getProtocolName() + "String_Node_Str","String_Node_Str")) {
case "String_Node_Str":
    position.setSpeed(parser.nextDouble(0));
  break;
case "String_Node_Str":
position.setSpeed(UnitsConverter.knotsFromMph(parser.nextDouble(0)));
break;
default :
position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble(0)));
break;
}
dateBuilder.setTime(parser.nextInt(0),parser.nextInt(0),parser.nextInt(0));
position.setTime(dateBuilder.getDate());
position.setCourse(parser.nextDouble(0));
String status=parser.next();
if (status != null) {
position.set(Position.KEY_STATUS,status);
int value=Integer.parseInt(new StringBuilder(status).reverse().toString(),2);
position.set(Position.KEY_CHARGE,!BitUtil.check(value,0));
position.set(Position.KEY_IGNITION,BitUtil.check(value,1));
}
position.set(Position.KEY_STATUS,parser.next());
if (parser.hasNext()) {
position.set(Position.KEY_ODOMETER,parser.nextLong(16,0));
}
if (parser.hasNext()) {
position.set(Position.PREFIX_TEMP + 1,parser.nextDouble(0));
}
return position;
}