nus-yam/ex-repair huggingface dataset:
Program: 156054
Project: 156054
Buggy source:
@Override public void filter(ContainerRequestContext requestContext){
  if (requestContext.getMethod().equals("String_Node_Str")) {
    throw new WebApplicationException(Response.status(Response.Status.OK).build());
  }
  SecurityContext securityContext=null;
  String authHeader=requestContext.getHeaderString(AUTHORIZATION_HEADER);
  if (authHeader != null) {
    try {
      String[] auth=decodeBasicAuth(authHeader);
      User user=Context.getDataManager().login(auth[0],auth[1]);
      if (user != null) {
        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) {
      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;
  String authHeader=requestContext.getHeaderString(AUTHORIZATION_HEADER);
  if (authHeader != null) {
    try {
      String[] auth=decodeBasicAuth(authHeader);
      User user=Context.getDataManager().login(auth[0],auth[1]);
      if (user != null) {
        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) {
      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());
    }
  }
}
Program: 156055
Project: 156055
Buggy source:
private Item findNearest(Item current,Item search,int depth){
  int direction=comparators.get(depth % 2).compare(search,current);
  Item next, other;
  if (direction < 0) {
    next=current.left;
    other=current.right;
  }
 else {
    next=current.right;
    other=current.left;
  }
  Item best=current;
  if (next != null) {
    best=findNearest(next,search,depth + 1);
  }
  if (current.squaredDistance(search) < best.squaredDistance(search)) {
    best=current;
  }
  if (other != null) {
    if (current.axisSquaredDistance(search,depth % 2) < best.squaredDistance(search)) {
      Item possibleBest=findNearest(other,search,depth + 1);
      if (possibleBest.squaredDistance(search) < best.squaredDistance(search)) {
        best=possibleBest;
      }
    }
  }
  return best;
}

Fixed version (ground truth):
private Item findNearest(Item current,Item search,int depth){
  int direction=comparators.get(depth % 2).compare(search,current);
  Item next, other;
  if (direction < 0) {
    next=current.left;
    other=current.right;
  }
 else {
    next=current.right;
    other=current.left;
  }
  Item best=current;
  if (next != null) {
    best=findNearest(next,search,depth + 1);
  }
  if (current.squaredDistance(search) < best.squaredDistance(search)) {
    best=current;
  }
  if (other != null && current.axisSquaredDistance(search,depth % 2) < best.squaredDistance(search)) {
    Item possibleBest=findNearest(other,search,depth + 1);
    if (possibleBest.squaredDistance(search) < best.squaredDistance(search)) {
      best=possibleBest;
    }
  }
  return best;
}
Program: 156056
Project: 156056
Buggy source:
private Item findNearest(Item current,Item search,int depth){
  int direction=comparators.get(depth % 2).compare(search,current);
  Item next, other;
  if (direction < 0) {
    next=current.left;
    other=current.right;
  }
 else {
    next=current.right;
    other=current.left;
  }
  Item best=current;
  if (next != null) {
    findNearest(next,search,depth + 1);
  }
  if (current.squaredDistance(search) < best.squaredDistance(search)) {
    best=current;
  }
  if (other != null) {
    if (current.axisSquaredDistance(search,depth % 2) < best.squaredDistance(search)) {
      Item possibleBest=findNearest(other,search,depth + 1);
      if (possibleBest.squaredDistance(search) < best.squaredDistance(search)) {
        best=possibleBest;
      }
    }
  }
  return best;
}

Fixed version (ground truth):
private Item findNearest(Item current,Item search,int depth){
  int direction=comparators.get(depth % 2).compare(search,current);
  Item next, other;
  if (direction < 0) {
    next=current.left;
    other=current.right;
  }
 else {
    next=current.right;
    other=current.left;
  }
  Item best=current;
  if (next != null) {
    best=findNearest(next,search,depth + 1);
  }
  if (current.squaredDistance(search) < best.squaredDistance(search)) {
    best=current;
  }
  if (other != null) {
    if (current.axisSquaredDistance(search,depth % 2) < best.squaredDistance(search)) {
      Item possibleBest=findNearest(other,search,depth + 1);
      if (possibleBest.squaredDistance(search) < best.squaredDistance(search)) {
        best=possibleBest;
      }
    }
  }
  return best;
}
Program: 156057
Project: 156057
Buggy source:
private void initApi(){
  ServletContextHandler servletHandler=new ServletContextHandler(ServletContextHandler.SESSIONS);
  servletHandler.setContextPath("String_Node_Str");
  servletHandler.getSessionHandler().setSessionManager(sessionManager);
  servletHandler.addServlet(new ServletHolder(new AsyncSocketServlet()),"String_Node_Str");
  ResourceConfig resourceConfig=new ResourceConfig();
  resourceConfig.register(ObjectMapperProvider.class);
  resourceConfig.register(ResourceErrorHandler.class);
  resourceConfig.register(SecurityRequestFilter.class);
  resourceConfig.register(CorsResponseFilter.class);
  resourceConfig.registerClasses(ServerResource.class,SessionResource.class,CommandResource.class,GroupPermissionResource.class,DevicePermissionResource.class,UserResource.class,GroupResource.class,DeviceResource.class,PositionResource.class);
  servletHandler.addServlet(new ServletHolder(new ServletContainer(resourceConfig)),"String_Node_Str");
  handlers.addHandler(servletHandler);
}

Fixed version (ground truth):
private void initApi(){
  ServletContextHandler servletHandler=new ServletContextHandler(ServletContextHandler.SESSIONS);
  servletHandler.setContextPath("String_Node_Str");
  servletHandler.getSessionHandler().setSessionManager(sessionManager);
  servletHandler.addServlet(new ServletHolder(new AsyncSocketServlet()),"String_Node_Str");
  ResourceConfig resourceConfig=new ResourceConfig();
  resourceConfig.register(ObjectMapperProvider.class);
  resourceConfig.register(JacksonFeature.class);
  resourceConfig.register(ResourceErrorHandler.class);
  resourceConfig.register(SecurityRequestFilter.class);
  resourceConfig.register(CorsResponseFilter.class);
  resourceConfig.registerClasses(ServerResource.class,SessionResource.class,CommandResource.class,GroupPermissionResource.class,DevicePermissionResource.class,UserResource.class,GroupResource.class,DeviceResource.class,PositionResource.class);
  servletHandler.addServlet(new ServletHolder(new ServletContainer(resourceConfig)),"String_Node_Str");
  handlers.addHandler(servletHandler);
}
Program: 156058
Project: 156058
Buggy source:
private Item findNearest(Item current,Item search,int depth){
  int direction=comparators.get(depth % 2).compare(search,current);
  Item next=(direction < 0) ? current.left : current.right;
  Item other=(direction < 0) ? current.right : current.left;
  Item best=(next == null) ? current : findNearest(next,search,depth + 1);
  if (current.squaredDistance(search) < best.squaredDistance(search)) {
    best=current;
  }
  if (other != null) {
    if (current.axisSquaredDistance(search,depth % 2) < best.squaredDistance(search)) {
      Item possibleBest=findNearest(other,search,depth + 1);
      if (possibleBest.squaredDistance(search) < best.squaredDistance(search)) {
        best=possibleBest;
      }
    }
  }
  return best;
}

Fixed version (ground truth):
private Item findNearest(Item current,Item search,int depth){
  int direction=comparators.get(depth % 2).compare(search,current);
  Item next, other;
  if (direction < 0) {
    next=current.left;
    other=current.right;
  }
 else {
    next=current.right;
    other=current.left;
  }
  Item best=current;
  if (next != null) {
    findNearest(next,search,depth + 1);
  }
  if (current.squaredDistance(search) < best.squaredDistance(search)) {
    best=current;
  }
  if (other != null) {
    if (current.axisSquaredDistance(search,depth % 2) < best.squaredDistance(search)) {
      Item possibleBest=findNearest(other,search,depth + 1);
      if (possibleBest.squaredDistance(search) < best.squaredDistance(search)) {
        best=possibleBest;
      }
    }
  }
  return best;
}
Program: 156060
Project: 156060
Buggy source:
private void saveOriginal(Object decodedMessage,Object originalMessage){
  if (Context.getConfig().getBoolean("String_Node_Str")) {
    if (decodedMessage instanceof Position) {
      Position position=(Position)decodedMessage;
      if (originalMessage instanceof ChannelBuffer) {
        position.set(Event.KEY_ORIGINAL,ChannelBuffers.hexDump((ChannelBuffer)originalMessage));
      }
 else       if (originalMessage instanceof String) {
        position.set(Event.KEY_ORIGINAL,DatatypeConverter.printHexBinary(((String)originalMessage).getBytes()));
      }
    }
  }
}

Fixed version (ground truth):
private void saveOriginal(Object decodedMessage,Object originalMessage){
  if (Context.getConfig().getBoolean("String_Node_Str") && decodedMessage instanceof Position) {
    Position position=(Position)decodedMessage;
    if (originalMessage instanceof ChannelBuffer) {
      position.set(Event.KEY_ORIGINAL,ChannelBuffers.hexDump((ChannelBuffer)originalMessage));
    }
 else     if (originalMessage instanceof String) {
      position.set(Event.KEY_ORIGINAL,DatatypeConverter.printHexBinary(((String)originalMessage).getBytes(Charset.defaultCharset())));
    }
  }
}
Program: 156061
Project: 156061
Buggy source:
@Override public void handleUpstream(final ChannelHandlerContext ctx,ChannelEvent evt) throws Exception {
  if (!(evt instanceof MessageEvent)) {
    ctx.sendUpstream(evt);
    return;
  }
  final MessageEvent e=(MessageEvent)evt;
  Object message=e.getMessage();
  if (message instanceof Position) {
    final Position position=(Position)message;
    if (position.getOutdated() || (processInvalidPositions && !position.getValid())) {
      locationProvider.getLocation(position.getAttributes(),new LocationProvider.LocationProviderCallback(){
        @Override public void onSuccess(        double latitude,        double longitude){
          position.set(Event.KEY_APPROXIMATE,true);
          position.setValid(true);
          position.setFixTime(position.getDeviceTime());
          position.setLatitude(latitude);
          position.setLongitude(longitude);
          Channels.fireMessageReceived(ctx,position,e.getRemoteAddress());
        }
        @Override public void onFailure(){
          Channels.fireMessageReceived(ctx,position,e.getRemoteAddress());
        }
      }
);
    }
 else {
      Channels.fireMessageReceived(ctx,position,e.getRemoteAddress());
    }
  }
 else {
    Channels.fireMessageReceived(ctx,message,e.getRemoteAddress());
  }
}

Fixed version (ground truth):
@Override public void handleUpstream(final ChannelHandlerContext ctx,ChannelEvent evt) throws Exception {
  if (!(evt instanceof MessageEvent)) {
    ctx.sendUpstream(evt);
    return;
  }
  final MessageEvent e=(MessageEvent)evt;
  Object message=e.getMessage();
  if (message instanceof Position) {
    final Position position=(Position)message;
    if (position.getOutdated() || processInvalidPositions && !position.getValid()) {
      locationProvider.getLocation(position.getAttributes(),new LocationProvider.LocationProviderCallback(){
        @Override public void onSuccess(        double latitude,        double longitude){
          position.set(Event.KEY_APPROXIMATE,true);
          position.setValid(true);
          position.setFixTime(position.getDeviceTime());
          position.setLatitude(latitude);
          position.setLongitude(longitude);
          Channels.fireMessageReceived(ctx,position,e.getRemoteAddress());
        }
        @Override public void onFailure(){
          Channels.fireMessageReceived(ctx,position,e.getRemoteAddress());
        }
      }
);
    }
 else {
      Channels.fireMessageReceived(ctx,position,e.getRemoteAddress());
    }
  }
 else {
    Channels.fireMessageReceived(ctx,message,e.getRemoteAddress());
  }
}
Program: 156062
Project: 156062
Buggy source:
public TreeNode(Device device){
  this.device=device;
}

Fixed version (ground truth):
TreeNode(Device device){
  this.device=device;
}
Program: 156063
Project: 156063
Buggy source:
@Override public boolean equals(Object obj){
  if (!(obj instanceof TreeNode)) {
    return false;
  }
  TreeNode other=(TreeNode)obj;
  if (other == this) {
    return true;
  }
  if (group != null) {
    if (other.group != null) {
      return group.getId() == other.group.getId();
    }
  }
 else   if (device != null) {
    if (other.device != null) {
      return device.getId() == other.device.getId();
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean equals(Object obj){
  if (!(obj instanceof TreeNode)) {
    return false;
  }
  TreeNode other=(TreeNode)obj;
  if (other == this) {
    return true;
  }
  if (group != null && other.group != null) {
    return group.getId() == other.group.getId();
  }
 else   if (device != null && other.device != null) {
    return device.getId() == other.device.getId();
  }
  return false;
}
Program: 156064
Project: 156064
Buggy source:
@Override public void filter(ContainerRequestContext request,ContainerResponseContext response) throws IOException {
  if (!response.getHeaders().containsKey(ACCESS_CONTROL_ALLOW_HEADERS_KEY)) {
    response.getHeaders().add(ACCESS_CONTROL_ALLOW_HEADERS_KEY,ACCESS_CONTROL_ALLOW_HEADERS_VALUE);
  }
  if (!response.getHeaders().containsKey(ACCESS_CONTROL_ALLOW_CREDENTIALS_KEY)) {
    response.getHeaders().add(ACCESS_CONTROL_ALLOW_CREDENTIALS_KEY,ACCESS_CONTROL_ALLOW_CREDENTIALS_VALUE);
  }
  if (!response.getHeaders().containsKey(ACCESS_CONTROL_ALLOW_METHODS_KEY)) {
    response.getHeaders().add(ACCESS_CONTROL_ALLOW_METHODS_KEY,ACCESS_CONTROL_ALLOW_METHODS_VALUE);
  }
  if (!response.getHeaders().containsKey(ACCESS_CONTROL_ALLOW_ORIGIN_KEY)) {
    String origin=request.getHeaderString(HttpHeaders.Names.ORIGIN);
    String allowed=Context.getConfig().getString("String_Node_Str");
    if (allowed == null) {
      response.getHeaders().add(ACCESS_CONTROL_ALLOW_ORIGIN_KEY,ACCESS_CONTROL_ALLOW_ORIGIN_VALUE);
    }
 else     if (allowed.contains(origin)) {
      String originSafe=URLEncoder.encode(origin,StandardCharsets.UTF_8.name());
      response.getHeaders().add(ACCESS_CONTROL_ALLOW_ORIGIN_KEY,originSafe);
    }
  }
}

Fixed version (ground truth):
@Override public void filter(ContainerRequestContext request,ContainerResponseContext response) throws IOException {
  if (!response.getHeaders().containsKey(ACCESS_CONTROL_ALLOW_HEADERS_KEY)) {
    response.getHeaders().add(ACCESS_CONTROL_ALLOW_HEADERS_KEY,ACCESS_CONTROL_ALLOW_HEADERS_VALUE);
  }
  if (!response.getHeaders().containsKey(ACCESS_CONTROL_ALLOW_CREDENTIALS_KEY)) {
    response.getHeaders().add(ACCESS_CONTROL_ALLOW_CREDENTIALS_KEY,ACCESS_CONTROL_ALLOW_CREDENTIALS_VALUE);
  }
  if (!response.getHeaders().containsKey(ACCESS_CONTROL_ALLOW_METHODS_KEY)) {
    response.getHeaders().add(ACCESS_CONTROL_ALLOW_METHODS_KEY,ACCESS_CONTROL_ALLOW_METHODS_VALUE);
  }
  if (!response.getHeaders().containsKey(ACCESS_CONTROL_ALLOW_ORIGIN_KEY)) {
    String origin=request.getHeaderString(HttpHeaders.Names.ORIGIN);
    String allowed=Context.getConfig().getString("String_Node_Str");
    if (allowed == null || origin == null) {
      response.getHeaders().add(ACCESS_CONTROL_ALLOW_ORIGIN_KEY,ACCESS_CONTROL_ALLOW_ORIGIN_VALUE);
    }
 else     if (allowed.contains(origin)) {
      String originSafe=URLEncoder.encode(origin,StandardCharsets.UTF_8.name());
      response.getHeaders().add(ACCESS_CONTROL_ALLOW_ORIGIN_KEY,originSafe);
    }
  }
}
Program: 156065
Project: 156065
Buggy source:
@Override protected final void service(HttpServletRequest req,HttpServletResponse resp) throws ServletException, IOException {
  try {
    resp.setContentType(APPLICATION_JSON);
    resp.setCharacterEncoding(CharsetUtil.UTF_8.name());
    resp.setHeader(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_HEADERS,ALLOW_HEADERS_VALUE);
    resp.setHeader(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_METHODS,ALLOW_METHODS_VALUE);
    String origin=req.getHeader(HttpHeaders.Names.ORIGIN);
    String allowed=Context.getConfig().getString("String_Node_Str");
    if (allowed == null) {
      resp.setHeader(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_ORIGIN,ALLOW_ORIGIN_VALUE);
    }
 else     if (allowed.contains(origin)) {
      String originSafe=URLEncoder.encode(origin,StandardCharsets.UTF_8.name());
      resp.setHeader(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_ORIGIN,originSafe);
    }
    if (!handle(getCommand(req),req,resp)) {
      resp.sendError(HttpServletResponse.SC_BAD_REQUEST);
    }
  }
 catch (  Exception error) {
    if (error instanceof AccessControlException) {
      resp.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
    }
 else     if (error instanceof SecurityException) {
      resp.setStatus(HttpServletResponse.SC_FORBIDDEN);
    }
    sendResponse(resp.getWriter(),error);
  }
}

Fixed version (ground truth):
@Override protected final void service(HttpServletRequest req,HttpServletResponse resp) throws ServletException, IOException {
  try {
    resp.setContentType(APPLICATION_JSON);
    resp.setCharacterEncoding(CharsetUtil.UTF_8.name());
    resp.setHeader(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_HEADERS,ALLOW_HEADERS_VALUE);
    resp.setHeader(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_METHODS,ALLOW_METHODS_VALUE);
    String origin=req.getHeader(HttpHeaders.Names.ORIGIN);
    String allowed=Context.getConfig().getString("String_Node_Str");
    if (allowed == null || origin == null) {
      resp.setHeader(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_ORIGIN,ALLOW_ORIGIN_VALUE);
    }
 else     if (allowed.contains(origin)) {
      String originSafe=URLEncoder.encode(origin,StandardCharsets.UTF_8.name());
      resp.setHeader(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_ORIGIN,originSafe);
    }
    if (!handle(getCommand(req),req,resp)) {
      resp.sendError(HttpServletResponse.SC_BAD_REQUEST);
    }
  }
 catch (  Exception error) {
    if (error instanceof AccessControlException) {
      resp.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
    }
 else     if (error instanceof SecurityException) {
      resp.setStatus(HttpServletResponse.SC_FORBIDDEN);
    }
    sendResponse(resp.getWriter(),error);
  }
}
Program: 156066
Project: 156066
Buggy source:
@Override protected Object decode(Channel channel,SocketAddress remoteAddress,Object msg) throws Exception {
  String x=PatternUtil.checkPattern(PATTERN.pattern(),(String)msg);
  Parser parser=new Parser(PATTERN,(String)msg);
  if (!parser.matches()) {
    return null;
  }
  Position position=new Position();
  position.setProtocol(getProtocolName());
  if (!identify(parser.next(),channel,remoteAddress)) {
    return null;
  }
  position.setDeviceId(getDeviceId());
  position.setValid(parser.nextInt() < 20);
  position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
  position.setCourse(parser.nextDouble());
  position.setAltitude(parser.nextDouble());
  position.setLongitude(parser.nextDouble());
  position.setLatitude(parser.nextDouble());
  DateBuilder dateBuilder=new DateBuilder().setDate(parser.nextInt(),parser.nextInt(),parser.nextInt()).setTime(parser.nextInt(),parser.nextInt(),parser.nextInt());
  position.setTime(dateBuilder.getDate());
  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));
  }
  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());
  if (!identify(parser.next(),channel,remoteAddress)) {
    return null;
  }
  position.setDeviceId(getDeviceId());
  position.setValid(parser.nextInt() < 20);
  position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
  position.setCourse(parser.nextDouble());
  position.setAltitude(parser.nextDouble());
  position.setLongitude(parser.nextDouble());
  position.setLatitude(parser.nextDouble());
  DateBuilder dateBuilder=new DateBuilder().setDate(parser.nextInt(),parser.nextInt(),parser.nextInt()).setTime(parser.nextInt(),parser.nextInt(),parser.nextInt());
  position.setTime(dateBuilder.getDate());
  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));
  }
  return position;
}
Program: 156067
Project: 156067
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());
  if (!identify(parser.next(),channel,remoteAddress)) {
    return null;
  }
  position.setDeviceId(getDeviceId());
  position.set(Event.KEY_TYPE,parser.next());
  DateBuilder dateBuilder=new DateBuilder().setDateReverse(parser.nextInt(),parser.nextInt(),parser.nextInt()).setTime(parser.nextInt(),parser.nextInt(),parser.nextInt());
  position.setTime(dateBuilder.getDate());
  if (parser.hasNext(6)) {
    position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_MIN_MIN));
    position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_MIN_MIN));
  }
  if (parser.hasNext(2)) {
    position.setLongitude(parser.nextDouble() / 10000);
    position.setLatitude(parser.nextDouble() / 10000);
  }
  position.setValid(parser.nextInt() != 1);
  position.setSpeed(parser.nextDouble());
  position.setCourse(parser.nextDouble());
  position.set(Event.KEY_SATELLITES,parser.next());
  position.set(Event.KEY_BATTERY,parser.nextInt());
  return position;
}

