nus-yam/ex-repair huggingface dataset:
Program: 156001
Project: 156001
Buggy source:
@Override protected Object decode(Channel channel,SocketAddress remoteAddress,Object msg) throws Exception {
  org.traccar.helper.PatternUtil.MatchResult matchResult=org.traccar.helper.PatternUtil.checkPattern(PATTERN.pattern(),(String)msg);
  Parser parser=new Parser(PATTERN,(String)msg);
  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());
  DateBuilder dateBuilder=new DateBuilder().setDateReverse(parser.nextInt(),parser.nextInt(),parser.nextInt()).setTime(parser.nextInt(),parser.nextInt(),parser.nextInt());
  position.setTime(dateBuilder.getDate());
  position.setValid(parser.nextInt() > 0);
  position.setLatitude(parser.nextCoordinate());
  position.setLongitude(parser.nextCoordinate());
  position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
  position.setCourse(parser.nextDouble());
  position.setAltitude(parser.nextDouble());
  position.set(Position.KEY_HDOP,parser.nextDouble());
  position.set(Position.KEY_SATELLITES,parser.nextInt());
  position.set(Position.KEY_IGNITION,parser.nextInt() == 1);
  position.set(Position.KEY_BATTERY,parser.nextDouble());
  position.set(Position.KEY_POWER,parser.nextDouble());
  position.set(Position.KEY_INPUT,parser.nextInt(2));
  position.set(Position.KEY_OUTPUT,parser.nextInt(2));
  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;
  }
  DeviceSession deviceSession=getDeviceSession(channel,remoteAddress,parser.next());
  if (deviceSession == null) {
    return null;
  }
  Position position=new Position();
  position.setProtocol(getProtocolName());
  position.setDeviceId(deviceSession.getDeviceId());
  DateBuilder dateBuilder=new DateBuilder().setDateReverse(parser.nextInt(),parser.nextInt(),parser.nextInt()).setTime(parser.nextInt(),parser.nextInt(),parser.nextInt());
  position.setTime(dateBuilder.getDate());
  position.setValid(parser.nextInt() > 0);
  position.setLatitude(parser.nextCoordinate());
  position.setLongitude(parser.nextCoordinate());
  position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
  position.setCourse(parser.nextDouble());
  position.setAltitude(parser.nextDouble());
  position.set(Position.KEY_HDOP,parser.nextDouble());
  position.set(Position.KEY_SATELLITES,parser.nextInt());
  position.set(Position.KEY_IGNITION,parser.nextInt() == 1);
  position.set(Position.KEY_BATTERY,parser.nextDouble());
  position.set(Position.KEY_POWER,parser.nextDouble());
  position.set(Position.KEY_INPUT,parser.nextInt(2));
  position.set(Position.KEY_OUTPUT,parser.nextInt(2));
  return position;
}
Program: 156002
Project: 156002
Buggy source:
private void decodeParameter(Position position,int id,ChannelBuffer buf,int length){
switch (id) {
case 9:
    position.set(Position.PREFIX_ADC + 1,buf.readUnsignedShort());
  break;
case 66:
position.set(Position.KEY_POWER,buf.readUnsignedShort() + "String_Node_Str");
break;
case 67:
position.set(Position.KEY_BATTERY,buf.readUnsignedShort() + "String_Node_Str");
break;
case 72:
position.set(Position.PREFIX_TEMP + 1,buf.readInt() * 0.1);
break;
case 73:
position.set(Position.PREFIX_TEMP + 2,buf.readInt() * 0.1);
break;
case 74:
position.set(Position.PREFIX_TEMP + 3,buf.readInt() * 0.1);
break;
case 78:
position.set(Position.KEY_RFID,buf.readLong());
break;
case 182:
position.set(Position.KEY_HDOP,buf.readUnsignedShort() * 0.1);
break;
default :
switch (length) {
case 1:
position.set(Position.PREFIX_IO + id,buf.readUnsignedByte());
break;
case 2:
position.set(Position.PREFIX_IO + id,buf.readUnsignedShort());
break;
case 4:
position.set(Position.PREFIX_IO + id,buf.readUnsignedInt());
break;
case 8:
position.set(Position.PREFIX_IO + id,buf.readLong());
break;
}
break;
}
}

Fixed version (ground truth):
private void decodeParameter(Position position,int id,ChannelBuffer buf,int length){
switch (id) {
case 9:
    position.set(Position.PREFIX_ADC + 1,buf.readUnsignedShort());
  break;
case 66:
position.set(Position.KEY_POWER,buf.readUnsignedShort() + "String_Node_Str");
break;
case 67:
position.set(Position.KEY_BATTERY,buf.readUnsignedShort() + "String_Node_Str");
break;
case 72:
position.set(Position.PREFIX_TEMP + 1,buf.readInt() * 0.1);
break;
case 73:
position.set(Position.PREFIX_TEMP + 2,buf.readInt() * 0.1);
break;
case 74:
position.set(Position.PREFIX_TEMP + 3,buf.readInt() * 0.1);
break;
case 78:
position.set(Position.KEY_RFID,buf.readLong());
break;
case 182:
position.set(Position.KEY_HDOP,buf.readUnsignedShort() * 0.1);
break;
default :
switch (length) {
case 1:
position.set(Position.PREFIX_IO + id,buf.readUnsignedByte());
break;
case 2:
position.set(Position.PREFIX_IO + id,buf.readUnsignedShort());
break;
case 4:
position.set(Position.PREFIX_IO + id,buf.readUnsignedInt());
break;
case 8:
default :
position.set(Position.PREFIX_IO + id,buf.readLong());
break;
}
break;
}
}
Program: 156003
Project: 156003
Buggy source:
@Override public ObjectMapper getContext(Class<?> type){
  return mapper;
}

Fixed version (ground truth):
@Override public ObjectMapper getContext(Class<?> type){
  return Context.getObjectMapper();
}
Program: 156005
Project: 156005
Buggy source:
@Override public void process(T object,ResultSet resultSet) throws SQLException {
  String value=resultSet.getString(name);
  if (value != null) {
    try {
      method.invoke(object,Context.getObjectMapper().readValue(value,parameterType.getClass()));
    }
 catch (    InvocationTargetException|IllegalAccessException|IOException error) {
      Log.warning(error);
    }
  }
}

