To fix it I researched Vector
that @user85421 told me about, I ended up finding the synchronizedList
class.
What I have done is modify both; the Arraylist
results
and the destination one ret
to this type.
// Old one List<InformeFacturacionAsociadoDto> ret = new ArrayList<>();
List<InformeFacturacionProcesado> results = null;
results = informeFacturacionDAO.getListInformeFactAsociadosV2(cliJurs, centros, desde, hasta, podologos, tipoPrescriptor, prescriptor, servicios, conveniosBusqueda);
//NEW CODE
List<InformeFacturacionAsociadoDto> retS = Collections.synchronizedList(new ArrayList<InformeFacturacionAsociadoDto>());
List<InformeFacturacionProcesado> resultsS = Collections.synchronizedList(results);
This way no null appears and no data is lost.