Fix to prevent rare Concurrent Modification Exceptions

This commit is contained in:
Jeff Chung 2017-07-17 15:10:38 -07:00
parent f7d4296046
commit a49e009cba
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());