Fixed version (ground truth):
@Override protected Object decode(Channel channel,SocketAddress remoteAddress,Object msg) throws Exception {
  Parser parser=new Parser(PATTERN,(String)msg);
  if (!parser.matches()) {
    return null;
  }
  Position position=new Position();
  position.setProtocol(getProtocolName());
  if (!identify(parser.next(),channel,remoteAddress)) {
    return null;
  }
  position.setDeviceId(getDeviceId());
  position.set(Event.KEY_TYPE,parser.next());
  DateBuilder dateBuilder=new DateBuilder().setDateReverse(parser.nextInt(),parser.nextInt(),parser.nextInt()).setTime(parser.nextInt(),parser.nextInt(),parser.nextInt());
  position.setTime(dateBuilder.getDate());
  if (parser.hasNext(6)) {
    position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_MIN_MIN));
    position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_MIN_MIN));
  }
  if (parser.hasNext(2)) {
    position.setLongitude(parser.nextDouble() / 10000);
    position.setLatitude(parser.nextDouble() / 10000);
  }
  position.setValid(parser.nextInt() != 1);
  position.setSpeed(parser.nextDouble());
  position.setCourse(parser.nextDouble());
  position.set(Event.KEY_SATELLITES,parser.next());
  position.set(Event.KEY_BATTERY,parser.nextInt());
  return position;
}
Program: 156068
Project: 156068
Buggy source:
@Test public void testDecode() throws Exception {
  TelicProtocolDecoder decoder=new TelicProtocolDecoder(new TelicProtocol());
  verifyPosition(decoder,text("String_Node_Str"));
  verifyNothing(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"),position("String_Node_Str",true,47.53410,16.66530));
  verifyPosition(decoder,text("String_Node_Str"));
}

Fixed version (ground truth):
@Test public void testDecode() throws Exception {
  TelicProtocolDecoder decoder=new TelicProtocolDecoder(new TelicProtocol());
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyNothing(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"));
  verifyPosition(decoder,text("String_Node_Str"),position("String_Node_Str",true,47.53410,16.66530));
  verifyPosition(decoder,text("String_Node_Str"));
}
Program: 156071
Project: 156071
Buggy source:
private void sendResponse(Channel channel,SocketAddress remoteAddress,int version,ChannelBuffer id,short type,ChannelBuffer content){
  if (channel != null) {
    int length=2 + 2 + 1+ id.readableBytes()+ 2+ 2+ 2;
    if (content != null) {
      length+=content.readableBytes();
    }
    ChannelBuffer response=ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN,length);
    response.writeByte('@');
    response.writeByte('@');
    response.writeShort(length);
    response.writeByte(version);
    response.writeBytes(id);
    response.writeShort(ChannelBuffers.swapShort(type));
    if (content != null) {
      response.writeBytes(content);
    }
    response.writeShort(Checksum.crc16(Checksum.CRC16_X25,response.toByteBuffer(0,response.writerIndex())));
    response.writeByte(0x0D);
    response.writeByte(0x0A);
    channel.write(response,remoteAddress);
  }
}

Fixed version (ground truth):
private void sendResponse(Channel channel,SocketAddress remoteAddress,ChannelBuffer id,short type){
  if (channel != null) {
    int length=2 + 2 + id.readableBytes()+ 2+ 4+ 8+ 2+ 2;
    ChannelBuffer response=ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN,length);
    response.writeByte('@');
    response.writeByte('@');
    response.writeShort(length);
    response.writeBytes(id);
    response.writeShort(ChannelBuffers.swapShort(type));
    response.writeInt(0);
    for (int i=0; i < 8; i++) {
      response.writeByte(0xff);
    }
    response.writeShort(Checksum.crc16(Checksum.CRC16_X25,response.toByteBuffer(0,response.writerIndex())));
    response.writeByte(0x0D);
    response.writeByte(0x0A);
    channel.write(response,remoteAddress);
  }
}
Program: 156074
Project: 156074
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());
  if (!identify(parser.next(),channel,remoteAddress)) {
    return null;
  }
  position.setDeviceId(getDeviceId());
  position.setValid(parser.next().equals("String_Node_Str"));
  DateBuilder dateBuilder=new DateBuilder().setTime(parser.nextInt(),parser.nextInt(),parser.nextInt()).setDateReverse(parser.nextInt(),parser.nextInt(),parser.nextInt());
  position.setTime(dateBuilder.getDate());
  position.setLatitude(parser.nextCoordinate());
  position.setLatitude(parser.nextCoordinate());
  position.setSpeed(parser.nextDouble());
  position.setCourse(parser.nextDouble());
  position.set(Event.KEY_SATELLITES,parser.next());
  position.set(Event.KEY_HDOP,parser.next());
  position.set(Event.KEY_GSM,parser.next());
  position.set(Event.KEY_CHARGE,parser.nextInt() == 2);
  position.set(Event.KEY_BATTERY,parser.next());
  position.set(Event.PREFIX_ADC + 1,parser.nextInt());
  position.set(Event.PREFIX_ADC + 1,parser.nextInt());
  position.set(Event.KEY_ODOMETER,parser.next());
  position.set(Event.KEY_INPUT,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());
  if (!identify(parser.next(),channel,remoteAddress)) {
    return null;
  }
  position.setDeviceId(getDeviceId());
  position.setValid(parser.next().equals("String_Node_Str"));
  DateBuilder dateBuilder=new DateBuilder().setTime(parser.nextInt(),parser.nextInt(),parser.nextInt()).setDateReverse(parser.nextInt(),parser.nextInt(),parser.nextInt());
  position.setTime(dateBuilder.getDate());
  position.setLatitude(parser.nextCoordinate());
  position.setLongitude(parser.nextCoordinate());
  position.setSpeed(parser.nextDouble());
  position.setCourse(parser.nextDouble());
  position.set(Event.KEY_SATELLITES,parser.next());
  position.set(Event.KEY_HDOP,parser.next());
  position.set(Event.KEY_GSM,parser.next());
  position.set(Event.KEY_CHARGE,parser.nextInt() == 2);
  position.set(Event.KEY_BATTERY,parser.next());
  position.set(Event.PREFIX_ADC + 1,parser.nextInt());
  position.set(Event.PREFIX_ADC + 1,parser.nextInt());
  position.set(Event.KEY_ODOMETER,parser.next());
  position.set(Event.KEY_INPUT,parser.next());
  return position;
}
Program: 156075
Project: 156075
Buggy source:
@Test public void testDecode() throws Exception {
  DishaProtocolDecoder decoder=new DishaProtocolDecoder(new DishaProtocol());
  verifyPosition(decoder,text("String_Node_Str"));
}

