From 94eb12aca3f83a755b2d14a3f0898b7b2d49c913 Mon Sep 17 00:00:00 2001 From: James Agnew Date: Tue, 11 Sep 2018 07:59:11 -0400 Subject: [PATCH] Add a retry to database expunge routines --- ...RuntimeChildUndeclaredExtensionDefinition.java | 2 +- .../main/java/ca/uhn/fhir/parser/JsonParser.java | 2 +- .../src/main/java/ca/uhn/fhir/util/XmlUtil.java | 4 ++-- .../java/ca/uhn/fhir/jpa/dao/BaseJpaTest.java | 15 ++++++++++++++- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildUndeclaredExtensionDefinition.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildUndeclaredExtensionDefinition.java index cd94bc5b4eb..a96f1283ce8 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildUndeclaredExtensionDefinition.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildUndeclaredExtensionDefinition.java @@ -27,7 +27,7 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.apache.commons.lang3.text.WordUtils; +import org.apache.commons.text.WordUtils; import org.hl7.fhir.instance.model.api.IBase; import org.hl7.fhir.instance.model.api.IBaseResource; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/JsonParser.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/JsonParser.java index c0b28de9b74..4ed208ca9e1 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/JsonParser.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/JsonParser.java @@ -38,7 +38,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.Validate; -import org.apache.commons.lang3.text.WordUtils; +import org.apache.commons.text.WordUtils; import org.hl7.fhir.instance.model.api.*; import java.io.IOException; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/XmlUtil.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/XmlUtil.java index cb4aba958dd..6c166b1ecdf 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/XmlUtil.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/XmlUtil.java @@ -27,7 +27,7 @@ import ca.uhn.fhir.util.jar.DependencyLogFactory; import ca.uhn.fhir.util.jar.IDependencyLog; import com.ctc.wstx.api.WstxInputProperties; import com.ctc.wstx.stax.WstxOutputFactory; -import org.apache.commons.lang3.StringEscapeUtils; +import org.apache.commons.text.StringEscapeUtils; import org.codehaus.stax2.XMLOutputFactory2; import org.codehaus.stax2.io.EscapingWriterFactory; @@ -54,7 +54,7 @@ public class XmlUtil { private static volatile XMLOutputFactory ourOutputFactory; static { - HashMap validEntityNames = new HashMap(1448); + HashMap validEntityNames = new HashMap<>(1448); validEntityNames.put("AElig", 0x000C6); validEntityNames.put("Aacute", 0x000C1); validEntityNames.put("Abreve", 0x00102); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseJpaTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseJpaTest.java index 16e4368aceb..5bb84abf40c 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseJpaTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseJpaTest.java @@ -335,7 +335,20 @@ public abstract class BaseJpaTest { boolean expungeEnabled = theDaoConfig.isExpungeEnabled(); theDaoConfig.setExpungeEnabled(true); - theSystemDao.expunge(new ExpungeOptions().setExpungeEverything(true)); + + for (int count = 0;; count++) { + try { + theSystemDao.expunge(new ExpungeOptions().setExpungeEverything(true)); + break; + } catch (Exception e) { + if (count >= 3) { + ourLog.error("Failed during expunge", e); + fail(e.toString()); + } else { + Thread.sleep(1000); + } + } + } theDaoConfig.setExpungeEnabled(expungeEnabled); theSearchParamRegistry.forceRefresh();