Fixed version (ground truth):
@Override public void process(T object,ResultSet resultSet) throws SQLException {
  String value=resultSet.getString(name);
  if (value != null) {
    try {
      method.invoke(object,Context.getObjectMapper().readValue(value,parameterType));
    }
 catch (    InvocationTargetException|IllegalAccessException|IOException error) {
      Log.warning(error);
    }
  }
}
Program: 156007
Project: 156007
Buggy source:
private double convertCoordinate(long value){
  boolean negative=value < 0;
  value=Math.abs(value);
  double minutes=(value % 100000) * 0.001;
  double degrees=value / 100000 + minutes / 60;
  return negative ? -degrees : degrees;
}

Fixed version (ground truth):
private double convertCoordinate(long value){
  boolean negative=value < 0;
  value=Math.abs(value);
  double minutes=(value % 100000) * 0.001;
  value/=100000;
  double degrees=value + minutes / 60;
  return negative ? -degrees : degrees;
}
Program: 156008
Project: 156008
Buggy source:
public boolean hasKey(String key){
  return properties.containsKey(key) || (defaultProperties != null && defaultProperties.containsKey(key));
}

Fixed version (ground truth):
public boolean hasKey(String key){
  return properties.containsKey(key) || defaultProperties != null && defaultProperties.containsKey(key);
}
Program: 156009
Project: 156009
Buggy source:
@Override public void filter(ContainerRequestContext requestContext){
  if (requestContext.getMethod().equals("String_Node_Str")) {
    return;
  }
  SecurityContext securityContext=null;
  String authHeader=requestContext.getHeaderString(AUTHORIZATION_HEADER);
  if (authHeader != null) {
    try {
      String[] auth=decodeBasicAuth(authHeader);
      User user=Context.getPermissionsManager().login(auth[0],auth[1]);
      if (user != null) {
        Context.getStatisticsManager().registerRequest(user.getId());
        securityContext=new UserSecurityContext(new UserPrincipal(user.getId()));
      }
    }
 catch (    SQLException e) {
      throw new WebApplicationException(e);
    }
  }
 else   if (request.getSession() != null) {
    Long userId=(Long)request.getSession().getAttribute(SessionResource.USER_ID_KEY);
    if (userId != null) {
      Context.getPermissionsManager().checkUser(userId);
      Context.getStatisticsManager().registerRequest(userId);
      securityContext=new UserSecurityContext(new UserPrincipal(userId));
    }
  }
  if (securityContext != null) {
    requestContext.setSecurityContext(securityContext);
  }
 else {
    Method method=resourceInfo.getResourceMethod();
    if (!method.isAnnotationPresent(PermitAll.class)) {
      throw new WebApplicationException(Response.status(Response.Status.UNAUTHORIZED).header(WWW_AUTHENTICATE,BASIC_REALM).build());
    }
  }
}

Fixed version (ground truth):
@Override public void filter(ContainerRequestContext requestContext){
  if (requestContext.getMethod().equals("String_Node_Str")) {
    return;
  }
  SecurityContext securityContext=null;
  try {
    String authHeader=requestContext.getHeaderString(AUTHORIZATION_HEADER);
    if (authHeader != null) {
      try {
        String[] auth=decodeBasicAuth(authHeader);
        User user=Context.getPermissionsManager().login(auth[0],auth[1]);
        if (user != null) {
          Context.getStatisticsManager().registerRequest(user.getId());
          securityContext=new UserSecurityContext(new UserPrincipal(user.getId()));
        }
      }
 catch (      SQLException e) {
        throw new WebApplicationException(e);
      }
    }
 else     if (request.getSession() != null) {
      Long userId=(Long)request.getSession().getAttribute(SessionResource.USER_ID_KEY);
      if (userId != null) {
        Context.getPermissionsManager().checkUser(userId);
        Context.getStatisticsManager().registerRequest(userId);
        securityContext=new UserSecurityContext(new UserPrincipal(userId));
      }
    }
  }
 catch (  SecurityException e) {
    Log.warning(e);
  }
  if (securityContext != null) {
    requestContext.setSecurityContext(securityContext);
  }
 else {
    Method method=resourceInfo.getResourceMethod();
    if (!method.isAnnotationPresent(PermitAll.class)) {
      throw new WebApplicationException(Response.status(Response.Status.UNAUTHORIZED).header(WWW_AUTHENTICATE,BASIC_REALM).build());
    }
  }
}
Program: 156011
Project: 156011
Buggy source:
@Test public void testDecode() throws Exception {
  AstraProtocolDecoder decoder=new AstraProtocolDecoder(new AstraProtocol());
  verifyPositions(decoder,binary("String_Node_Str"));
  verifyPositions(decoder,binary("String_Node_Str"));
}

Fixed version (ground truth):
@Test public void testDecode() throws Exception {
  AstraProtocolDecoder decoder=new AstraProtocolDecoder(new AstraProtocol());
  verifyPositions(decoder,binary("String_Node_Str"));
  verifyPositions(decoder,binary("String_Node_Str"));
  verifyPositions(decoder,binary("String_Node_Str"));
}
Program: 156012
Project: 156012
Buggy source:
private void decodeLocation(Position position,String data){
  Parser parser=new Parser(PATTERN_LOCATION,data);
  if (parser.matches()) {
    DateBuilder dateBuilder=new DateBuilder().setTime(parser.nextInt(),parser.nextInt(),parser.nextInt());
    position.setValid(true);
    position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_MIN_MIN));
    position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_MIN_MIN));
    int flags=parser.nextInt();
    position.setValid(BitUtil.check(flags,0));
    if (!BitUtil.check(flags,1)) {
      position.setLatitude(-position.getLatitude());
    }
    if (!BitUtil.check(flags,2)) {
      position.setLatitude(-position.getLatitude());
    }
    position.setSpeed(parser.nextInt() * 2);
    position.setCourse(parser.nextInt() * 10);
    dateBuilder.setDateReverse(parser.nextInt(),parser.nextInt(),parser.nextInt());
    position.setTime(dateBuilder.getDate());
  }
}

