Added null checks for the request details param

This commit is contained in:
Nick Goupinets 2021-03-24 10:50:26 -04:00
parent 6aab327612
commit bac2e58b90
3 changed files with 16 additions and 1 deletions

View File

@ -101,6 +101,11 @@ public class StandardizingInterceptor {
} }
private void standardize(RequestDetails theRequest, IBaseResource theResource) { private void standardize(RequestDetails theRequest, IBaseResource theResource) {
if (theRequest == null) {
ourLog.debug("RequestDetails is null - unable to standardize {}", theResource);
return;
}
if (!theRequest.getHeaders(STANDARDIZATION_DISABLED_HEADER).isEmpty()) { if (!theRequest.getHeaders(STANDARDIZATION_DISABLED_HEADER).isEmpty()) {
ourLog.debug("Standardization for {} is disabled via header {}", theResource, STANDARDIZATION_DISABLED_HEADER); ourLog.debug("Standardization for {} is disabled via header {}", theResource, STANDARDIZATION_DISABLED_HEADER);
return; return;

View File

@ -107,6 +107,12 @@ public class AddressValidatingInterceptor {
protected void handleRequest(RequestDetails theRequest, IBaseResource theResource) { protected void handleRequest(RequestDetails theRequest, IBaseResource theResource) {
if (getAddressValidator() == null) { if (getAddressValidator() == null) {
ourLog.debug("Address validator is not provided - validation disabled");
return;
}
if (theRequest == null) {
ourLog.debug("RequestDetails is null - unable to validate address for {}", theResource);
return; return;
} }

View File

@ -27,7 +27,6 @@ import ca.uhn.fhir.interceptor.api.Interceptor;
import ca.uhn.fhir.interceptor.api.Pointcut; import ca.uhn.fhir.interceptor.api.Pointcut;
import ca.uhn.fhir.rest.api.server.RequestDetails; import ca.uhn.fhir.rest.api.server.RequestDetails;
import ca.uhn.fhir.rest.server.interceptor.ConfigLoader; import ca.uhn.fhir.rest.server.interceptor.ConfigLoader;
import ca.uhn.fhir.rest.server.interceptor.ServerOperationInterceptorAdapter;
import ca.uhn.fhir.rest.server.interceptor.validation.address.IAddressValidator; import ca.uhn.fhir.rest.server.interceptor.validation.address.IAddressValidator;
import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IPrimitiveType; import org.hl7.fhir.instance.model.api.IPrimitiveType;
@ -73,6 +72,11 @@ public class FieldValidatingInterceptor {
} }
protected void handleRequest(RequestDetails theRequest, IBaseResource theResource) { protected void handleRequest(RequestDetails theRequest, IBaseResource theResource) {
if (theRequest == null) {
ourLog.debug("RequestDetails is null - unable to validate {}", theResource);
return;
}
if (!theRequest.getHeaders(VALIDATION_DISABLED_HEADER).isEmpty()) { if (!theRequest.getHeaders(VALIDATION_DISABLED_HEADER).isEmpty()) {
ourLog.debug("Address validation is disabled for this request via header"); ourLog.debug("Address validation is disabled for this request via header");
return; return;