Merge branch 'rel_5_7'

This commit is contained in:
Tadgh 2022-02-04 22:22:02 -08:00
commit 1af4912603
3 changed files with 16 additions and 11 deletions

View File

@ -524,8 +524,8 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> extends BaseStora
.map(Throwable::getMessage)
.collect(Collectors.joining(", "));
throw new InternalErrorException(
Msg.code(2019) +
"Tag get/create failed after "
Msg.code(2023)
+ "Tag get/create failed after "
+ TOTAL_TAG_READ_ATTEMPTS
+ " attempts with error(s): "
+ msg

View File

@ -15,7 +15,6 @@ import org.jetbrains.annotations.Nullable;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
@ -149,7 +148,6 @@ public class BaseHapiFhirDaoTest {
return from;
}
@Disabled
@Test
public void getTagOrNull_raceCondition_wontUpsertDuplicates() throws InterruptedException, ExecutionException {
/*
@ -179,7 +177,6 @@ public class BaseHapiFhirDaoTest {
String scheme = "http://localhost";
String term = "code123";
String label = "hollow world";
TransactionDetails transactionDetails = new TransactionDetails();
String raceConditionError = "Entity exists; if this is logged, you have race condition issues!";
TagDefinition tagDefinition = new TagDefinition(tagType,
@ -275,7 +272,7 @@ public class BaseHapiFhirDaoTest {
Runnable task = () -> {
latch.countDown();
try {
TagDefinition retTag = myTestDao.getTagOrNull(transactionDetails, tagType, scheme, term, label);
TagDefinition retTag = myTestDao.getTagOrNull(new TransactionDetails(), tagType, scheme, term, label);
outcomes.put(retTag.hashCode(), retTag);
counter.incrementAndGet();
} catch (Exception ex) {
@ -367,7 +364,7 @@ public class BaseHapiFhirDaoTest {
fail();
} catch (Exception ex) {
// verify
assertEquals("HAPI-2019: Tag get/create failed after 10 attempts with error(s): " + exMsg, ex.getMessage());
assertTrue(ex.getMessage().contains("Tag get/create failed after 10 attempts with error(s): " + exMsg));
ArgumentCaptor<ILoggingEvent> appenderCaptor = ArgumentCaptor.forClass(ILoggingEvent.class);
verify(myAppender, Mockito.times(10))

View File

@ -3,6 +3,7 @@ package ca.uhn.fhir.jpa.dao.r4;
import ca.uhn.fhir.i18n.Msg;
import ca.uhn.fhir.jpa.api.config.DaoConfig;
import ca.uhn.fhir.jpa.api.model.DaoMethodOutcome;
import ca.uhn.fhir.jpa.config.TestR4Config;
import ca.uhn.fhir.jpa.model.entity.ModelConfig;
import ca.uhn.fhir.jpa.model.entity.NormalizedQuantitySearchLevel;
import ca.uhn.fhir.jpa.model.entity.ResourceHistoryTable;
@ -60,7 +61,10 @@ import java.util.concurrent.Future;
import java.util.stream.Collectors;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.matchesPattern;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
@ -1009,8 +1013,10 @@ public class FhirResourceDaoR4CreateTest extends BaseJpaR4Test {
@Test
public void testResourceWithTagCreationNoFailures() throws ExecutionException, InterruptedException {
// this was 5, but our random connection pool runs as small as 3, and this solution needs a spare connection to be safe.
ExecutorService pool = Executors.newFixedThreadPool(2);
// we need to leave at least one free thread
// due to a REQUIRED_NEW transaction internally
int maxThreadsUsed = TestR4Config.ourMaxThreads - 1;
ExecutorService pool = Executors.newFixedThreadPool(Math.min(maxThreadsUsed, 5));
try {
Coding tag = new Coding();
tag.setCode("code123");
@ -1035,7 +1041,9 @@ public class FhirResourceDaoR4CreateTest extends BaseJpaR4Test {
try {
myPatientDao.update(updatePatient);
} catch (ResourceVersionConflictException e) {
assertThat(e.getMessage(), startsWith(Msg.code(550) + Msg.code(823)));
assertTrue(e.getMessage().contains(
"The operation has failed with a version constraint failure. This generally means that two clients/threads were trying to update the same resource at the same time, and this request was chosen as the failing request."
));
}
} catch (Exception e) {
ourLog.error("Failure", e);