Merge pull request #693 from jamesagnew/ConcurrentModificationRestSubscriptionFix

Fix to prevent rare Concurrent Modification Exceptions
This commit is contained in:
James Agnew 2017-07-26 17:26:45 -04:00 committed by GitHub
commit cb2cea54d7
2 changed files with 15 additions and 2 deletions

View File

@ -83,7 +83,12 @@ public class RestHookSubscriptionDstu2Interceptor extends BaseRestHookSubscripti
* @param theOperation
*/
private void checkSubscriptions(IIdType idType, String resourceType, RestOperationTypeEnum theOperation) {
for (Subscription subscription : myRestHookSubscriptions) {
//avoid a ConcurrentModificationException by copying to an array
for (Object object : myRestHookSubscriptions.toArray()) {
if (object == null) {
continue;
}
Subscription subscription = (Subscription) object;
// see if the criteria matches the created object
ourLog.info("Checking subscription {} for {} with criteria {}", subscription.getIdElement().getIdPart(), resourceType, subscription.getCriteria());
@ -121,6 +126,8 @@ public class RestHookSubscriptionDstu2Interceptor extends BaseRestHookSubscripti
}
}
/**
* Creates an HTTP Post for a subscription
*/

View File

@ -82,7 +82,13 @@ public class RestHookSubscriptionDstu3Interceptor extends BaseRestHookSubscripti
* @param theOperation
*/
private void checkSubscriptions(IIdType idType, String resourceType, RestOperationTypeEnum theOperation) {
for (Subscription subscription : myRestHookSubscriptions) {
//avoid a ConcurrentModificationException by copying to an array
for (Object object : myRestHookSubscriptions.toArray()) {
//for (Subscription subscription : myRestHookSubscriptions) {
if (object == null) {
continue;
}
Subscription subscription = (Subscription) object;
// see if the criteria matches the created object
ourLog.info("Checking subscription {} for {} with criteria {}", subscription.getIdElement().getIdPart(), resourceType, subscription.getCriteria());