Program: 25681
Project: 25681
Buggy source:
private void sendPasswordResetRelatedEmail(Study study,String email,boolean includeEmailSignIn,EmailTemplate template){
  String sptoken=getNextToken();
  CacheKey cacheKey=CacheKeys.passwordResetForEmail(sptoken,study.getIdentifier());
  cacheProvider.setObject(cacheKey,email,VERIFY_OR_RESET_EXPIRE_IN_SECONDS);
  String url=getResetPasswordURL(study,sptoken);
  String shortUrl=getShortResetPasswordURL(study,sptoken);
  BasicEmailProvider.Builder builder=new BasicEmailProvider.Builder().withStudy(study).withEmailTemplate(template).withRecipientEmail(email).withToken(SPTOKEN_KEY,sptoken).withToken(OLD_URL_KEY,url).withToken(OLD_SHORT_URL_KEY,shortUrl).withToken(OLD_EXP_WINDOW_TOKEN,Integer.toString(VERIFY_OR_RESET_EXPIRE_IN_SECONDS / 60 / 60)).withExpirationPeriod(OLD_EXPIRATION_PERIOD,VERIFY_OR_RESET_EXPIRE_IN_SECONDS).withToken(RESET_PASSWORD_URL_KEY,shortUrl).withExpirationPeriod(RESET_PASSWORD_EXPIRATION_PERIOD,VERIFY_OR_RESET_EXPIRE_IN_SECONDS);
  if (includeEmailSignIn && study.isEmailSignInEnabled()) {
    SignIn signIn=new SignIn.Builder().withEmail(email).withStudy(study.getIdentifier()).build();
    requestChannelSignIn(EMAIL,EMAIL_SIGNIN_REQUEST,EMAIL_CACHE_KEY_FUNC,emailSignInRequestInMillis,signIn,false,this::getNextToken,(theStudy,token) -> {
      String emailShortUrl=getShortEmailSignInURL(signIn.getEmail(),theStudy.getIdentifier(),token);
      builder.withToken(EMAIL_KEY,BridgeUtils.encodeURIComponent(signIn.getEmail()));
      builder.withToken(TOKEN_KEY,token);
      builder.withToken(OLD_SHORT_URL_KEY,emailShortUrl);
      builder.withToken(EMAIL_SIGNIN_URL_KEY,emailShortUrl);
      builder.withExpirationPeriod(EMAIL_SIGNIN_EXPIRATION_PERIOD,SIGNIN_EXPIRE_IN_SECONDS);
    }
);
  }
  sendMailService.sendEmail(builder.build());
}

Fixed version (ground truth):
private void sendPasswordResetRelatedEmail(Study study,String email,boolean includeEmailSignIn,EmailTemplate template){
  String sptoken=getNextToken();
  CacheKey cacheKey=CacheKeys.passwordResetForEmail(sptoken,study.getIdentifier());
  cacheProvider.setObject(cacheKey,email,VERIFY_OR_RESET_EXPIRE_IN_SECONDS);
  String url=getResetPasswordURL(study,sptoken);
  String shortUrl=getShortResetPasswordURL(study,sptoken);
  BasicEmailProvider.Builder builder=new BasicEmailProvider.Builder().withStudy(study).withEmailTemplate(template).withRecipientEmail(email).withToken(SPTOKEN_KEY,sptoken).withToken(OLD_URL_KEY,url).withToken(OLD_SHORT_URL_KEY,shortUrl).withToken(OLD_EXP_WINDOW_TOKEN,Integer.toString(VERIFY_OR_RESET_EXPIRE_IN_SECONDS / 60 / 60)).withExpirationPeriod(OLD_EXPIRATION_PERIOD,VERIFY_OR_RESET_EXPIRE_IN_SECONDS).withToken(RESET_PASSWORD_URL_KEY,shortUrl).withExpirationPeriod(RESET_PASSWORD_EXPIRATION_PERIOD,VERIFY_OR_RESET_EXPIRE_IN_SECONDS);
  if (includeEmailSignIn && study.isEmailSignInEnabled()) {
    SignIn signIn=new SignIn.Builder().withEmail(email).withStudy(study.getIdentifier()).build();
    requestChannelSignIn(EMAIL,EMAIL_SIGNIN_REQUEST,emailSignInRequestInMillis,signIn,false,this::getNextToken,(theStudy,token) -> {
      String emailShortUrl=getShortEmailSignInURL(signIn.getEmail(),theStudy.getIdentifier(),token);
      builder.withToken(EMAIL_KEY,BridgeUtils.encodeURIComponent(signIn.getEmail()));
      builder.withToken(TOKEN_KEY,token);
      builder.withToken(OLD_SHORT_URL_KEY,emailShortUrl);
      builder.withToken(EMAIL_SIGNIN_URL_KEY,emailShortUrl);
      builder.withExpirationPeriod(EMAIL_SIGNIN_EXPIRATION_PERIOD,SIGNIN_EXPIRE_IN_SECONDS);
    }
);
  }
  sendMailService.sendEmail(builder.build());
}