Fixed version (ground truth):
@Test public void testDecode() throws Exception {
  DishaProtocolDecoder decoder=new DishaProtocolDecoder(new DishaProtocol());
  verifyPosition(decoder,text("String_Node_Str"),position("String_Node_Str",true,22.53365,88.35546));
  verifyPosition(decoder,text("String_Node_Str"));
}
Program: 156076
Project: 156076
Buggy source:
protected long getUserId(){
  return ((UserPrincipal)securityContext.getUserPrincipal()).getUserId();
}

Fixed version (ground truth):
protected long getUserId(){
  UserPrincipal principal=(UserPrincipal)securityContext.getUserPrincipal();
  if (principal != null) {
    return principal.getUserId();
  }
  return 0;
}
Program: 156077
Project: 156077
Buggy source:
@Override public Device getDeviceById(long id) throws SQLException {
  updateDeviceCache(!devicesById.containsKey(id));
  return devicesById.get(id);
}

Fixed version (ground truth):
@Override public Device getDeviceById(long id){
  try {
    updateDeviceCache(!devicesById.containsKey(id));
  }
 catch (  SQLException e) {
    Log.warning(e);
  }
  return devicesById.get(id);
}
Program: 156078
Project: 156078
Buggy source:
Device getDeviceById(long id) throws Exception ;

