Program: 62598
Project: 62598
Buggy source:
/** 
 * Hue API call to set the state of a light
 * @param id
 * @param req
 * @param resp
 * @throws IOException
 */
private void apiState(String id,HttpServletRequest req,HttpServletResponse resp) throws IOException {
  if (!req.getMethod().equals(METHOD_PUT)) {
    apiServerError(req,resp,HueErrorResponse.METHOD_NOT_AVAILABLE,"String_Node_Str");
    return;
  }
  try {
    Item item=itemRegistry.getItem(id);
    HueState state=gson.fromJson(req.getReader(),HueState.class);
    logger.debug("String_Node_Str" + state);
    String value;
    if (item.getAcceptedCommandTypes().contains(HSBType.class)) {
      value=String.format("String_Node_Str",state.hue,state.sat,state.bri);
    }
 else     if (state.bri > -1 && (item.getAcceptedCommandTypes().contains(DecimalType.class) || item.getAcceptedCommandTypes().contains(PercentType.class))) {
      value=String.valueOf(Math.round(state.bri / 255.0 * 100));
    }
 else {
      value=state.on ? "String_Node_Str" : "String_Node_Str";
    }
    Command command=TypeParser.parseCommand(item.getAcceptedCommandTypes(),value);
    eventPublisher.post(ItemEventFactory.createCommandEvent(id,command));
    PrintWriter out=resp.getWriter();
    out.write(String.format(STATE_RESP,id,String.valueOf(state.on)));
    out.close();
  }
 catch (  ItemNotFoundException e) {
    logger.debug("String_Node_Str" + id);
    apiServerError(req,resp,HueErrorResponse.NOT_AVAILABLE,"String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Hue API call to set the state of a light
 * @param id
 * @param req
 * @param resp
 * @throws IOException
 */
private void apiState(String id,HttpServletRequest req,HttpServletResponse resp) throws IOException {
  if (!req.getMethod().equals(METHOD_PUT)) {
    apiServerError(req,resp,HueErrorResponse.METHOD_NOT_AVAILABLE,"String_Node_Str");
    return;
  }
  try {
    Item item=itemRegistry.getItem(id);
    HueState state=gson.fromJson(req.getReader(),HueState.class);
    HSBType hsb=state.toHSBType();
    logger.debug("String_Node_Str" + state);
    logger.debug("String_Node_Str" + hsb);
    Command command=null;
    if (hsb.getBrightness().intValue() > 0) {
      if (item.getAcceptedCommandTypes().contains(HSBType.class)) {
        command=hsb;
      }
 else {
        command=TypeParser.parseCommand(item.getAcceptedCommandTypes(),hsb.getBrightness().toString());
        if (command == null) {
          command=TypeParser.parseCommand(item.getAcceptedCommandTypes(),"String_Node_Str");
        }
      }
    }
 else {
      command=TypeParser.parseCommand(item.getAcceptedCommandTypes(),"String_Node_Str");
      if (command == null) {
        command=TypeParser.parseCommand(item.getAcceptedCommandTypes(),"String_Node_Str");
      }
    }
    if (command != null) {
      logger.debug("String_Node_Str",command,id);
      eventPublisher.post(ItemEventFactory.createCommandEvent(id,command));
      PrintWriter out=resp.getWriter();
      out.write(String.format(STATE_RESP,id,String.valueOf(state.on)));
      out.close();
    }
 else {
      logger.error("String_Node_Str",id);
      apiServerError(req,resp,HueErrorResponse.INTERNAL_ERROR,"String_Node_Str");
    }
  }
 catch (  ItemNotFoundException e) {
    logger.debug("String_Node_Str",id);
    apiServerError(req,resp,HueErrorResponse.NOT_AVAILABLE,"String_Node_Str");
  }
}