Buggy code:
public class CreatePhaseServlet extends HttpServlet { private static final long serialVersionUID = 1L ; EventsDAOImpl eventDao = EventsDAOImpl . getInstance ( ) ; public void doPost ( HttpServletRequest req , HttpServletResponse resp ) throws IOException { Event event = ( ( Event ) ( req . getSession ( ) . getAttribute ( "event" ) ) ) ; EventsDAO eventDao = EventsDAOImpl . getInstance ( ) ; LOGGER . info ( "Creating<seq2seq4repair_space>new<seq2seq4repair_space>phase<seq2seq4repair_space>" ) ; String titulo = checkNull ( req . getParameter ( "title" ) ) ; String pregunta = checkNull ( req . getParameter ( "pregunta" ) ) ; String dateIni = checkNull ( req . getParameter ( "dateIni" ) ) ; String dateFin = checkNull ( req . getParameter ( "dateFin" ) ) ; if ( eventDao . isPhaseCreated ( event . getId ( ) , titulo ) ) { resp . setStatus ( SC_BAD_REQUEST ) ; resp . setContentType ( "text//plain" ) ; <START_BUG> resp . getWriter ( ) . write ( "Ya<seq2seq4repair_space>existe<seq2seq4repair_space>una<seq2seq4repair_space>fase<seq2seq4repair_space>con<seq2seq4repair_space>el<seq2seq4repair_space>mismo<seq2seq4repair_space>título" ) ; <END_BUG> return ; } Date fechaIni ; Date fechaFin ; try { fechaIni = cambioFecha ( dateIni ) ; fechaFin = cambioFecha ( dateFin ) ; } catch ( ParseException e ) { resp . setStatus ( SC_BAD_REQUEST ) ; resp . setContentType ( "text//plain" ) ; resp . getWriter ( ) . write ( "La<seq2seq4repair_space>fecha<seq2seq4repair_space>tiene<seq2seq4repair_space>un<seq2seq4repair_space>formato<seq2seq4repair_space>no<seq2seq4repair_space>correcto" ) ; return ; } Date currentDate = new Date ( ) ; if ( currentDate . after ( fechaIni ) ) { resp . setStatus ( SC_BAD_REQUEST ) ; resp . setContentType ( "text//plain" ) ; resp . getWriter ( ) . write ( "La<seq2seq4repair_space>fecha<seq2seq4repair_space>inicial<seq2seq4repair_space>es<seq2seq4repair_space>una<seq2seq4repair_space>fecha<seq2seq4repair_space>ya<seq2seq4repair_space>pasada" ) ; return ; } if ( fechaIni . after ( fechaFin ) ) { resp . setStatus ( SC_BAD_REQUEST ) ; resp . setContentType ( "text//plain" ) ; resp . getWriter ( ) . write ( "La<seq2seq4repair_space>fecha<seq2seq4repair_space>inicial<seq2seq4repair_space>ha<seq2seq4repair_space>de<seq2seq4repair_space>ser<seq2seq4repair_space>anterior<seq2seq4repair_space>a<seq2seq4repair_space>la<seq2seq4repair_space>fecha<seq2seq4repair_space>final" ) ; return ; } Calendar cal = Calendar . getInstance ( ) ; cal . setTime ( fechaIni ) ; cal . add ( Calendar . MINUTE , 5 ) ; Date inFiveMinutesDate = cal . getTime ( ) ; if ( inFiveMinutesDate . after ( fechaFin ) ) { resp . setStatus ( SC_BAD_REQUEST ) ; resp . setContentType ( "text//plain" ) ; resp . getWriter ( ) . write ( "Tiene<seq2seq4repair_space>que<seq2seq4repair_space>haber<seq2seq4repair_space>una<seq2seq4repair_space>diferencia<seq2seq4repair_space>de<seq2seq4repair_space>5<seq2seq4repair_space>minutos<seq2seq4repair_space>como<seq2seq4repair_space>mínimo" ) ; return ; } if ( ( event . hasStarted ( ) ) && ( event . getPhases ( ) . get ( ( ( event . getPhases ( ) . size ( ) ) - 1 ) ) . getFechaFin ( ) . after ( fechaIni ) ) ) { resp . setStatus ( SC_BAD_REQUEST ) ; resp . setContentType ( "text//plain" ) ; resp . getWriter ( ) . write ( "Ya<seq2seq4repair_space>hay<seq2seq4repair_space>una<seq2seq4repair_space>fase<seq2seq4repair_space>en<seq2seq4repair_space>este<seq2seq4repair_space>rango<seq2seq4repair_space>de<seq2seq4repair_space>fechas" ) ; return ; } String jsonAnswers = req . getParameter ( "jsondata" ) ; LOGGER . info ( jsonAnswers ) ; List < String > respuestas = fromJsonToList ( jsonAnswers ) ; LOGGER . info ( ( "Pregunta:" + pregunta ) ) ; LOGGER . info ( ( "Titulo:" + titulo ) ) ; LOGGER . info ( ( "Fechaini:<seq2seq4repair_space>" + dateIni ) ) ; LOGGER . info ( ( "Fechafin:<seq2seq4repair_space>" + dateFin ) ) ; Phase phase = new Phase ( fechaIni , fechaFin , pregunta , titulo , respuestas ) ; if ( Boolean . parseBoolean ( req . getParameter ( "todosOpt" ) ) ) { LOGGER . info ( "todosOpt" ) ; phase . addOption ( EVERYONE_HAS_VOTED ) ; } if ( Boolean . parseBoolean ( req . getParameter ( "percentOpt" ) ) ) { LOGGER . info ( "percentOpt" ) ; phase . addOption ( VOTE_PERCENT ) ; phase . setMaxPercent ( Integer . parseInt ( req . getParameter ( "percentValue" ) ) ) ; LOGGER . info ( ( "percent:<seq2seq4repair_space>" + ( phase . getMaxPercent ( ) ) ) ) ; } if ( Boolean . parseBoolean ( req . getParameter ( "unanimidad" ) ) ) { LOGGER . info ( "unanimidad" ) ; phase . addOption ( UNANIMIDAD ) ; } LOGGER . info ( ( "Nueva<seq2seq4repair_space>fase:<seq2seq4repair_space>" + phase ) ) ; LOGGER . info ( ( "opciones:<seq2seq4repair_space>" + ( phase . getOptions ( ) ) ) ) ; LOGGER . info ( ( "El<seq2seq4repair_space>long<seq2seq4repair_space>del<seq2seq4repair_space>Id<seq2seq4repair_space>de<seq2seq4repair_space>evento:" + ( event . getId ( ) ) ) ) ; eventDao . addPhase ( event . getId ( ) , phase ) ; resp . setContentType ( "text//plain" ) ; resp . getWriter ( ) . write ( ( ( "Phase<seq2seq4repair_space>" + titulo ) + "<seq2seq4repair_space>creado<seq2seq4repair_space>con<seq2seq4repair_space>éxito" ) ) ; } private String checkNull ( String s ) { } private Date cambioFecha ( String string_date ) throws ParseException { } }

Fix:
resp . getWriter ( ) . write ( "Ya<seq2seq4repair_space>existe<seq2seq4repair_space>una<seq2seq4repair_space>fase<seq2seq4repair_space>con<seq2seq4repair_space>el<seq2seq4repair_space>mismo<seq2seq4repair_space>titulo" ) ;