bug #9606
closedNullPointerExceptions (NPEs) in OccurrenceServiceImpl
100%
Description
see taxon, taxonBase and name in these methods
- OccurrenceServiceImpl.countByTitle(IIdentifiableEntityServiceConfigurator config)
- OccurrenceServiceImpl.findByTitleUuidAndTitleCache(FindOccurrencesConfigurator config)
- OccurrenceServiceImpl.findByTitleDerivedUnitDTO(FindOccurrencesConfigurator config)
Maybe more methods are affecetd
Updated by Andreas Müller over 2 years ago
- Category changed from cdm to cdmlib
- Status changed from New to Feedback
- Assignee changed from Andreas Müller to Andreas Kohlbecker
- Priority changed from New to Highest
- Target version changed from Unassigned CDM tickets to Release 5.25
Can you give a bit more inside. Any stacktrace available for the NPE?
What exactly is about taxon, taxonbase and name in this methods?
Updated by Andreas Kohlbecker over 2 years ago
in these lines of countByTitle() it is obvious:
TaxonBase<?> taxonBase = taxonService.load(occurrenceConfig.getAssociatedTaxonUuid());
if(taxonBase.isInstanceOf(Taxon.class)){
taxon = HibernateProxyHelper.deproxy(taxonBase, Taxon.class);
}
in the other methods there are things like
if(config.getAssociatedTaxonNameUuid()!=null){
taxonName = nameService.load(config.getAssociatedTaxonNameUuid());
}
occurrences.addAll(dao.findOccurrencesUuidAndTitleCache(config.getClazz(),
config.getTitleSearchString(), config.getSignificantIdentifier(),
config.getSpecimenType(), taxon, taxonName, config.getMatchMode(), null, null,
config.getOrderHints()));
taxonName may be null but is passed to another method, this needs to be checked
Updated by Andreas Kohlbecker over 2 years ago
- Assignee changed from Andreas Kohlbecker to Andreas Müller
Updated by Andreas Müller over 2 years ago
- Assignee changed from Andreas Müller to Andreas Kohlbecker
But it is not forbidden to pass a null value, and if you follow the method that is called, there you have null values handled correctly:
createFindOccurrenceCriteria(...) ... if(associatedTaxon!=null){ ... else if(associatedTaxonName!=null){ ...
So I really do not understand what exactly the problem.
Did you get an NPE (if yes, is there a stacktrace?) or a HQL Query not working (if yes, which one) or something else (if yes what)?
Updated by Andreas Müller over 2 years ago
Andreas Kohlbecker wrote:
in these lines of countByTitle() it is obvious:
TaxonBase<?> taxonBase = taxonService.load(occurrenceConfig.getAssociatedTaxonUuid()); if(taxonBase.isInstanceOf(Taxon.class)){ taxon = HibernateProxyHelper.deproxy(taxonBase, Taxon.class); }
this one I fixed
Updated by Andreas Kohlbecker over 2 years ago
as said there definitely an NPE in this code line from above
taxonBase.isInstanceOf(Taxon.class)){
The others should be checked as it is suspect, I did not dig deeper as I had no time for it. You ched it now - good, so we can forget about this part and concentrate on the obvious NPE - seems to be fixed now !
Updated by Andreas Kohlbecker over 2 years ago
- Status changed from Feedback to In Progress
- Assignee changed from Andreas Kohlbecker to Andreas Müller
Updated by Andreas Müller over 2 years ago
- Status changed from In Progress to Resolved
- Assignee changed from Andreas Müller to Andreas Kohlbecker
- % Done changed from 0 to 50
please review
Updated by Andreas Müller over 2 years ago
Ahh, correct, there were also the other methods. I corrected the 3rd one now so everything should be correct now. Can we close the ticket?
Updated by Andreas Kohlbecker over 2 years ago
- Status changed from Resolved to Closed
- % Done changed from 50 to 100
yes
Updated by Andreas Müller over 2 years ago
- Target version changed from Release 5.25 to Release 5.23