Avoid deserialization issues in subscription delivery (#1856)

* Avoid deserialization issues in subscription delivery

* Add changelog
This commit is contained in:
James Agnew 2020-05-21 05:47:39 -04:00 committed by GitHub
parent 5b2181a563
commit e07e071130
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 2 deletions

6
\ Normal file
View File

@ -0,0 +1,6 @@
---
type: fix
issue: 1856
title: The subscription delivery queue in the JPA server was erroniously keeping both a copy of the serialized and the
deserialized payload in memory for each entry in the queue, doubling the memory requirements. This also caused failures
when delivering XML payloads in some configurations. This has been corrected.

View File

@ -0,0 +1,6 @@
---
type: fix
issue: 1856
title: "The subscription delivery queue in the JPA server was erroniously keeping both a copy of the serialized and the
deserialized payload in memory for each entry in the queue, doubling the memory requirements. This also caused failures
when delivering XML payloads in some configurations. This has been corrected."

View File

@ -21,6 +21,7 @@ package ca.uhn.fhir.jpa.subscription.model;
*/
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.parser.IParser;
import ca.uhn.fhir.rest.api.EncodingEnum;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
@ -62,7 +63,8 @@ public class ResourceDeliveryMessage extends BaseResourceMessage implements IRes
public IBaseResource getPayload(FhirContext theCtx) {
IBaseResource retVal = myPayload;
if (retVal == null && isNotBlank(myPayloadString)) {
retVal = theCtx.newJsonParser().parseResource(myPayloadString);
IParser parser = EncodingEnum.detectEncoding(myPayloadString).newParser(theCtx);
retVal = parser.parseResource(myPayloadString);
myPayload = retVal;
}
return retVal;
@ -93,7 +95,13 @@ public class ResourceDeliveryMessage extends BaseResourceMessage implements IRes
}
public void setPayload(FhirContext theCtx, IBaseResource thePayload, EncodingEnum theEncoding) {
myPayload = thePayload;
/*
* Note that we populate the raw string but don't keep the parsed resource around when we set this. This
* has two reasons:
* - If we build up a big queue of these on an in-memory queue, we aren't taking up double the memory
* - If use a serializing queue, we aren't behaving differently (and therefore possibly missing things
* in tests)
*/
myPayloadString = theEncoding.newParser(theCtx).encodeResourceToString(thePayload);
myPayloadId = thePayload.getIdElement().toUnqualified().getValue();
}