Buggy code:
@ Controller @ RequestMapping ( "//" ) public class SurveyController { @ Autowired ApplicationContext ctx ; @ Autowired SurveyService surveySvc ; @ Autowired ReportService reportSvc ; @ Autowired MailService emailSvc ; @ Autowired SurveyCalculateFactory calculationFactory ; private static final Logger logger = Logger . getLogger ( SurveyController . class ) ; @ RequestMapping ( value = { "//" , "//index.html" } , method = RequestMethod . GET ) public String home ( ModelMap model ) { } @ RequestMapping ( value = { "//templates.html" } , method = RequestMethod . GET ) public String listTemplates ( ModelMap model ) { } @ RequestMapping ( value = { "//survey_{surveyTemplateId}.html" } , method = RequestMethod . GET ) public String showSurvey ( @ PathVariable int surveyTemplateId ) { } @ RequestMapping ( value = { "//survey_{surveyTemplateId}.html" } , method = RequestMethod . POST ) public String saveSurvey ( @ PathVariable int surveyTemplateId , @ Valid SurveyForm form , @ RequestParam ( value = "preview" , required = false ) String preview , @ RequestParam ( value = "submit" , required = false ) String submit , BindingResult result , ModelMap model ) { } @ RequestMapping ( value = { "//error.html" } , method = RequestMethod . GET ) public String showError ( ModelMap model ) { } @ RequestMapping ( value = { "//submit//{surveyId}.html" } , method = RequestMethod . POST ) public String finishSurvey ( ModelMap model , @ PathVariable int surveyId ) { Survey survey = surveySvc . findSurveyWithId ( surveyId ) ; survey . setStatus ( COMPLETED . getValue ( ) ) ; surveySvc . saveSurvey ( survey ) ; <START_BUG> String reportViewPath = String . format ( "%1$s_%2$s_%3$s_%4$s.html" , "//view" , survey . getId ( ) , survey . getStorageName ( ) , PDF . getName ( ) ) ; <END_BUG> String baseUrl = ctx . getEnvironment ( ) . getProperty ( BASE_URL . getName ( ) ) ; String reportBasePath = ctx . getEnvironment ( ) . getProperty ( REPORT_OUTPUT_BASE_URL . getName ( ) ) ; String reportPath = String . format ( "%1$s%2$s%3$s%4$s%5$s.%6$s" , reportBasePath , File . separator , PDF . getName ( ) , File . separator , survey . getStorageName ( ) , PDF . getName ( ) ) ; String reportUrl = String . format ( "%1$s%2$s" , baseUrl , reportPath ) ; Map < String , String > params = new HashMap < String , String > ( ) ; params . put ( SURVEY_PDF_URL . getName ( ) , reportUrl ) ; emailSvc . sendMail ( survey , params ) ; SurveyController . logger . info ( ( "Send<seq2seq4repair_space>email<seq2seq4repair_space>for<seq2seq4repair_space>the<seq2seq4repair_space>survey<seq2seq4repair_space>" + ( survey . getId ( ) ) ) ) ; return "redirect:" + reportViewPath ; } @ SuppressWarnings ( "unchecked" ) @ RequestMapping ( value = { "//calculate_field_{surveyTemplateId}//{fieldName}.html" } , method = RequestMethod . POST ) @ ResponseBody public String calculateField ( @ PathVariable int surveyTemplateId , @ PathVariable String fieldName , @ RequestParam ( "fields['proposed-keyword']" ) MultipartFile uploadfile , @ Valid SurveyForm form ) { } }

Fix:
String reportViewPath = String . format ( "%1$s//%2$s//%3$s_%4$s.html" , "//view" , survey . getId ( ) , survey . getStorageName ( ) , PDF . getName ( ) ) ;