Fixed version (ground truth):
private void decodeLocation(Position position,String data){
  Parser parser=new Parser(PATTERN_LOCATION,data);
  if (parser.matches()) {
    DateBuilder dateBuilder=new DateBuilder().setTime(parser.nextInt(),parser.nextInt(),parser.nextInt());
    position.setValid(true);
    position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_MIN_MIN));
    position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_MIN_MIN));
    int flags=parser.nextInt();
    position.setValid(BitUtil.check(flags,0));
    if (!BitUtil.check(flags,1)) {
      position.setLatitude(-position.getLatitude());
    }
    if (!BitUtil.check(flags,2)) {
      position.setLongitude(-position.getLongitude());
    }
    position.setSpeed(parser.nextInt() * 2);
    position.setCourse(parser.nextInt() * 10);
    dateBuilder.setDateReverse(parser.nextInt(),parser.nextInt(),parser.nextInt());
    position.setTime(dateBuilder.getDate());
  }
}
Program: 156013
Project: 156013
Buggy source:
@Test public void testDecode() throws Exception {
  UproProtocolDecoder decoder=new UproProtocolDecoder(new UproProtocol());
  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"));
  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 {
  UproProtocolDecoder decoder=new UproProtocolDecoder(new UproProtocol());
  verifyPosition(decoder,text("String_Node_Str"),position("String_Node_Str",true,-33.58934,-70.61626));
  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"),position("String_Node_Str",false,49.22016,18.74855));
  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: 156014
Project: 156014
Buggy source:
@Test public void testDecode() throws Exception {
  UproProtocolDecoder decoder=new UproProtocolDecoder(new UproProtocol());
  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"));
}

Fixed version (ground truth):
@Test public void testDecode() throws Exception {
  UproProtocolDecoder decoder=new UproProtocolDecoder(new UproProtocol());
  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: 156015
Project: 156015
Buggy source:
public FilterHandler(){
  Config config=Context.getConfig();
  filterInvalid=config.getBoolean("String_Node_Str");
  filterZero=config.getBoolean("String_Node_Str");
  filterDuplicate=config.getBoolean("String_Node_Str");
  filterFuture=config.getBoolean("String_Node_Str");
  filterApproximate=config.getBoolean("String_Node_Str");
  filterStatic=config.getBoolean("String_Node_Str");
  filterDistance=config.getInteger("String_Node_Str");
  filterLimit=config.getLong("String_Node_Str") * 1000;
}

Fixed version (ground truth):
public FilterHandler(){
  Config config=Context.getConfig();
  if (config != null) {
    filterInvalid=config.getBoolean("String_Node_Str");
    filterZero=config.getBoolean("String_Node_Str");
    filterDuplicate=config.getBoolean("String_Node_Str");
    filterFuture=config.getBoolean("String_Node_Str");
    filterApproximate=config.getBoolean("String_Node_Str");
    filterStatic=config.getBoolean("String_Node_Str");
    filterDistance=config.getInteger("String_Node_Str");
    filterLimit=config.getLong("String_Node_Str") * 1000;
  }
}
Program: 156016
Project: 156016
Buggy source:
@Before public void setUp(){
  filtingHandler=new FilterHandler(true,true,true,true,true,10,10);
  passingHandler=new FilterHandler(false,false,false,false,false,0,0);
}

Fixed version (ground truth):
@Before public void setUp(){
  passingHandler=new FilterHandler();
  filtingHandler=new FilterHandler();
  filtingHandler.setFilterInvalid(true);
  filtingHandler.setFilterZero(true);
  filtingHandler.setFilterDuplicate(true);
  filtingHandler.setFilterFuture(true);
  filtingHandler.setFilterApproximate(true);
  filtingHandler.setFilterStatic(true);
  filtingHandler.setFilterDistance(10);
  filtingHandler.setFilterLimit(10);
}
Program: 156017
Project: 156017
Buggy source:
private void decodeJ1708(Position position,ChannelBuffer buf,short length){
  int end=buf.readerIndex() + length;
  while (buf.readerIndex() < end) {
    int mark=buf.readUnsignedByte();
    int len=BitUtil.between(mark,0,6);
    int type=BitUtil.between(mark,6,8);
    int id=buf.readUnsignedByte();
    if (type == 3) {
      id+=256;
    }
    String value=ChannelBuffers.hexDump(buf.readBytes(len - 1));
    if (type == 2 || type == 3) {
      position.set("String_Node_Str" + id,value);
    }
  }
}

Fixed version (ground truth):
private void decodeJ1708(Position position,ChannelBuffer buf,int length){
  int end=buf.readerIndex() + length;
  while (buf.readerIndex() < end) {
    int mark=buf.readUnsignedByte();
    int len=BitUtil.between(mark,0,6);
    int type=BitUtil.between(mark,6,8);
    int id=buf.readUnsignedByte();
    if (type == 3) {
      id+=256;
    }
    String value=ChannelBuffers.hexDump(buf.readBytes(len - 1));
    if (type == 2 || type == 3) {
      position.set("String_Node_Str" + id,value);
    }
  }
}
Program: 156018
Project: 156018
Buggy source:
private void decodeObd(Position position,ChannelBuffer buf,short length){
  int end=buf.readerIndex() + length;
  while (buf.readerIndex() < end) {
    int parameterLength=buf.getUnsignedByte(buf.readerIndex()) >> 4;
    int mode=buf.readUnsignedByte() & 0x0F;
    position.add(ObdDecoder.decode(mode,ChannelBuffers.hexDump(buf.readBytes(parameterLength - 1))));
  }
}

Fixed version (ground truth):
private void decodeObd(Position position,ChannelBuffer buf,int length){
  int end=buf.readerIndex() + length;
  while (buf.readerIndex() < end) {
    int parameterLength=buf.getUnsignedByte(buf.readerIndex()) >> 4;
    int mode=buf.readUnsignedByte() & 0x0F;
    position.add(ObdDecoder.decode(mode,ChannelBuffers.hexDump(buf.readBytes(parameterLength - 1))));
  }
}
Program: 156020
Project: 156020
Buggy source:
@Test public void testDecode() throws Exception {
  UlbotechProtocolDecoder decoder=new UlbotechProtocolDecoder(new UlbotechProtocol());
  verifyPosition(decoder,binary("String_Node_Str"));
  verifyNotNull(decoder,binary("String_Node_Str"));
  verifyNotNull(decoder,binary("String_Node_Str"));
  verifyAttributes(decoder,binary("String_Node_Str"));
  verifyAttributes(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"));
  verifyPosition(decoder,binary("String_Node_Str"));
  verifyPosition(decoder,binary("String_Node_Str"));
  verifyPosition(decoder,binary("String_Node_Str"));
  verifyPosition(decoder,binary("String_Node_Str"));
  verifyPosition(decoder,binary("String_Node_Str"));
  verifyPosition(decoder,binary("String_Node_Str"));
  verifyNotNull(decoder,binary("String_Node_Str"));
  verifyNotNull(decoder,binary("String_Node_Str"));
  verifyPosition(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 {
  UlbotechProtocolDecoder decoder=new UlbotechProtocolDecoder(new UlbotechProtocol());
  verifyPosition(decoder,binary("String_Node_Str"));
  verifyPosition(decoder,binary("String_Node_Str"));
  verifyNotNull(decoder,binary("String_Node_Str"));
  verifyNotNull(decoder,binary("String_Node_Str"));
  verifyAttributes(decoder,binary("String_Node_Str"));
  verifyAttributes(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"));
  verifyPosition(decoder,binary("String_Node_Str"));
  verifyPosition(decoder,binary("String_Node_Str"));
  verifyPosition(decoder,binary("String_Node_Str"));
  verifyPosition(decoder,binary("String_Node_Str"));
  verifyPosition(decoder,binary("String_Node_Str"));
  verifyPosition(decoder,binary("String_Node_Str"));
  verifyNotNull(decoder,binary("String_Node_Str"));
  verifyNotNull(decoder,binary("String_Node_Str"));
  verifyPosition(decoder,binary("String_Node_Str"));
  verifyPosition(decoder,binary("String_Node_Str"));
  verifyPosition(decoder,binary("String_Node_Str"));
}
Program: 156021
Project: 156021
Buggy source:
public static void sendMailSync(long userId,Event event,Position position){
  Properties mailServerProperties;
  Session mailSession;
  MimeMessage mailMessage;
  try {
    User user=Context.getPermissionsManager().getUser(userId);
    mailServerProperties=getConfigProperies();
    if (!mailServerProperties.containsKey("String_Node_Str")) {
      mailServerProperties=getAttributesProperties(user);
      if (!mailServerProperties.containsKey("String_Node_Str")) {
        return;
      }
    }
    mailSession=Session.getInstance(mailServerProperties,null);
    mailMessage=new MimeMessage(mailSession);
    if (mailServerProperties.getProperty("String_Node_Str") != null) {
      mailMessage.setFrom(new InternetAddress(mailServerProperties.getProperty("String_Node_Str")));
    }
    mailMessage.addRecipient(Message.RecipientType.TO,new InternetAddress(user.getEmail()));
    mailMessage.setSubject(NotificationFormatter.formatTitle(userId,event,position));
    mailMessage.setText(NotificationFormatter.formatMessage(userId,event,position));
    Transport transport=mailSession.getTransport("String_Node_Str");
    transport.connect(mailServerProperties.getProperty("String_Node_Str"),mailServerProperties.getProperty("String_Node_Str"),mailServerProperties.getProperty("String_Node_Str"));
    transport.sendMessage(mailMessage,mailMessage.getAllRecipients());
    transport.close();
  }
 catch (  MessagingException error) {
    Log.warning(error);
  }
}

Fixed version (ground truth):
public static void sendMailSync(long userId,Event event,Position position){
  Properties mailServerProperties;
  Session mailSession;
  MimeMessage mailMessage;
  try {
    User user=Context.getPermissionsManager().getUser(userId);
    mailServerProperties=getConfigProperies();
    if (!mailServerProperties.containsKey("String_Node_Str")) {
      mailServerProperties=getAttributesProperties(user);
      if (!mailServerProperties.containsKey("String_Node_Str")) {
        return;
      }
    }
    mailSession=Session.getDefaultInstance(mailServerProperties);
    mailMessage=new MimeMessage(mailSession);
    if (mailServerProperties.getProperty("String_Node_Str") != null) {
      mailMessage.setFrom(new InternetAddress(mailServerProperties.getProperty("String_Node_Str")));
    }
    mailMessage.addRecipient(Message.RecipientType.TO,new InternetAddress(user.getEmail()));
    mailMessage.setSubject(NotificationFormatter.formatTitle(userId,event,position));
    mailMessage.setText(NotificationFormatter.formatMessage(userId,event,position));
    Transport transport=mailSession.getTransport("String_Node_Str");
    transport.connect(mailServerProperties.getProperty("String_Node_Str"),mailServerProperties.getProperty("String_Node_Str"),mailServerProperties.getProperty("String_Node_Str"));
    transport.sendMessage(mailMessage,mailMessage.getAllRecipients());
    transport.close();
  }
 catch (  MessagingException error) {
    Log.warning(error);
  }
}
Program: 156022
Project: 156022
Buggy source:
public static int xor(String string){
  byte[] bytes=string.getBytes(StandardCharsets.US_ASCII);
  byte sum=0;
  for (  byte b : bytes) {
    sum^=b;
  }
  return sum;
}

Fixed version (ground truth):
public static int xor(String string){
  byte checksum=0;
  for (  byte b : string.getBytes(StandardCharsets.US_ASCII)) {
    checksum^=b;
  }
  return checksum;
}
Program: 156024
Project: 156024
Buggy source:
@Override protected Object decode(Channel channel,SocketAddress remoteAddress,Object msg) throws Exception {
  ChannelBuffer buf=(ChannelBuffer)msg;
  buf.skipBytes(2);
  buf.readUnsignedByte();
  String id=ChannelBuffers.hexDump(buf.readBytes(8));
  DeviceSession deviceSession=getDeviceSession(channel,remoteAddress,id);
  if (deviceSession == null) {
    return null;
  }
  int type=buf.readUnsignedByte();
  if (type == 0) {
    if (channel != null) {
    }
    Position position=new Position();
    position.setProtocol(getProtocolName());
    position.setDeviceId(deviceSession.getDeviceId());
    position.set(Position.KEY_STATUS,buf.readUnsignedByte());
    DateBuilder dateBuilder=new DateBuilder().setDate(2000,1,1).addSeconds(buf.readUnsignedInt());
    getLastLocation(position,dateBuilder.getDate());
    position.set(Position.KEY_INDEX,buf.readUnsignedByte());
    buf.readUnsignedShort();
    buf.readUnsignedShort();
    return position;
  }
  return null;
}

Fixed version (ground truth):
@Override protected Object decode(Channel channel,SocketAddress remoteAddress,Object msg) throws Exception {
  ChannelBuffer buf=(ChannelBuffer)msg;
  buf.skipBytes(2);
  buf.readUnsignedByte();
  String id=ChannelBuffers.hexDump(buf.readBytes(8));
  DeviceSession deviceSession=getDeviceSession(channel,remoteAddress,id);
  if (deviceSession == null) {
    return null;
  }
  int type=buf.readUnsignedByte();
  if (type == 0) {
    Position position=new Position();
    position.setProtocol(getProtocolName());
    position.setDeviceId(deviceSession.getDeviceId());
    position.set(Position.KEY_STATUS,buf.readUnsignedByte());
    DateBuilder dateBuilder=new DateBuilder().setDate(2000,1,1).addSeconds(buf.readUnsignedInt());
    getLastLocation(position,dateBuilder.getDate());
    position.set(Position.KEY_INDEX,buf.readUnsignedByte());
    buf.readUnsignedShort();
    buf.readUnsignedShort();
    return position;
  }
  return null;
}
Program: 156025
Project: 156025
Buggy source:
public void clearPositionsHistory() throws SQLException {
  int historyDays=config.getInteger("String_Node_Str");
  if (historyDays != 0) {
    QueryBuilder.create(dataSource,getQuery("String_Node_Str")).setDate("String_Node_Str",new Date(System.currentTimeMillis() - historyDays * 24 * 3600* 1000)).executeUpdate();
  }
}

Fixed version (ground truth):
public void clearPositionsHistory() throws SQLException {
  long historyDays=config.getInteger("String_Node_Str");
  if (historyDays != 0) {
    QueryBuilder.create(dataSource,getQuery("String_Node_Str")).setDate("String_Node_Str",new Date(System.currentTimeMillis() - historyDays * 24 * 3600* 1000)).executeUpdate();
  }
}
Program: 156026
Project: 156026
Buggy source:
private Position decodeNew(DeviceSession deviceSession,ChannelBuffer buf,int type,int index){
  Position position=new Position();
  position.setDeviceId(deviceSession.getDeviceId());
  position.setProtocol(getProtocolName());
  position.set(Position.KEY_INDEX,index);
  position.setTime(new Date(buf.readUnsignedInt() * 1000));
  int flags=buf.readUnsignedByte();
  if (BitUtil.check(flags,0)) {
    position.setLatitude(buf.readInt() / 1800000.0);
    position.setLongitude(buf.readInt() / 1800000.0);
    position.setAltitude(buf.readShort());
    position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedShort()));
    position.setCourse(buf.readUnsignedShort());
    position.set(Position.KEY_SATELLITES,buf.readUnsignedByte());
  }
  if (BitUtil.check(flags,1)) {
    position.set(Position.KEY_MCC,buf.readUnsignedShort());
    position.set(Position.KEY_MNC,buf.readUnsignedShort());
    position.set(Position.KEY_LAC,buf.readUnsignedShort());
    position.set(Position.KEY_CID,buf.readUnsignedInt());
    position.set(Position.KEY_GSM,buf.readUnsignedByte());
  }
  if (BitUtil.check(flags,2)) {
    buf.skipBytes(7);
  }
  if (BitUtil.check(flags,3)) {
    buf.skipBytes(7);
  }
  if (BitUtil.check(flags,4)) {
    buf.skipBytes(7);
  }
  if (BitUtil.check(flags,5)) {
    buf.skipBytes(7);
  }
  if (BitUtil.check(flags,6)) {
    buf.skipBytes(7);
  }
  return position;
}

Fixed version (ground truth):
private Position decodeNew(DeviceSession deviceSession,ChannelBuffer buf,int index){
  Position position=new Position();
  position.setDeviceId(deviceSession.getDeviceId());
  position.setProtocol(getProtocolName());
  position.set(Position.KEY_INDEX,index);
  position.setTime(new Date(buf.readUnsignedInt() * 1000));
  int flags=buf.readUnsignedByte();
  if (BitUtil.check(flags,0)) {
    position.setLatitude(buf.readInt() / 1800000.0);
    position.setLongitude(buf.readInt() / 1800000.0);
    position.setAltitude(buf.readShort());
    position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedShort()));
    position.setCourse(buf.readUnsignedShort());
    position.set(Position.KEY_SATELLITES,buf.readUnsignedByte());
  }
  if (BitUtil.check(flags,1)) {
    position.set(Position.KEY_MCC,buf.readUnsignedShort());
    position.set(Position.KEY_MNC,buf.readUnsignedShort());
    position.set(Position.KEY_LAC,buf.readUnsignedShort());
    position.set(Position.KEY_CID,buf.readUnsignedInt());
    position.set(Position.KEY_GSM,buf.readUnsignedByte());
  }
  if (BitUtil.check(flags,2)) {
    buf.skipBytes(7);
  }
  if (BitUtil.check(flags,3)) {
    buf.skipBytes(7);
  }
  if (BitUtil.check(flags,4)) {
    buf.skipBytes(7);
  }
  if (BitUtil.check(flags,5)) {
    buf.skipBytes(7);
  }
  if (BitUtil.check(flags,6)) {
    buf.skipBytes(7);
  }
  return position;
}
Program: 156027
Project: 156027
Buggy source:
@Override protected Object decode(Channel channel,SocketAddress remoteAddress,Object msg) throws Exception {
  ChannelBuffer buf=(ChannelBuffer)msg;
  buf.skipBytes(2);
  int type=buf.readUnsignedByte();
  buf.readShort();
  int index=buf.readUnsignedShort();
  if (type != MSG_GPS && type != MSG_DATA) {
    sendResponse(channel,type,index);
  }
  if (type == MSG_LOGIN) {
    getDeviceSession(channel,remoteAddress,ChannelBuffers.hexDump(buf.readBytes(8)).substring(1));
  }
 else {
    DeviceSession deviceSession=getDeviceSession(channel,remoteAddress);
    if (deviceSession == null) {
      return null;
    }
    if (type == MSG_GPS || type == MSG_ALARM || type == MSG_STATE || type == MSG_SMS) {
      return decodeOld(deviceSession,buf,type,index);
    }
 else     if (type >= MSG_NORMAL && type <= MSG_OBD_CODE) {
      return decodeNew(deviceSession,buf,type,index);
    }
  }
  return null;
}

Fixed version (ground truth):
@Override protected Object decode(Channel channel,SocketAddress remoteAddress,Object msg) throws Exception {
  ChannelBuffer buf=(ChannelBuffer)msg;
  buf.skipBytes(2);
  int type=buf.readUnsignedByte();
  buf.readShort();
  int index=buf.readUnsignedShort();
  if (type != MSG_GPS && type != MSG_DATA) {
    sendResponse(channel,type,index);
  }
  if (type == MSG_LOGIN) {
    getDeviceSession(channel,remoteAddress,ChannelBuffers.hexDump(buf.readBytes(8)).substring(1));
  }
 else {
    DeviceSession deviceSession=getDeviceSession(channel,remoteAddress);
    if (deviceSession == null) {
      return null;
    }
    if (type == MSG_GPS || type == MSG_ALARM || type == MSG_STATE || type == MSG_SMS) {
      return decodeOld(deviceSession,buf,type,index);
    }
 else     if (type >= MSG_NORMAL && type <= MSG_OBD_CODE) {
      return decodeNew(deviceSession,buf,index);
    }
  }
  return null;
}
Program: 156029
Project: 156029
Buggy source:
@Override protected Object decode(ChannelHandlerContext ctx,Channel channel,ChannelBuffer buf) throws Exception {
  if (buf.readableBytes() < 80) {
    return null;
  }
  int beginIndex=buf.indexOf(buf.readerIndex(),buf.writerIndex(),new StringFinder("String_Node_Str"));
  if (beginIndex == -1) {
    beginIndex=buf.indexOf(buf.readerIndex(),buf.writerIndex(),new StringFinder("String_Node_Str"));
    if (beginIndex == -1) {
      return null;
    }
  }
  int identifierIndex=buf.indexOf(beginIndex,buf.writerIndex(),new StringFinder("String_Node_Str"));
  if (identifierIndex == -1) {
    return null;
  }
  int endIndex=buf.indexOf(identifierIndex,buf.writerIndex(),(byte)',');
  if (endIndex == -1) {
    return null;
  }
  buf.skipBytes(beginIndex);
  return buf.readBytes(endIndex - beginIndex + 1);
}

Fixed version (ground truth):
@Override protected Object decode(ChannelHandlerContext ctx,Channel channel,ChannelBuffer buf) throws Exception {
  if (buf.readableBytes() < 80) {
    return null;
  }
  int beginIndex=buf.indexOf(buf.readerIndex(),buf.writerIndex(),new StringFinder("String_Node_Str"));
  if (beginIndex == -1) {
    beginIndex=buf.indexOf(buf.readerIndex(),buf.writerIndex(),new StringFinder("String_Node_Str"));
    if (beginIndex == -1) {
      return null;
    }
  }
  int identifierIndex=buf.indexOf(beginIndex,buf.writerIndex(),new StringFinder("String_Node_Str"));
  if (identifierIndex == -1) {
    return null;
  }
  int endIndex=buf.indexOf(identifierIndex,buf.writerIndex(),(byte)',');
  if (endIndex == -1) {
    return null;
  }
  buf.skipBytes(beginIndex - buf.readerIndex());
  return buf.readBytes(endIndex - beginIndex + 1);
}
Program: 156031
Project: 156031
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());
  DateBuilder dateBuilder=new DateBuilder().setDateReverse(parser.nextInt(),parser.nextInt(),parser.nextInt()).setTime(parser.nextInt(),parser.nextInt(),parser.nextInt());
  position.setTime(dateBuilder.getDate());
  position.setValid(true);
  position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.HEM_DEG_MIN_MIN));
  position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.HEM_DEG_MIN_MIN));
  position.setSpeed(parser.nextDouble());
  position.setCourse(parser.nextDouble());
  position.set(Position.KEY_SATELLITES,parser.next());
  position.set(Position.KEY_BATTERY,parser.next());
  position.set(Position.KEY_INPUT,parser.next());
  position.set(Position.KEY_OUTPUT,parser.next());
  position.set(Position.PREFIX_TEMP + 1,parser.next());
  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());
  DateBuilder dateBuilder=new DateBuilder().setDateReverse(parser.nextInt(),parser.nextInt(),parser.nextInt()).setTime(parser.nextInt(),parser.nextInt(),parser.nextInt());
  position.setTime(dateBuilder.getDate());
  position.setValid(true);
  position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.HEM_DEG_MIN_MIN));
  position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.HEM_DEG_MIN_MIN));
  position.setSpeed(parser.nextDouble());
  position.setCourse(parser.nextDouble());
  position.set(Position.KEY_SATELLITES,parser.nextInt(16));
  position.set(Position.KEY_BATTERY,parser.next());
  position.set(Position.KEY_INPUT,parser.next());
  position.set(Position.KEY_OUTPUT,parser.next());
  position.set(Position.PREFIX_TEMP + 1,parser.next());
  return position;
}
Program: 156032
Project: 156032
Buggy source:
@Test public void testDecode() throws Exception {
  GpsMarkerProtocolDecoder decoder=new GpsMarkerProtocolDecoder(new GpsMarkerProtocol());
  verifyNothing(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"),position("String_Node_Str",true,55.86132,37.93539));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
}

Fixed version (ground truth):
@Test public void testDecode() throws Exception {
  GpsMarkerProtocolDecoder decoder=new GpsMarkerProtocolDecoder(new GpsMarkerProtocol());
  verifyPosition(decoder,text("String_Node_Str"));
  verifyNothing(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"),position("String_Node_Str",true,55.86132,37.93539));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
}
Program: 156038
Project: 156038
Buggy source:
@Override public Collection<String> getSupportedCommands(){
  return supportedCommands;
}

Fixed version (ground truth):
@Override public Collection<String> getSupportedCommands(){
  Set<String> commands=new HashSet<>(supportedCommands);
  commands.add(Command.TYPE_CUSTOM);
  return commands;
}
Program: 156039
Project: 156039
Buggy source:
public BaseProtocol(String name){
  this.name=name;
  supportedCommands.add(Command.TYPE_CUSTOM);
}

Fixed version (ground truth):
public BaseProtocol(String name){
  this.name=name;
}
Program: 156041
Project: 156041
Buggy source:
@Override protected Object decode(ChannelHandlerContext ctx,Channel channel,ChannelBuffer buf) throws Exception {
  if (buf.readableBytes() < 2) {
    return null;
  }
  int index=buf.indexOf(buf.readerIndex() + 1,buf.writerIndex(),(byte)0xC0);
  if (index != -1) {
    return buf.readBytes(index + 1 - buf.readerIndex());
  }
  return null;
}

Fixed version (ground truth):
@Override protected Object decode(ChannelHandlerContext ctx,Channel channel,ChannelBuffer buf) throws Exception {
  if (buf.readableBytes() < 2) {
    return null;
  }
  int index=buf.indexOf(buf.readerIndex() + 1,buf.writerIndex(),(byte)0xC0);
  if (index != -1) {
    ChannelBuffer result=ChannelBuffers.buffer(index + 1 - buf.readerIndex());
    while (buf.readerIndex() <= index) {
      int b=buf.readUnsignedByte();
      if (b == 0xDB) {
        int ext=buf.readUnsignedByte();
        if (ext == 0xDC) {
          result.writeByte(0xC0);
        }
 else         if (ext == 0xDD) {
          result.writeByte(0xDB);
        }
      }
 else {
        result.writeByte(b);
      }
    }
    return result;
  }
  return null;
}
Program: 156042
Project: 156042
Buggy source:
@Test public void testDecode() throws Exception {
  HuaShengFrameDecoder decoder=new HuaShengFrameDecoder();
  Assert.assertEquals(binary("String_Node_Str"),decoder.decode(null,null,binary("String_Node_Str")));
  Assert.assertEquals(binary("String_Node_Str"),decoder.decode(null,null,binary("String_Node_Str")));
}

Fixed version (ground truth):
@Test public void testDecode() throws Exception {
  HuaShengFrameDecoder decoder=new HuaShengFrameDecoder();
  Assert.assertEquals(binary("String_Node_Str"),decoder.decode(null,null,binary("String_Node_Str")));
  Assert.assertEquals(binary("String_Node_Str"),decoder.decode(null,null,binary("String_Node_Str")));
  Assert.assertEquals(binary("String_Node_Str"),decoder.decode(null,null,binary("String_Node_Str")));
  Assert.assertEquals(binary("String_Node_Str"),decoder.decode(null,null,binary("String_Node_Str")));
}
Program: 156044
Project: 156044
Buggy source:
public List<Long> getCurrentDeviceGeofences(Position position){
  List<Long> result=new ArrayList<Long>();
  for (  Long geofenceId : getAllDeviceGeofences(position.getDeviceId())) {
    if (getGeofence(geofenceId).getGeometry().containsPoint(position.getLatitude(),position.getLongitude())) {
      result.add(geofenceId);
    }
  }
  return result;
}

Fixed version (ground truth):
public List<Long> getCurrentDeviceGeofences(Position position){
  List<Long> result=new ArrayList<>();
  for (  Long geofenceId : getAllDeviceGeofences(position.getDeviceId())) {
    if (getGeofence(geofenceId).getGeometry().containsPoint(position.getLatitude(),position.getLongitude())) {
      result.add(geofenceId);
    }
  }
  return result;
}
Program: 156048
Project: 156048
Buggy source:
@Override protected void addSpecificHandlers(ChannelPipeline pipeline){
  pipeline.addLast("String_Node_Str",new StringEncoder());
  pipeline.addLast("String_Node_Str",new StringDecoder());
  pipeline.addLast("String_Node_Str",new LdplProtocolDecoder(LdplProtocol.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 StringEncoder());
  pipeline.addLast("String_Node_Str",new StringDecoder());
  pipeline.addLast("String_Node_Str",new LdplProtocolDecoder(LdplProtocol.this));
}
Program: 156049
Project: 156049
Buggy source:
@Override public void initTrackerServers(List<TrackerServer> serverList){
  serverList.add(new TrackerServer(new ConnectionlessBootstrap(),this.getName()){
    @Override protected void addSpecificHandlers(    ChannelPipeline pipeline){
      pipeline.addLast("String_Node_Str",new StringEncoder());
      pipeline.addLast("String_Node_Str",new StringDecoder());
      pipeline.addLast("String_Node_Str",new LdplProtocolDecoder(LdplProtocol.this));
    }
  }
);
}

Fixed version (ground truth):
@Override public void initTrackerServers(List<TrackerServer> serverList){
  serverList.add(new TrackerServer(new ServerBootstrap(),this.getName()){
    @Override protected void addSpecificHandlers(    ChannelPipeline pipeline){
      pipeline.addLast("String_Node_Str",new LineBasedFrameDecoder(1024));
      pipeline.addLast("String_Node_Str",new StringEncoder());
      pipeline.addLast("String_Node_Str",new StringDecoder());
      pipeline.addLast("String_Node_Str",new LdplProtocolDecoder(LdplProtocol.this));
    }
  }
);
}
Program: 156051
Project: 156051
Buggy source:
@Test public void testCheckPattern(){
  assertEquals("String_Node_Str",PatternUtil.checkPattern("String_Node_Str","String_Node_Str").pattern);
}

Fixed version (ground truth):
@Test public void testCheckPattern(){
  assertEquals("String_Node_Str",PatternUtil.checkPattern("String_Node_Str","String_Node_Str").getPattern());
}
Program: 156052
Project: 156052
Buggy source:
private Position decodePosition(Parser parser,Date time){
  Position position=new Position();
  position.setProtocol(getProtocolName());
  position.setDeviceId(getDeviceId());
  if (time != null) {
    position.setTime(time);
  }
  position.set(Event.KEY_EVENT,parser.next());
  position.setValid(parser.next().equals("String_Node_Str"));
  position.set(Event.KEY_SATELLITES,parser.next());
  position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.HEM_DEG));
  position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.HEM_DEG));
  position.setSpeed(parser.nextDouble());
  position.setCourse(parser.nextDouble());
  position.setAltitude(parser.nextDouble());
  position.set(Event.KEY_HDOP,parser.next());
  if (parser.hasNext(4)) {
    position.set(Event.KEY_MCC,parser.nextInt());
    position.set(Event.KEY_MNC,parser.nextInt());
    position.set(Event.KEY_LAC,parser.nextInt(16));
    position.set(Event.KEY_CID,parser.nextInt(16));
  }
  position.set(Event.KEY_ODOMETER,parser.next());
  position.set(Event.KEY_POWER,parser.next());
  position.set(Event.KEY_BATTERY,parser.next());
  String status=parser.next();
  if (status != null) {
    position.set(Event.KEY_IGNITION,BitUtil.check(Integer.parseInt(status,16),13));
    position.set(Event.KEY_STATUS,status);
  }
  if (parser.hasNext()) {
    position.set("String_Node_Str",parser.next());
  }
  return position;
}

