-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Description
Describe the bug
- Attempting to do a versioned read of a resource that was just expunged (via
MdmStorageInterceptor
when isAutoExpungeGoldenResources == true) causes NullPointerException, until it is expired in the "forced id" memory cache (1 minute expiration), after which it then correctly throws ResourceNotFoundException as expected.
Expected behavior
- The versioned read should cause a ResourceNotFoundException even if the PID is not yet expired in the memory cache
To Reproduce
- I will open a PR that simulates the problem via a unit test and fixes it by introducing a null guard such that
BaseHapiFhirResourceDao
correctly throws a ResourceNotFoundException even if the PID is not yet expired in the memory cache
Fix Details
The problem could probably also be fixed by invalidating the caches after commit, as is done in https://github.com/hapifhir/hapi-fhir/blob/v8.4.0/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/expunge/JpaResourceExpungeService.java#L212-L225
But the null guard seems good to have in any case (and fixes the issue without invalidating the entire cache).
- It could even be considered that the
JpaResourceExpungeService
should stop invalidating the cache (and thereby stop incurring a performance cost) with this fix?
Stacktrace:
Caused by: java.lang.NullPointerException: Cannot invoke "ca.uhn.fhir.jpa.model.entity.BaseHasResource.getVersion()" because "entity" is null
at ca.uhn.fhir.jpa.dao.BaseHapiFhirResourceDao.readEntity(BaseHapiFhirResourceDao.java:1944)
at ca.uhn.fhir.jpa.dao.BaseHapiFhirResourceDao.lambda$readEntity$21(BaseHapiFhirResourceDao.java:1680)
at ca.uhn.fhir.jpa.dao.tx.HapiTransactionService.invokeCallableAndHandleAnyException(HapiTransactionService.java:663)
... 13 more
Metadata
Metadata
Assignees
Labels
No labels