Program: 103791
Project: 103791
Buggy source:
/** 
 * An ok here means that our registration has been accepted or terminated (depending on the corresponding REGISTER request). We change state notify listeners and (in the case of a new registration) schedule reregistration.
 * @param clientTransatcion the ClientTransaction that we created whensending the register request.
 * @param response the OK Response that we've just received.
 */
public void processOK(ClientTransaction clientTransatcion,Response response){
  int requestedExpiration=0;
  Request register=clientTransatcion.getRequest();
  ExpiresHeader expiresHeader=register.getExpires();
  if (expiresHeader != null)   requestedExpiration=expiresHeader.getExpires();
 else {
    ContactHeader contactHeader=(ContactHeader)register.getHeader(ContactHeader.NAME);
    if (contactHeader != null)     requestedExpiration=contactHeader.getExpires();
 else     requestedExpiration=0;
  }
  int grantedExpiration=registrationsExpiration;
  expiresHeader=response.getExpires();
  if (expiresHeader != null) {
    grantedExpiration=expiresHeader.getExpires();
  }
 else {
    ContactHeader contactHeader=(ContactHeader)response.getHeader(ContactHeader.NAME);
    if (contactHeader != null) {
      grantedExpiration=contactHeader.getExpires();
    }
 else {
      grantedExpiration=requestedExpiration;
    }
  }
  if (grantedExpiration <= 0 || requestedExpiration <= 0) {
    setRegistrationState(RegistrationState.UNREGISTERED,RegistrationStateChangeEvent.REASON_USER_REQUEST,"String_Node_Str");
  }
 else {
    int scheduleTime=grantedExpiration;
    String keepAliveMethod=sipProvider.getAccountID().getAccountPropertyString(KEEP_ALIVE_METHOD);
    if ((keepAliveMethod != null && keepAliveMethod.equalsIgnoreCase("String_Node_Str")) || keepAliveMethod == null) {
      int registrationInterval=sipProvider.getAccountID().getAccountPropertyInt(KEEP_ALIVE_INTERVAL,KEEP_ALIVE_INTERVAL_DEFAULT_VALUE);
      if (registrationInterval < grantedExpiration) {
        scheduleTime=registrationInterval;
      }
    }
    scheduleReRegistration(scheduleTime);
    setRegistrationState(RegistrationState.REGISTERED,RegistrationStateChangeEvent.REASON_NOT_SPECIFIED,null);
  }
}

Fixed version (ground truth):
/** 
 * An ok here means that our registration has been accepted or terminated (depending on the corresponding REGISTER request). We change state notify listeners and (in the case of a new registration) schedule reregistration.
 * @param clientTransatcion the ClientTransaction that we created whensending the register request.
 * @param response the OK Response that we've just received.
 */
public void processOK(ClientTransaction clientTransatcion,Response response){
  int requestedExpiration=0;
  Request register=clientTransatcion.getRequest();
  ContactHeader contactHeader=(ContactHeader)register.getHeader(ContactHeader.NAME);
  if (contactHeader != null)   requestedExpiration=contactHeader.getExpires();
 else   requestedExpiration=0;
  if (requestedExpiration <= 0) {
    ExpiresHeader expiresHeader=register.getExpires();
    if (expiresHeader != null)     requestedExpiration=expiresHeader.getExpires();
  }
  int grantedExpiration=registrationsExpiration;
  expiresHeader=response.getExpires();
  if (expiresHeader != null) {
    grantedExpiration=expiresHeader.getExpires();
  }
 else {
    ContactHeader contactHeader=(ContactHeader)response.getHeader(ContactHeader.NAME);
    if (contactHeader != null) {
      grantedExpiration=contactHeader.getExpires();
    }
 else {
      grantedExpiration=requestedExpiration;
    }
  }
  if (grantedExpiration <= 0 || requestedExpiration <= 0) {
    setRegistrationState(RegistrationState.UNREGISTERED,RegistrationStateChangeEvent.REASON_USER_REQUEST,"String_Node_Str");
  }
 else {
    int scheduleTime=grantedExpiration;
    String keepAliveMethod=sipProvider.getAccountID().getAccountPropertyString(KEEP_ALIVE_METHOD);
    if ((keepAliveMethod != null && keepAliveMethod.equalsIgnoreCase("String_Node_Str")) || keepAliveMethod == null) {
      int registrationInterval=sipProvider.getAccountID().getAccountPropertyInt(KEEP_ALIVE_INTERVAL,KEEP_ALIVE_INTERVAL_DEFAULT_VALUE);
      if (registrationInterval < grantedExpiration) {
        scheduleTime=registrationInterval;
      }
    }
    scheduleReRegistration(scheduleTime);
    setRegistrationState(RegistrationState.REGISTERED,RegistrationStateChangeEvent.REASON_NOT_SPECIFIED,null);
  }
}