diff --git a/framework/src/main/groovy/org/moqui/impl/context/NotificationMessageImpl.groovy b/framework/src/main/groovy/org/moqui/impl/context/NotificationMessageImpl.groovy index 43988372d..63bc08178 100644 --- a/framework/src/main/groovy/org/moqui/impl/context/NotificationMessageImpl.groovy +++ b/framework/src/main/groovy/org/moqui/impl/context/NotificationMessageImpl.groovy @@ -96,12 +96,16 @@ class NotificationMessageImpl implements NotificationMessage, Externalizable { EntityListIterator eli = ef.find("moqui.security.UserGroupMember") .conditionDate("fromDate", "thruDate", new Timestamp(System.currentTimeMillis())) .condition("userGroupId", userGroupId).disableAuthz().iterator() - EntityValue nextValue - while ((nextValue = (EntityValue) eli.next()) != null) { - String userId = (String) nextValue.userId - if (checkedUserIds.contains(userId)) continue - checkedUserIds.add(userId) - if (checkUserNotify(userId, ef)) notifyUserIds.add(userId) + try { + EntityValue nextValue + while ((nextValue = (EntityValue) eli.next()) != null) { + String userId = (String) nextValue.userId + if (checkedUserIds.contains(userId)) continue + checkedUserIds.add(userId) + if (checkUserNotify(userId, ef)) notifyUserIds.add(userId) + } + } finally { + eli.close(); } } diff --git a/framework/src/main/java/org/moqui/entity/EntityListIterator.java b/framework/src/main/java/org/moqui/entity/EntityListIterator.java index 639431001..7dea9643a 100644 --- a/framework/src/main/java/org/moqui/entity/EntityListIterator.java +++ b/framework/src/main/java/org/moqui/entity/EntityListIterator.java @@ -20,7 +20,7 @@ * Entity Cursor List Iterator for Handling Cursored Database Results */ @SuppressWarnings("unused") -public interface EntityListIterator extends ListIterator { +public interface EntityListIterator extends ListIterator, AutoCloseable { /** Close the underlying ResultSet and Connection. This must ALWAYS be called when done with an EntityListIterator. */ void close() throws EntityException;