Fixed version (ground truth):
Device getDeviceById(long id);
Program: 156079
Project: 156079
Buggy source:
public static String[] decodeBasicAuth(String auth){
  auth=auth.replaceFirst("String_Node_Str","String_Node_Str");
  byte[] decodedBytes=DatatypeConverter.parseBase64Binary(auth);
  if (decodedBytes != null && decodedBytes.length > 0) {
    return new String(decodedBytes).split("String_Node_Str",2);
  }
  return null;
}

Fixed version (ground truth):
public static String[] decodeBasicAuth(String auth){
  auth=auth.replaceFirst("String_Node_Str","String_Node_Str");
  byte[] decodedBytes=DatatypeConverter.parseBase64Binary(auth);
  if (decodedBytes != null && decodedBytes.length > 0) {
    return new String(decodedBytes,Charset.defaultCharset()).split("String_Node_Str",2);
  }
  return null;
}
Program: 156081
Project: 156081
Buggy source:
public OpenChannelHandler(TrackerServer server){
  this.server=server;
}

Fixed version (ground truth):
private OpenChannelHandler(TrackerServer server){
  this.server=server;
}
Program: 156082
Project: 156082
Buggy source:
public ParseResult(long id,Position position){
  this.id=id;
  this.position=position;
}

Fixed version (ground truth):
private ParseResult(long id,Position position){
  this.id=id;
  this.position=position;
}
Program: 156083
Project: 156083
Buggy source:
@Override protected Object decode(Channel channel,SocketAddress remoteAddress,Object msg) throws Exception {
  ChannelBuffer buf=(ChannelBuffer)msg;
  buf.readUnsignedByte();
  int type=buf.readUnsignedShort();
  int flags=buf.readUnsignedShort();
  buf.skipBytes(6);
  buf.readUnsignedShort();
  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.skipBytes(6);
  buf.readUnsignedShort();
  return null;
}
Program: 156084
Project: 156084
Buggy source:
private static String formatSentence(Position position){
  StringBuilder s=new StringBuilder("String_Node_Str");
  try (Formatter f=new Formatter(s,Locale.ENGLISH)){
    Calendar calendar=Calendar.getInstance(TimeZone.getTimeZone("String_Node_Str"),Locale.ENGLISH);
    calendar.setTimeInMillis(position.getFixTime().getTime());
    f.format("String_Node_Str",calendar);
    double lat=position.getLatitude();
    double lon=position.getLongitude();
    f.format("String_Node_Str",(int)Math.abs(lat),Math.abs(lat) % 1 * 60,lat < 0 ? 'S' : 'N');
    f.format("String_Node_Str",(int)Math.abs(lon),Math.abs(lon) % 1 * 60,lon < 0 ? 'W' : 'E');
    f.format("String_Node_Str",position.getSpeed(),position.getCourse());
    f.format("String_Node_Str",calendar);
  }
   s.append(Checksum.nmea(s.toString()));
  return s.toString();
}

