Project

General

Profile

bug #9606

NullPointerExceptions (NPEs) in OccurrenceServiceImpl

Added by Andreas Kohlbecker 6 months ago. Updated 5 months ago.

Status:
Closed
Priority:
Highest
Category:
cdmlib
Target version:
Start date:
05/04/2021
Due date:
% Done:

100%

Severity:
normal
Found in Version:

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

Associated revisions

Revision d9a9f2b1 (diff)
Added by Andreas Müller 6 months ago

ref #9606 fix potential NPE

Revision 97fc0f95 (diff)
Added by Andreas Kohlbecker 6 months ago

ref #9606 fix another potential NPE

Revision 5f196d28 (diff)
Added by Andreas Müller 6 months ago

ref #9606 fixing also the 3rd potential NPE

History

#1 Updated by Andreas Müller 6 months 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?

#2 Updated by Andreas Kohlbecker 6 months 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

#3 Updated by Andreas Kohlbecker 6 months ago

  • Assignee changed from Andreas Kohlbecker to Andreas Müller

#4 Updated by Andreas Müller 6 months 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)?

#5 Updated by Andreas Müller 6 months 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

#6 Updated by Andreas Kohlbecker 6 months 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 !

#7 Updated by Andreas Kohlbecker 6 months ago

  • Status changed from Feedback to In Progress
  • Assignee changed from Andreas Kohlbecker to Andreas Müller

#8 Updated by Andreas Müller 6 months 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

#9 Updated by Andreas Müller 6 months 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?

#10 Updated by Andreas Kohlbecker 6 months ago

  • Status changed from Resolved to Closed
  • % Done changed from 50 to 100

yes

#11 Updated by Andreas Müller 5 months ago

  • Target version changed from Release 5.25 to Release 5.23

Also available in: Atom PDF

Add picture from clipboard (Maximum size: 40 MB)