Buggy code:
public class CatracaController { private static final String ATIVO ; private static final String ALUNO ; private static final String horaEntrada ; private static final String horaSaida ; private PlasticoDao plasticoDao ; private PessoaDao pessoaDao ; private AlunoDao alunoDao ; private EventoDao eventoDao ; static Logger logger = Logger . getLogger ( CatracaController . class ) ; public CatracaController ( ) { } public HashMap < String , Object > novoEvento ( String linhaDigitavel ) { CatracaController . logger . info ( "*****Criando<seq2seq4repair_space>novo<seq2seq4repair_space>evento<seq2seq4repair_space>...******" ) ; HashMap < String , Object > retorno = new HashMap < String , Object > ( ) ; if ( ( linhaDigitavel . equals ( "" ) ) || ( linhaDigitavel == null ) ) { retorno . put ( "mensagem" , "Leitura<seq2seq4repair_space>falhou,<seq2seq4repair_space>tente<seq2seq4repair_space>novamente<seq2seq4repair_space>ou<seq2seq4repair_space>entre<seq2seq4repair_space>em<seq2seq4repair_space>contato<seq2seq4repair_space>com<seq2seq4repair_space>a<seq2seq4repair_space>Equipe<seq2seq4repair_space>do<seq2seq4repair_space>Futuro-Alternativo." ) ; CatracaController . logger . error ( retorno . get ( "mensagem" ) ) ; } else { try { CatracaController . logger . info ( "Buscando<seq2seq4repair_space>Cartão..." ) ; Plastico plastico = consultarPlastico ( linhaDigitavel ) ; if ( ( plastico != null ) && ( plastico . getStatus ( ) . equals ( CatracaController . ATIVO ) ) ) { CatracaController . logger . info ( "Cartão<seq2seq4repair_space>encontrado!" ) ; Pessoa pessoa = plastico . getPessoa ( ) ; if ( ( ( pessoa != null ) && ( pessoa . getTipopessoa ( ) . equals ( CatracaController . ALUNO ) ) ) && ( alunoAtivo ( pessoa . getId ( ) ) ) ) { CatracaController . logger . info ( "Pessoa<seq2seq4repair_space>Existe<seq2seq4repair_space>e<seq2seq4repair_space>é<seq2seq4repair_space>um<seq2seq4repair_space>aluno<seq2seq4repair_space>ativo" ) ; CatracaController . logger . info ( "Buscando<seq2seq4repair_space>Eventos<seq2seq4repair_space>..." ) ; List < Evento > eventos = consultarEventosEntrada ( pessoa . getId ( ) ) ; if ( eventos . isEmpty ( ) ) { CatracaController . logger . info ( "Não<seq2seq4repair_space>hã<seq2seq4repair_space>eventos<seq2seq4repair_space>para<seq2seq4repair_space>o<seq2seq4repair_space>dia.<seq2seq4repair_space>Registrando<seq2seq4repair_space>nova<seq2seq4repair_space>entrada..." ) ; Date now = new Date ( ) ; CatracaController . logger . info ( "Validando<seq2seq4repair_space>horário<seq2seq4repair_space>de<seq2seq4repair_space>entrada<seq2seq4repair_space>para<seq2seq4repair_space>criar<seq2seq4repair_space>status<seq2seq4repair_space>do<seq2seq4repair_space>Evento." ) ; String status = comparaEntrada ( now ) ; CatracaController . logger . info ( ( "Status<seq2seq4repair_space>=<seq2seq4repair_space>" + status ) ) ; Evento evento = new Evento ( now , null , status , pessoa ) ; CatracaController . logger . info ( "Salvando<seq2seq4repair_space>novo<seq2seq4repair_space>envento<seq2seq4repair_space>entrada" ) ; eventoDao . save ( evento ) ; CatracaController . logger . info ( "Evento<seq2seq4repair_space>criado<seq2seq4repair_space>com<seq2seq4repair_space>sucesso..." ) ; String mensagem = info ( pessoa , evento , "ENTRADA" ) ; retorno . put ( "mensagem" , mensagem ) ; CatracaController . logger . info ( mensagem ) ; } else { Evento evento ; if ( ( eventos . size ( ) ) > 1 ) { <START_BUG> evento = eventos . get ( eventos . size ( ) ) ; <END_BUG> CatracaController . logger . info ( "Existe<seq2seq4repair_space>mais<seq2seq4repair_space>de<seq2seq4repair_space>1<seq2seq4repair_space>evento<seq2seq4repair_space>para<seq2seq4repair_space>este<seq2seq4repair_space>cartão<seq2seq4repair_space>no<seq2seq4repair_space>dia<seq2seq4repair_space>de<seq2seq4repair_space>hoje,<seq2seq4repair_space>apenas<seq2seq4repair_space>o<seq2seq4repair_space>evento<seq2seq4repair_space>mais<seq2seq4repair_space>recente<seq2seq4repair_space>será<seq2seq4repair_space>atualizado" ) ; } else { evento = eventos . get ( 0 ) ; } Date now = new Date ( ) ; CatracaController . logger . info ( "Validando<seq2seq4repair_space>horário<seq2seq4repair_space>de<seq2seq4repair_space>Saída<seq2seq4repair_space>para<seq2seq4repair_space>criar<seq2seq4repair_space>status<seq2seq4repair_space>do<seq2seq4repair_space>Evento." ) ; String status = comparaSaida ( now ) ; CatracaController . logger . info ( ( "Status<seq2seq4repair_space>=<seq2seq4repair_space>" + status ) ) ; evento . setDatahorasaida ( now ) ; evento . setStatus ( status ) ; CatracaController . logger . info ( "Salvando<seq2seq4repair_space>novo<seq2seq4repair_space>envento<seq2seq4repair_space>saída" ) ; eventoDao . update ( evento ) ; String mensagem = info ( pessoa , evento , "SAIDA" ) ; retorno . put ( "mensagem" , mensagem ) ; CatracaController . logger . info ( mensagem ) ; } } } else { retorno . put ( "mensagem" , ( ( ( Object ) ( "Número<seq2seq4repair_space>de<seq2seq4repair_space>cartão<seq2seq4repair_space>não<seq2seq4repair_space>encontrado<seq2seq4repair_space>na<seq2seq4repair_space>base<seq2seq4repair_space>de<seq2seq4repair_space>dados," ) ) + "<seq2seq4repair_space>tente<seq2seq4repair_space>novamente<seq2seq4repair_space>ou<seq2seq4repair_space>entre<seq2seq4repair_space>em<seq2seq4repair_space>contato<seq2seq4repair_space>com<seq2seq4repair_space>a<seq2seq4repair_space>Equipe<seq2seq4repair_space>do<seq2seq4repair_space>Futuro-Alternativo." ) ) ; } } catch ( Exception e ) { e . printStackTrace ( ) ; retorno . put ( "mensagem" , ( "Houve<seq2seq4repair_space>um<seq2seq4repair_space>erro<seq2seq4repair_space>ao<seq2seq4repair_space>registradar<seq2seq4repair_space>as<seq2seq4repair_space>informações" + "<seq2seq4repair_space>tente<seq2seq4repair_space>novamente<seq2seq4repair_space>ou<seq2seq4repair_space>entre<seq2seq4repair_space>em<seq2seq4repair_space>contato<seq2seq4repair_space>com<seq2seq4repair_space>a<seq2seq4repair_space>Equipe<seq2seq4repair_space>do<seq2seq4repair_space>Futuro-Alternativo." ) ) ; System . err . println ( retorno . get ( "mensagem" ) ) ; } } return retorno ; } private String info ( Pessoa pessoa , Evento evento , String tipoMsg ) { } private Plastico consultarPlastico ( String linhaDigitavel ) { } private boolean alunoAtivo ( Long pessoaId ) { } private List < Evento > consultarEventosEntrada ( Long pessoaId ) { } private String comparaEntrada ( Date now ) throws ParseException { } private String comparaSaida ( Date now ) throws ParseException { } public PlasticoDao getPlasticoDao ( ) { } public void setPlasticoDao ( PlasticoDao plasticoDao ) { } public PessoaDao getPessoaDao ( ) { } public void setPessoaDao ( PessoaDao pessoaDao ) { } public AlunoDao getAlunoDao ( ) { } public void setAlunoDao ( AlunoDao alunoDao ) { } }

Fix:
evento = eventos . get ( ( ( eventos . size ( ) ) - 1 ) ) ;