Repository: hapifhir/hapi-fhir
Issue: Address interceptor retains previous values

**Describe the bug**

Address interceptor retains previous values, but it should not

Changed files:
hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/validation/address/AddressValidatingInterceptor.java
hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/server/interceptor/validation/address/AddressValidatingInterceptorTest.java

diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/validation/address/AddressValidatingInterceptor.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/validation/address/AddressValidatingInterceptor.java
index f00bfb292d3..d76b3f83656 100644
--- a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/validation/address/AddressValidatingInterceptor.java
+++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/validation/address/AddressValidatingInterceptor.java
@@ -165,6 +165,8 @@ public class AddressValidatingInterceptor {
 	}
 
 	protected boolean validateAddress(IBase theAddress, FhirContext theFhirContext) {
+		ExtensionUtil.clearExtensionsByUrl(theAddress, getExtensionUrl());
+
 		try {
 			AddressValidationResult validationResult = getAddressValidator().isValid(theAddress, theFhirContext);
 			ourLog.debug("Validated address {}", validationResult);
diff --git a/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/server/interceptor/validation/address/AddressValidatingInterceptorTest.java b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/server/interceptor/validation/address/AddressValidatingInterceptorTest.java
index da7e98fbdcd..8a79791d8a9 100644
--- a/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/server/interceptor/validation/address/AddressValidatingInterceptorTest.java
+++ b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/server/interceptor/validation/address/AddressValidatingInterceptorTest.java
@@ -33,6 +33,7 @@ import static org.junit.jupiter.api.Assertions.fail;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.reset;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
@@ -235,6 +236,33 @@ class AddressValidatingInterceptorTest {
 		assertValidationErrorValue(person.getAddress().get(1), "true");
 	}
 
+	@Test
+	void validateOnValidInvalid() {
+		Address address = new Address();
+		address.addLine("Line");
+		address.setCity("City");
+
+		Person person = new Person();
+		person.addAddress(address);
+
+		AddressValidationResult validationResult = new AddressValidationResult();
+		validationResult.setValid(true);
+		when(myValidator.isValid(eq(address), any())).thenReturn(validationResult);
+		myInterceptor.resourcePreUpdate(myRequestDetails, null, person);
+
+		assertValidationErrorValue(person.getAddress().get(0), "false");
+
+		when(myValidator.isValid(eq(address), any())).thenThrow(new RuntimeException());
+
+		myInterceptor.resourcePreUpdate(myRequestDetails, null, person);
+
+		Extension ext = assertValidationErrorExtension(address);
+		assertNotNull(ext);
+		assertNull(ext.getValue());
+		assertTrue(ext.hasExtension());
+
+	}
+
 	public static class TestAddressValidator implements IAddressValidator {
 		@Override
 		public AddressValidationResult isValid(IBase theAddress, FhirContext theFhirContext) throws AddressValidationException {