Program: 69947
Project: 69947
Buggy source:
/** 
 * Create a session code with a one hour expiration date
 * @param identity
 * @param booking
 * @return
 */
protected String createPersonalBookingSessionCode(Identity identity,ViteroBooking booking) throws VmsNotAvailableException {
  try {
    int userId=getVmsUserId(identity,true);
    try {
      updateVmsUser(identity,userId);
      storePortrait(identity,userId);
    }
 catch (    Exception e) {
      logError("String_Node_Str" + identity.getName(),e);
    }
    SessionCodeServiceStub sessionCodeWs=getSessionCodeWebService();
    SessionCodeServiceStub.CreatePersonalBookingSessionCodeRequest codeRequest=new SessionCodeServiceStub.CreatePersonalBookingSessionCodeRequest();
    SessionCodeServiceStub.Sessioncode_type2 code=new SessionCodeServiceStub.Sessioncode_type2();
    code.setBookingid(booking.getBookingId());
    code.setUserid(userId);
    code.setTimezone(viteroModule.getTimeZoneId());
    Calendar cal=Calendar.getInstance();
    cal.setTime(new Date());
    cal.add(Calendar.HOUR,1);
    code.setExpirationdate(format(cal.getTime()));
    codeRequest.setSessioncode(code);
    SessionCodeServiceStub.CreatePersonalBookingSessionCodeResponse response=sessionCodeWs.createPersonalBookingSessionCode(codeRequest);
    Codetype myCode=response.getCreatePersonalBookingSessionCodeResponse();
    return myCode.getCode();
  }
 catch (  AxisFault f) {
    ErrorCode code=handleAxisFault(f);
switch (code) {
case userDoesntExist:
      logError("String_Node_Str",f);
    break;
case userNotAssignedToGroup:
  logError("String_Node_Str",f);
break;
case invalidAttribut:
logError("String_Node_Str",f);
break;
case invalidTimezone:
logError("String_Node_Str",f);
break;
case bookingDoesntExist:
case bookingDoesntExistPrime:
logError("String_Node_Str",f);
break;
default :
logAxisError("String_Node_Str",f);
}
return null;
}
catch (RemoteException e) {
logError("String_Node_Str",e);
return null;
}
}

Fixed version (ground truth):
/** 
 * Create a session code with a one hour expiration date
 * @param identity
 * @param booking
 * @return
 */
protected String createPersonalBookingSessionCode(Identity identity,ViteroBooking booking) throws VmsNotAvailableException {
  try {
    GetUserInfo userInfo=getVmsUserId(identity,true);
    int userId=userInfo.getUserId();
    if (!userInfo.isCreated()) {
      try {
        updateVmsUser(identity,userId);
        storePortrait(identity,userId);
      }
 catch (      Exception e) {
        logError("String_Node_Str" + identity.getName(),e);
      }
    }
    SessionCodeServiceStub sessionCodeWs=getSessionCodeWebService();
    SessionCodeServiceStub.CreatePersonalBookingSessionCodeRequest codeRequest=new SessionCodeServiceStub.CreatePersonalBookingSessionCodeRequest();
    SessionCodeServiceStub.Sessioncode_type2 code=new SessionCodeServiceStub.Sessioncode_type2();
    code.setBookingid(booking.getBookingId());
    code.setUserid(userId);
    code.setTimezone(viteroModule.getTimeZoneId());
    Calendar cal=Calendar.getInstance();
    cal.setTime(new Date());
    cal.add(Calendar.HOUR,1);
    code.setExpirationdate(format(cal.getTime()));
    codeRequest.setSessioncode(code);
    SessionCodeServiceStub.CreatePersonalBookingSessionCodeResponse response=sessionCodeWs.createPersonalBookingSessionCode(codeRequest);
    Codetype myCode=response.getCreatePersonalBookingSessionCodeResponse();
    return myCode.getCode();
  }
 catch (  AxisFault f) {
    ErrorCode code=handleAxisFault(f);
switch (code) {
case userDoesntExist:
      logError("String_Node_Str",f);
    break;
case userNotAssignedToGroup:
  logError("String_Node_Str",f);
break;
case invalidAttribut:
logError("String_Node_Str",f);
break;
case invalidTimezone:
logError("String_Node_Str",f);
break;
case bookingDoesntExist:
case bookingDoesntExistPrime:
logError("String_Node_Str",f);
break;
default :
logAxisError("String_Node_Str",f);
}
return null;
}
catch (RemoteException e) {
logError("String_Node_Str",e);
return null;
}
}