Buggy code:
public class SendEmailController extends SMITravelController { private static final Logger LOG = Logger . getLogger ( SendEmailController . class . getName ( ) ) ; private static final String InvoiceReport = "Invoice" ; private static final String ReceiptEmail = "ReceiptEmail" ; private static final String TaxInvoiceEmail = "TaxInvoiceEmail" ; private static final String CreditNote = "CreditNote" ; private ModelAndView ModelMail = new ModelAndView ( "SendMail" ) ; private static final String ReportName = "reportname" ; private static final String ReportID = "reportid" ; private static final String BANKID = "bankid" ; private static final String SHOWSTAFF = "showstaff" ; private static final String SHOWLEADER = "showleader" ; private static final String OPTIONSENDMAIL = "optionsend" ; private static final String RECIPIENT = "recipient" ; private static final String SENDCC = "sendCc" ; private static final String SUBJECT = "subject" ; private static final String MESSAGE = "message" ; private static final String SIGN = "sign" ; private JavaMailSender mailSender ; private ReportService reportservice ; private DataSource datasource ; private Mail sendMail ; private static final String TransectionResult = "result" ; @ Override protected ModelAndView process ( HttpServletRequest request , HttpServletResponse response , HttpSession session ) { String recipientAddress = request . getParameter ( "recipient" ) ; String subject = request . getParameter ( "subject" ) ; String message = request . getParameter ( "message" ) ; String cc = request . getParameter ( "sendCc" ) ; String name = request . getParameter ( "reportname" ) ; String reportid = request . getParameter ( "reportid" ) ; String bankid = request . getParameter ( "bankid" ) ; String showstaff = request . getParameter ( "showstaff" ) ; String showleader = request . getParameter ( "showleader" ) ; String reportFile = request . getParameter ( "file" ) ; String sign = request . getParameter ( "sign" ) ; String jasperFileName = "" ; String pdfFileName = "" ; String optionsend = request . getParameter ( "optionsend" ) ; int option = Integer . parseInt ( ( ( optionsend == null ) || ( "" . equalsIgnoreCase ( optionsend ) ) ? "0" : optionsend ) ) ; System . out . println ( ( "To:<seq2seq4repair_space>" + recipientAddress ) ) ; System . out . println ( ( "Subject:<seq2seq4repair_space>" + subject ) ) ; System . out . println ( ( "Message:<seq2seq4repair_space>" + message ) ) ; String result = "" ; List data = new ArrayList ( ) ; String pathAttachfile = "" ; SystemUser user = ( ( SystemUser ) ( session . getAttribute ( "USER" ) ) ) ; String username = user . getUsername ( ) ; String [ ] path = reportservice . getPartReport ( ) ; if ( cc == null ) { cc = user . getEmail ( ) ; } if ( ( recipientAddress != null ) && ( ! ( "" . equalsIgnoreCase ( recipientAddress ) ) ) ) { if ( SendEmailController . InvoiceReport . equalsIgnoreCase ( name ) ) { <START_BUG> data = reportservice . getInvoice ( reportid , bankid , showstaff , showleader , sign ) ; <END_BUG> JRDataSource dataSource = new JRBeanCollectionDataSource ( data ) ; jasperFileName = "InvoiceEmail.jasper" ; pdfFileName = "invoice.pdf" ; pathAttachfile = ( ( path [ 0 ] ) + "\\" ) + username ; System . out . println ( ( ( "path<seq2seq4repair_space>:<seq2seq4repair_space>" + ( path [ 0 ] ) ) + username ) ) ; if ( checkDirectory ( ( ( path [ 0 ] ) + username ) ) ) { result = reportservice . printreport ( jasperFileName , ( ( username + "\\" ) + pdfFileName ) , dataSource ) ; } } if ( SendEmailController . ReceiptEmail . equalsIgnoreCase ( name ) ) { data = reportservice . getReceiptEmail ( reportid , option ) ; JRDataSource dataSource = new JRBeanCollectionDataSource ( data ) ; jasperFileName = "ReceiptEmail.jasper" ; pdfFileName = "receipt.pdf" ; pathAttachfile = ( ( path [ 0 ] ) + "\\" ) + username ; System . out . println ( ( ( "path<seq2seq4repair_space>:<seq2seq4repair_space>" + ( path [ 0 ] ) ) + username ) ) ; if ( checkDirectory ( ( ( path [ 0 ] ) + username ) ) ) { result = reportservice . printreport ( jasperFileName , ( ( username + "\\" ) + pdfFileName ) , dataSource ) ; } } if ( SendEmailController . TaxInvoiceEmail . equalsIgnoreCase ( name ) ) { data = reportservice . getTaxInvoiceEmail ( reportid , option ) ; JRDataSource dataSource = new JRBeanCollectionDataSource ( data ) ; jasperFileName = "TaxInvoiceEmailReport.jasper" ; pdfFileName = "taxinvoice.pdf" ; pathAttachfile = ( ( path [ 0 ] ) + "\\" ) + username ; System . out . println ( ( ( "path<seq2seq4repair_space>:<seq2seq4repair_space>" + ( path [ 0 ] ) ) + username ) ) ; if ( checkDirectory ( ( ( path [ 0 ] ) + username ) ) ) { result = reportservice . printreport ( jasperFileName , ( ( username + "\\" ) + pdfFileName ) , dataSource ) ; } } if ( SendEmailController . CreditNote . equalsIgnoreCase ( name ) ) { data = reportservice . getCreditNoteReport ( reportid ) ; JRDataSource dataSource = new JRBeanCollectionDataSource ( data ) ; jasperFileName = "CreditNote.jasper" ; pdfFileName = "creditnote.pdf" ; pathAttachfile = ( ( path [ 0 ] ) + "\\" ) + username ; System . out . println ( ( ( "path<seq2seq4repair_space>:<seq2seq4repair_space>" + ( path [ 0 ] ) ) + username ) ) ; if ( checkDirectory ( ( ( path [ 0 ] ) + username ) ) ) { result = reportservice . printreport ( jasperFileName , ( ( username + "\\" ) + pdfFileName ) , dataSource ) ; } } } System . out . println ( ( "result<seq2seq4repair_space>:<seq2seq4repair_space>" + result ) ) ;

Fix:
data = reportservice . getInvoice ( reportid , bankid , showstaff , showleader , sign , user . getName ( ) ) ;