Program: 68988
Project: 68988
Buggy source:
@RequestMapping(value="String_Node_Str",method=POST,consumes=APPLICATION_JSON_UTF8_VALUE,produces=APPLICATION_JSON_UTF8_VALUE) public AddressResponse address(@Valid @RequestBody AddressRequest addressRequest,@RequestHeader(value="String_Node_Str") String authorizationHeader) throws BaseException {
  String emailConfirmationToken=getEmailConfirmationToken(authorizationHeader);
  Optional<Investor> oInvestor=investorRepository.findOptionalByEmailConfirmationToken(emailConfirmationToken);
  if (!oInvestor.isPresent()) {
    throw new ConfirmationTokenNotFoundException();
  }
  String walletAddress=replacePrefixAddress(addressRequest.getAddress());
  String refundEthereumAddress=replacePrefixAddress(addressRequest.getRefundETH());
  String refundBitcoinAddress=addressRequest.getRefundBTC();
  if (walletAddress.isEmpty()) {
    throw new EthereumWalletAddressEmptyException();
  }
  if (!ethereumKeyGenerator.isValidAddress(walletAddress)) {
    throw new EthereumAddressInvalidException();
  }
  if (refundEthereumAddress != null && !refundEthereumAddress.isEmpty() && !ethereumKeyGenerator.isValidAddress(refundEthereumAddress)) {
    throw new EthereumAddressInvalidException();
  }
  if (refundBitcoinAddress != null && !refundBitcoinAddress.isEmpty() && !bitcoinKeyGenerator.isValidAddress(refundBitcoinAddress)) {
    throw new BitcoinAddressInvalidException();
  }
  Keys bitcoinKeys=bitcoinKeyGenerator.getKeys();
  Keys ethereumKeys=ethereumKeyGenerator.getKeys();
  try {
    Investor investor=oInvestor.get();
    investor.setWalletAddress(addPrefixEtherIfNotExist(walletAddress)).setPayInBitcoinAddress(bitcoinKeys.getAddressAsString()).setPayInBitcoinPrivateKey(Hex.toHexString(bitcoinKeys.getPrivateKey())).setPayInEtherAddress(ethereumKeys.getAddressAsString()).setPayInEtherPrivateKey(Hex.toHexString(ethereumKeys.getPrivateKey())).setRefundBitcoinAddress(refundBitcoinAddress).setRefundEtherAddress(addPrefixEtherIfNotExist(refundEthereumAddress));
    investorRepository.save(investor);
    mailService.sendSummaryEmail(investor);
  }
 catch (  Exception e) {
    throw new UnexpectedException();
  }
  return new AddressResponse().setBtc(bitcoinKeys.getAddressAsString()).setEther(ethereumKeys.getAddressAsString());
}

Fixed version (ground truth):
@RequestMapping(value="String_Node_Str",method=POST,consumes=APPLICATION_JSON_UTF8_VALUE,produces=APPLICATION_JSON_UTF8_VALUE) public AddressResponse address(@Valid @RequestBody AddressRequest addressRequest,@Valid @Size(max=Constants.UUID_CHAR_MAX_SIZE) @RequestHeader(value="String_Node_Str") String authorizationHeader) throws BaseException {
  String emailConfirmationToken=getEmailConfirmationToken(authorizationHeader);
  Optional<Investor> oInvestor=findInvestorOrThrowException(emailConfirmationToken);
  checkIfWalletAddressIsAlreadySet(oInvestor);
  String walletAddress=replacePrefixAddress(addressRequest.getAddress());
  String refundEthereumAddress=replacePrefixAddress(addressRequest.getRefundETH());
  String refundBitcoinAddress=addressRequest.getRefundBTC();
  checkWalletAndRefundAddressesOrThrowException(walletAddress,refundEthereumAddress,refundBitcoinAddress);
  Keys bitcoinKeys=bitcoinKeyGenerator.getKeys();
  Keys ethereumKeys=ethereumKeyGenerator.getKeys();
  try {
    Investor investor=oInvestor.get();
    investor.setWalletAddress(addPrefixEtherIfNotExist(walletAddress)).setPayInBitcoinAddress(bitcoinKeys.getAddressAsString()).setPayInBitcoinPrivateKey(Hex.toHexString(bitcoinKeys.getPrivateKey())).setPayInEtherAddress(ethereumKeys.getAddressAsString()).setPayInEtherPrivateKey(Hex.toHexString(ethereumKeys.getPrivateKey())).setRefundBitcoinAddress(refundBitcoinAddress).setRefundEtherAddress(addPrefixEtherIfNotExist(refundEthereumAddress));
    investorRepository.save(investor);
    mailService.sendSummaryEmail(investor);
  }
 catch (  Exception e) {
    throw new UnexpectedException();
  }
  return new AddressResponse().setBtc(bitcoinKeys.getAddressAsString()).setEther(ethereumKeys.getAddressAsString());
}