Fixed version (ground truth):
private Position decodePosition(Parser parser,Date time){
  Position position=new Position();
  position.setProtocol(getProtocolName());
  position.setDeviceId(getDeviceId());
  if (time != null) {
    position.setTime(time);
  }
  position.set(Event.KEY_EVENT,parser.next());
  position.setValid(parser.next().equals("String_Node_Str"));
  position.set(Event.KEY_SATELLITES,parser.next());
  position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.HEM_DEG));
  position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.HEM_DEG));
  position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
  position.setCourse(parser.nextDouble());
  position.setAltitude(parser.nextDouble());
  position.set(Event.KEY_HDOP,parser.next());
  if (parser.hasNext(4)) {
    position.set(Event.KEY_MCC,parser.nextInt());
    position.set(Event.KEY_MNC,parser.nextInt());
    position.set(Event.KEY_LAC,parser.nextInt(16));
    position.set(Event.KEY_CID,parser.nextInt(16));
  }
  position.set(Event.KEY_ODOMETER,parser.next());
  position.set(Event.KEY_POWER,parser.next());
  position.set(Event.KEY_BATTERY,parser.next());
  String status=parser.next();
  if (status != null) {
    position.set(Event.KEY_IGNITION,BitUtil.check(Integer.parseInt(status,16),13));
    position.set(Event.KEY_STATUS,status);
  }
  if (parser.hasNext()) {
    position.set("String_Node_Str",parser.next());
  }
  return position;
}
Program: 156053
Project: 156053
Buggy source:
@Override public void filter(ContainerRequestContext request,ContainerResponseContext response) throws IOException {
  if (!response.getHeaders().containsKey(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_HEADERS)) {
    response.getHeaders().add(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_HEADERS,HEADERS_ALL);
  }
  if (!response.getHeaders().containsKey(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_CREDENTIALS)) {
    response.getHeaders().add(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_CREDENTIALS,true);
  }
  if (!response.getHeaders().containsKey(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_METHODS)) {
    response.getHeaders().add(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_METHODS,METHODS_ALL);
  }
  if (!response.getHeaders().containsKey(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_ORIGIN)) {
    String origin=request.getHeaderString(HttpHeaders.Names.ORIGIN);
    String allowed=Context.getConfig().getString("String_Node_Str");
    if (allowed == null || origin == null) {
      response.getHeaders().add(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_ORIGIN,ORIGIN_ALL);
    }
 else     if (allowed.equals(ORIGIN_ALL) || allowed.contains(origin)) {
      response.getHeaders().add(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_ORIGIN,origin);
    }
  }
}

Fixed version (ground truth):
@Override public void filter(ContainerRequestContext request,ContainerResponseContext response) throws IOException {
  if (!response.getHeaders().containsKey(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_HEADERS)) {
    response.getHeaders().add(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_HEADERS,HEADERS_ALL);
  }
  if (!response.getHeaders().containsKey(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_CREDENTIALS)) {
    response.getHeaders().add(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_CREDENTIALS,true);
  }
  if (!response.getHeaders().containsKey(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_METHODS)) {
    response.getHeaders().add(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_METHODS,METHODS_ALL);
  }
  if (!response.getHeaders().containsKey(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_ORIGIN)) {
    String origin=request.getHeaderString(HttpHeaders.Names.ORIGIN);
    String allowed=Context.getConfig().getString("String_Node_Str");
    if (origin == null) {
      response.getHeaders().add(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_ORIGIN,ORIGIN_ALL);
    }
 else     if (allowed == null || allowed.equals(ORIGIN_ALL) || allowed.contains(origin)) {
      response.getHeaders().add(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_ORIGIN,origin);
    }
  }
}