Fixed version (ground truth):
private static String formatSentence(Position position){
  StringBuilder s=new StringBuilder("String_Node_Str");
  try (Formatter f=new Formatter(s,Locale.ENGLISH)){
    Calendar calendar=Calendar.getInstance(TimeZone.getTimeZone("String_Node_Str"),Locale.ENGLISH);
    calendar.setTimeInMillis(position.getFixTime().getTime());
    f.format("String_Node_Str",calendar);
    double lat=position.getLatitude();
    double lon=position.getLongitude();
    char hemisphere;
    if (lat < 0) {
      hemisphere='S';
    }
 else {
      hemisphere='N';
    }
    f.format("String_Node_Str",(int)Math.abs(lat),Math.abs(lat) % 1 * 60,hemisphere);
    if (lon < 0) {
      hemisphere='W';
    }
 else {
      hemisphere='E';
    }
    f.format("String_Node_Str",(int)Math.abs(lon),Math.abs(lon) % 1 * 60,hemisphere);
    f.format("String_Node_Str",position.getSpeed(),position.getCourse());
    f.format("String_Node_Str",calendar);
  }
   s.append(Checksum.nmea(s.toString()));
  return s.toString();
}
Program: 156085
Project: 156085
Buggy source:
public User login(String email,String password) throws SQLException {
  User user=QueryBuilder.create(dataSource,getQuery("String_Node_Str")).setString("String_Node_Str",email).executeQuerySingle(new User());
  return user != null && user.isPasswordValid(password) ? user : null;
}

