Program: 103874
Project: 103874
Buggy source:
/** 
 * Indicates a user request to answer an incoming call from this <tt>CallPeer</tt>. Sends an OK response to <tt>callPeer</tt>. Make sure that the call peer contains an SDP description when you call this method.
 * @throws OperationFailedException if we fail to create or send theresponse.
 */
public synchronized void answer() throws OperationFailedException {
  Transaction transaction=getLatestInviteTransaction();
  if (transaction == null || !(transaction instanceof ServerTransaction)) {
    setState(CallPeerState.DISCONNECTED);
    throw new OperationFailedException("String_Node_Str" + "String_Node_Str",OperationFailedException.INTERNAL_ERROR);
  }
  CallPeerState peerState=getState();
  if (peerState.equals(CallPeerState.CONNECTED) || CallPeerState.isOnHold(peerState)) {
    logger.info("String_Node_Str" + "String_Node_Str");
    return;
  }
  ServerTransaction serverTransaction=(ServerTransaction)transaction;
  Response ok=null;
  try {
    ok=messageFactory.createResponse(Response.OK,serverTransaction.getRequest());
  }
 catch (  ParseException ex) {
    setState(CallPeerState.DISCONNECTED);
    ProtocolProviderServiceSipImpl.throwOperationFailedException("String_Node_Str",OperationFailedException.INTERNAL_ERROR,ex,logger);
  }
  ContentTypeHeader contentTypeHeader=null;
  try {
    contentTypeHeader=getProtocolProvider().getHeaderFactory().createContentTypeHeader("String_Node_Str","String_Node_Str");
  }
 catch (  ParseException ex) {
    setState(CallPeerState.DISCONNECTED);
    ProtocolProviderServiceSipImpl.throwOperationFailedException("String_Node_Str",OperationFailedException.INTERNAL_ERROR,ex,logger);
  }
  try {
    String sdpOffer=getSdpDescription();
    String sdp;
    if ((sdpOffer != null) && (sdpOffer.length() > 0)) {
      sdp=getMediaHandler().processFirstOffer(SdpUtils.parseSdpString(sdpOffer)).toString();
    }
 else {
      sdp=getMediaHandler().createOffer();
    }
    ok.setContent(sdp,contentTypeHeader);
  }
 catch (  Exception ex) {
    logger.error("String_Node_Str" + "String_Node_Str",ex);
    getProtocolProvider().sayError(serverTransaction,Response.NOT_ACCEPTABLE_HERE);
  }
  try {
    serverTransaction.sendResponse(ok);
    if (logger.isDebugEnabled())     logger.debug("String_Node_Str" + ok);
  }
 catch (  Exception ex) {
    setState(CallPeerState.DISCONNECTED);
    ProtocolProviderServiceSipImpl.throwOperationFailedException("String_Node_Str",OperationFailedException.NETWORK_FAILURE,ex,logger);
  }
}

Fixed version (ground truth):
/** 
 * Indicates a user request to answer an incoming call from this <tt>CallPeer</tt>. Sends an OK response to <tt>callPeer</tt>. Make sure that the call peer contains an SDP description when you call this method.
 * @throws OperationFailedException if we fail to create or send theresponse.
 */
public synchronized void answer() throws OperationFailedException {
  Transaction transaction=getLatestInviteTransaction();
  if (transaction == null || !(transaction instanceof ServerTransaction)) {
    setState(CallPeerState.DISCONNECTED);
    throw new OperationFailedException("String_Node_Str" + "String_Node_Str",OperationFailedException.INTERNAL_ERROR);
  }
  CallPeerState peerState=getState();
  if (peerState.equals(CallPeerState.CONNECTED) || CallPeerState.isOnHold(peerState)) {
    logger.info("String_Node_Str" + "String_Node_Str");
    return;
  }
  ServerTransaction serverTransaction=(ServerTransaction)transaction;
  Response ok=null;
  try {
    ok=messageFactory.createResponse(Response.OK,serverTransaction.getRequest());
  }
 catch (  ParseException ex) {
    setState(CallPeerState.DISCONNECTED);
    ProtocolProviderServiceSipImpl.throwOperationFailedException("String_Node_Str",OperationFailedException.INTERNAL_ERROR,ex,logger);
  }
  ContentTypeHeader contentTypeHeader=null;
  try {
    contentTypeHeader=getProtocolProvider().getHeaderFactory().createContentTypeHeader("String_Node_Str","String_Node_Str");
  }
 catch (  ParseException ex) {
    setState(CallPeerState.DISCONNECTED);
    ProtocolProviderServiceSipImpl.throwOperationFailedException("String_Node_Str",OperationFailedException.INTERNAL_ERROR,ex,logger);
  }
  try {
    String sdpOffer=null;
    Request invite=getLatestInviteTransaction().getRequest();
    ContentLengthHeader cl=invite.getContentLength();
    if (cl != null && cl.getContentLength() > 0) {
      sdpOffer=new String(invite.getRawContent());
    }
    ;
    String sdp;
    if ((sdpOffer != null) && (sdpOffer.length() > 0)) {
      sdp=getMediaHandler().processFirstOffer(SdpUtils.parseSdpString(sdpOffer)).toString();
    }
 else {
      sdp=getMediaHandler().createOffer();
    }
    ok.setContent(sdp,contentTypeHeader);
  }
 catch (  Exception ex) {
    logger.error("String_Node_Str" + "String_Node_Str",ex);
    getProtocolProvider().sayError(serverTransaction,Response.NOT_ACCEPTABLE_HERE);
  }
  try {
    serverTransaction.sendResponse(ok);
    if (logger.isDebugEnabled())     logger.debug("String_Node_Str" + ok);
  }
 catch (  Exception ex) {
    setState(CallPeerState.DISCONNECTED);
    ProtocolProviderServiceSipImpl.throwOperationFailedException("String_Node_Str",OperationFailedException.NETWORK_FAILURE,ex,logger);
  }
}