diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/FhirContext.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/FhirContext.java
index 653fdd00415..92313c93f49 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/FhirContext.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/FhirContext.java
@@ -12,7 +12,7 @@ import java.lang.reflect.Method;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -95,7 +95,7 @@ public class FhirContext {
private volatile RuntimeChildUndeclaredExtensionDefinition myRuntimeChildUndeclaredExtensionDefinition;
private IContextValidationSupport, ?, ?, ?, ?, ?> myValidationSupport;
private final IFhirVersion myVersion;
-
+
private Map
* In other words, call {@link #setValidationSupport(IContextValidationSupport)} before
@@ -523,12 +524,12 @@ public class FhirContext {
*
null
)
+ * The custom type to add (must not be null
)
*/
public void registerCustomType(Class extends IBase> theType) {
Validate.notNull(theType, "theType must not be null");
@@ -617,7 +618,7 @@ public class FhirContext {
*
*
* @param theTypes
- * The custom types to add (must not be null
or contain null elements in the collection)
+ * The custom types to add (must not be null
or contain null elements in the collection)
*/
public void registerCustomTypes(Collectionnull
)
+ * The add profile mode (must not be null
)
*/
public void setAddProfileTagWhenEncoding(AddProfileTagEnum theAddProfileTagWhenEncoding) {
Validate.notNull(theAddProfileTagWhenEncoding, "theAddProfileTagWhenEncoding must not be null");
@@ -737,10 +738,10 @@ public class FhirContext {
*
*
* @param theProfile
- * The profile string, e.g. "http://example.com/some_patient_profile"
. Must not be
- * null
or empty.
+ * The profile string, e.g. "http://example.com/some_patient_profile"
. Must not be
+ * null
or empty.
* @param theClass
- * The resource type, or null
to clear any existing type
+ * The resource type, or null
to clear any existing type
*/
public void setDefaultTypeForProfile(String theProfile, Class extends IBaseResource> theClass) {
Validate.notBlank(theProfile, "theProfile must not be null or empty");
@@ -767,7 +768,7 @@ public class FhirContext {
* Sets a parser error handler to use by default on all parsers
*
* @param theParserErrorHandler
- * The error handler
+ * The error handler
*/
public void setParserErrorHandler(IParserErrorHandler theParserErrorHandler) {
Validate.notNull(theParserErrorHandler, "theParserErrorHandler must not be null");
@@ -777,8 +778,9 @@ public class FhirContext {
/**
* Sets the parser options object which will be used to supply default
* options to newly created parsers
- *
- * @param theParserOptions The parser options object - Must not be null
+ *
+ * @param theParserOptions
+ * The parser options object - Must not be null
*/
public void setParserOptions(ParserOptions theParserOptions) {
Validate.notNull(theParserOptions, "theParserOptions must not be null");
@@ -823,7 +825,7 @@ public class FhirContext {
/**
* Sets the validation support module to use for this context. The validation support module
* is used to supply underlying infrastructure such as conformance resources (StructureDefinition, ValueSet, etc)
- * as well as to provide terminology services to modules such as the validator and FluentPath executor
+ * as well as to provide terminology services to modules such as the validator and FluentPath executor
*/
public void setValidationSupport(IContextValidationSupport, ?, ?, ?, ?, ?> theValidationSupport) {
myValidationSupport = theValidationSupport;
@@ -841,9 +843,14 @@ public class FhirContext {
return resTypes;
}
- private synchronized void validateInitialized() {
+ private void validateInitialized() {
+ // See #610
if (!myInitialized) {
- scanResourceTypes(toElementList(myResourceTypesToScan));
+ synchronized (this) {
+ if (!myInitialized) {
+ scanResourceTypes(toElementList(myResourceTypesToScan));
+ }
+ }
}
}
diff --git a/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/context/FhirContextDstu3Test.java b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/context/FhirContextDstu3Test.java
index 15a9e99fef8..7f7ed60152e 100644
--- a/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/context/FhirContextDstu3Test.java
+++ b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/context/FhirContextDstu3Test.java
@@ -91,7 +91,7 @@ public class FhirContextDstu3Test {
public void testInitialisationThreadSafety() {
final FhirContext ctx = FhirContext.forDstu3();
- final int numThreads = 4;
+ final int numThreads = 40;
final List