Fixed version (ground truth):
public User login(String email,String password) throws SQLException {
  User user=QueryBuilder.create(dataSource,getQuery("String_Node_Str")).setString("String_Node_Str",email).executeQuerySingle(new User());
  if (user != null && user.isPasswordValid(password)) {
    return user;
  }
 else {
    return null;
  }
}
Program: 156087
Project: 156087
Buggy source:
@Override public void handleUpstream(final ChannelHandlerContext ctx,ChannelEvent evt) throws Exception {
  if (!(evt instanceof MessageEvent)) {
    ctx.sendUpstream(evt);
    return;
  }
  final MessageEvent e=(MessageEvent)evt;
  Object message=e.getMessage();
  if (message instanceof Position) {
    final Position position=(Position)message;
    if (geocoder != null && (processInvalidPositions || position.getValid())) {
      geocoder.getAddress(addressFormat,position.getLatitude(),position.getLongitude(),new ReverseGeocoder.ReverseGeocoderCallback(){
        @Override public void onResult(        String address){
          position.setAddress(address);
          Channels.fireMessageReceived(ctx,position,e.getRemoteAddress());
        }
      }
);
    }
  }
 else {
    Channels.fireMessageReceived(ctx,message,e.getRemoteAddress());
  }
}

Fixed version (ground truth):
@Override public void handleUpstream(final ChannelHandlerContext ctx,ChannelEvent evt) throws Exception {
  if (!(evt instanceof MessageEvent)) {
    ctx.sendUpstream(evt);
    return;
  }
  final MessageEvent e=(MessageEvent)evt;
  Object message=e.getMessage();
  if (message instanceof Position) {
    final Position position=(Position)message;
    if (geocoder != null && (processInvalidPositions || position.getValid())) {
      geocoder.getAddress(addressFormat,position.getLatitude(),position.getLongitude(),new ReverseGeocoder.ReverseGeocoderCallback(){
        @Override public void onResult(        String address){
          position.setAddress(address);
          Channels.fireMessageReceived(ctx,position,e.getRemoteAddress());
        }
      }
);
    }
 else {
      Channels.fireMessageReceived(ctx,position,e.getRemoteAddress());
    }
  }
 else {
    Channels.fireMessageReceived(ctx,message,e.getRemoteAddress());
  }
}
Program: 156090
Project: 156090
Buggy source:
@Test public void testDecode() throws Exception {
  GoSafeProtocolDecoder decoder=new GoSafeProtocolDecoder(new GoSafeProtocol());
  verifyPositions(decoder,text("String_Node_Str"));
  verifyNothing(decoder,text("String_Node_Str"));
  verifyPositions(decoder,text("String_Node_Str"));
  verifyPositions(decoder,text("String_Node_Str"));
  verifyPositions(decoder,text("String_Node_Str"));
  verifyPositions(decoder,text("String_Node_Str"));
}

