Project

General

Profile

Actions

bug #9606

closed

NullPointerExceptions (NPEs) in OccurrenceServiceImpl

Added by Andreas Kohlbecker over 1 year ago. Updated over 1 year ago.

Status:
Closed
Priority:
Highest
Category:
cdmlib
Target version:
Start date:
Due date:
% Done:

100%

Estimated time:
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

Actions #1

Updated by Andreas Müller over 1 year 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?

Actions #2

Updated by Andreas Kohlbecker over 1 year 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

Actions #3

Updated by Andreas Kohlbecker over 1 year ago

  • Assignee changed from Andreas Kohlbecker to Andreas Müller
Actions #4

Updated by Andreas Müller over 1 year 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)?

Actions #5

Updated by Andreas Müller over 1 year 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

Actions #6

Updated by Andreas Kohlbecker over 1 year 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 !

Actions #7

Updated by Andreas Kohlbecker over 1 year ago

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

Updated by Andreas Müller over 1 year 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

Actions #9

Updated by Andreas Müller over 1 year 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?

Actions #10

Updated by Andreas Kohlbecker over 1 year ago

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

yes

Actions #11

Updated by Andreas Müller over 1 year ago

  • Target version changed from Release 5.25 to Release 5.23
Actions

Also available in: Atom PDF