Fixed version (ground truth):
@Test public void testDecode() throws Exception {
  GoSafeProtocolDecoder decoder=new GoSafeProtocolDecoder(new GoSafeProtocol());
  verifyPositions(decoder,text("String_Node_Str"));
  verifyPositions(decoder,text("String_Node_Str"));
  verifyNothing(decoder,text("String_Node_Str"));
  verifyPositions(decoder,text("String_Node_Str"));
  verifyPositions(decoder,text("String_Node_Str"));
  verifyPositions(decoder,text("String_Node_Str"));
  verifyPositions(decoder,text("String_Node_Str"));
}
Program: 156091
Project: 156091
Buggy source:
@Test public void testDecode() throws Exception {
  GoSafeProtocolDecoder decoder=new GoSafeProtocolDecoder(new GoSafeProtocol());
  verifyPositions(decoder,text("String_Node_Str"));
  verifyPositions(decoder,text("String_Node_Str"));
  verifyNothing(decoder,text("String_Node_Str"));
  verifyPositions(decoder,text("String_Node_Str"));
  verifyPositions(decoder,text("String_Node_Str"));
  verifyPositions(decoder,text("String_Node_Str"));
  verifyPositions(decoder,text("String_Node_Str"));
}

Fixed version (ground truth):
@Test public void testDecode() throws Exception {
  GoSafeProtocolDecoder decoder=new GoSafeProtocolDecoder(new GoSafeProtocol());
  verifyPositions(decoder,text("String_Node_Str"));
  verifyPositions(decoder,text("String_Node_Str"));
  verifyPositions(decoder,text("String_Node_Str"));
  verifyNothing(decoder,text("String_Node_Str"));
  verifyPositions(decoder,text("String_Node_Str"));
  verifyPositions(decoder,text("String_Node_Str"));
  verifyPositions(decoder,text("String_Node_Str"));
}
Program: 156092
Project: 156092
Buggy source:
private Position decodePosition(Parser parser,Date time){
  Position position=new Position();
  position.setDeviceId(getDeviceId());
  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());
  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);
  }
  return position;
}

Fixed version (ground truth):
private Position decodePosition(Parser parser,Date time){
  Position position=new Position();
  position.setDeviceId(getDeviceId());
  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());
  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: 156093
Project: 156093
Buggy source:
protected void verifyPositions(BaseProtocolDecoder decoder,Object object,Position position) throws Exception {
  Object decodedObject=decoder.decode(null,null,object);
  Assert.assertNotNull(decodedObject);
  Assert.assertTrue(decodedObject instanceof List);
  for (  Object item : (List)decodedObject) {
    verifyDecodedPosition(item,position);
  }
}

Fixed version (ground truth):
protected void verifyPositions(BaseProtocolDecoder decoder,Object object,Position position) throws Exception {
  Object decodedObject=decoder.decode(null,null,object);
  Assert.assertNotNull(decodedObject);
  Assert.assertTrue(decodedObject instanceof List);
  Assert.assertFalse("String_Node_Str",((List)decodedObject).isEmpty());
  for (  Object item : (List)decodedObject) {
    verifyDecodedPosition(item,position);
  }
}
Program: 156094
Project: 156094
Buggy source:
@Test public void testDecode() throws Exception {
  GoSafeProtocolDecoder decoder=new GoSafeProtocolDecoder(new GoSafeProtocol());
  verifyNothing(decoder,text("String_Node_Str"));
  verifyPositions(decoder,text("String_Node_Str"));
  verifyPositions(decoder,text("String_Node_Str"));
  verifyPositions(decoder,text("String_Node_Str"));
  verifyPositions(decoder,text("String_Node_Str"));
}

Fixed version (ground truth):
@Test public void testDecode() throws Exception {
  GoSafeProtocolDecoder decoder=new GoSafeProtocolDecoder(new GoSafeProtocol());
  verifyPositions(decoder,text("String_Node_Str"));
  verifyNothing(decoder,text("String_Node_Str"));
  verifyPositions(decoder,text("String_Node_Str"));
  verifyPositions(decoder,text("String_Node_Str"));
  verifyPositions(decoder,text("String_Node_Str"));
  verifyPositions(decoder,text("String_Node_Str"));
}
Program: 156098
Project: 156098
Buggy source:
private void decodeGps(Position position,ChannelBuffer buf){
  DateBuilder dateBuilder=new DateBuilder(timeZone).setDate(buf.readUnsignedByte(),buf.readUnsignedByte(),buf.readUnsignedByte()).setTime(buf.readUnsignedByte(),buf.readUnsignedByte(),buf.readUnsignedByte());
  position.setTime(dateBuilder.getDate());
  int length=buf.readUnsignedByte();
  position.set(Event.KEY_SATELLITES,BitUtil.to(length,4));
  length=BitUtil.from(length,4);
  double latitude=buf.readUnsignedInt() / 60.0 / 30000.0;
  double longitude=buf.readUnsignedInt() / 60.0 / 30000.0;
  position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedByte()));
  int flags=buf.readUnsignedShort();
  position.setCourse(BitUtil.to(flags,10));
  position.setValid(BitUtil.check(flags,12));
  if (BitUtil.check(flags,10)) {
    latitude=-latitude;
  }
  if (BitUtil.check(flags,11)) {
    longitude=-longitude;
  }
  position.setLatitude(latitude);
  position.setLongitude(longitude);
  if (BitUtil.check(flags,14)) {
    position.set(Event.KEY_IGNITION,BitUtil.check(flags,15));
  }
  buf.skipBytes(length - 12);
}

Fixed version (ground truth):
private void decodeGps(Position position,ChannelBuffer buf){
  DateBuilder dateBuilder=new DateBuilder(timeZone).setDate(buf.readUnsignedByte(),buf.readUnsignedByte(),buf.readUnsignedByte()).setTime(buf.readUnsignedByte(),buf.readUnsignedByte(),buf.readUnsignedByte());
  position.setTime(dateBuilder.getDate());
  int length=buf.readUnsignedByte();
  position.set(Event.KEY_SATELLITES,BitUtil.to(length,4));
  length=BitUtil.from(length,4);
  double latitude=buf.readUnsignedInt() / 60.0 / 30000.0;
  double longitude=buf.readUnsignedInt() / 60.0 / 30000.0;
  position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedByte()));
  int flags=buf.readUnsignedShort();
  position.setCourse(BitUtil.to(flags,10));
  position.setValid(BitUtil.check(flags,12));
  if (!BitUtil.check(flags,10)) {
    latitude=-latitude;
  }
  if (BitUtil.check(flags,11)) {
    longitude=-longitude;
  }
  position.setLatitude(latitude);
  position.setLongitude(longitude);
  if (BitUtil.check(flags,14)) {
    position.set(Event.KEY_IGNITION,BitUtil.check(flags,15));
  }
  buf.skipBytes(length - 12);
}
Program: 156099
Project: 156099
Buggy source:
private void verifyDecodedPosition(Object decodedObject){
  Assert.assertNotNull(decodedObject);
  Assert.assertTrue(decodedObject instanceof Position);
  Position position=(Position)decodedObject;
  Assert.assertNotNull(position.getFixTime());
  Assert.assertTrue(position.getFixTime().after(new Date(946684800000L)));
  Assert.assertTrue(position.getFixTime().getTime() < System.currentTimeMillis() + 25 * 3600000);
  Assert.assertTrue(position.getLatitude() >= -90);
  Assert.assertTrue(position.getLatitude() <= 90);
  Assert.assertTrue(position.getLongitude() >= -180);
  Assert.assertTrue(position.getLongitude() <= 180);
  Assert.assertTrue(position.getAltitude() >= -12262);
  Assert.assertTrue(position.getAltitude() <= 18000);
  Assert.assertTrue(position.getSpeed() >= 0);
  Assert.assertTrue(position.getSpeed() <= 869);
  Assert.assertTrue(position.getCourse() >= 0);
  Assert.assertTrue(position.getCourse() <= 360);
}

Fixed version (ground truth):
private void verifyDecodedPosition(Object decodedObject){
  Assert.assertNotNull(decodedObject);
  Assert.assertTrue(decodedObject instanceof Position);
  Position position=(Position)decodedObject;
  Assert.assertNotNull(position.getFixTime());
  Assert.assertTrue("String_Node_Str",position.getFixTime().after(new Date(946684800000L)));
  Assert.assertTrue("String_Node_Str",position.getFixTime().getTime() < System.currentTimeMillis() + 25 * 3600000);
  Assert.assertTrue("String_Node_Str",position.getLatitude() >= -90);
  Assert.assertTrue("String_Node_Str",position.getLatitude() <= 90);
  Assert.assertTrue("String_Node_Str",position.getLongitude() >= -180);
  Assert.assertTrue("String_Node_Str",position.getLongitude() <= 180);
  Assert.assertTrue("String_Node_Str",position.getAltitude() >= -12262);
  Assert.assertTrue("String_Node_Str",position.getAltitude() <= 18000);
  Assert.assertTrue("String_Node_Str",position.getSpeed() >= 0);
  Assert.assertTrue("String_Node_Str",position.getSpeed() <= 869);
  Assert.assertTrue("String_Node_Str",position.getCourse() >= 0);
  Assert.assertTrue("String_Node_Str",position.getCourse() <= 360);
}
Program: 156100
Project: 156100
Buggy source:
protected ChannelBuffer binary(ByteOrder endianness,String... data){
  return ChannelBuffers.wrappedBuffer(endianness,ChannelBufferTools.convertHexString(String.join("String_Node_Str",data)));
}

Fixed version (ground truth):
protected ChannelBuffer binary(ByteOrder endianness,String... data){
  return ChannelBuffers.wrappedBuffer(endianness,ChannelBufferTools.convertHexString(concatenateStrings(data)));
}