From 75a5c7c77373db1daa423dbf101d9ba366bb3855 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 1 Apr 2020 20:20:51 +0200 Subject: [PATCH] Please cherry-pick: - rewrote to avoid local Iterator instance MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../model/contact/JobsContactSessionBean.java | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/java/org/mxchange/jcontacts/model/contact/JobsContactSessionBean.java b/src/java/org/mxchange/jcontacts/model/contact/JobsContactSessionBean.java index 1cd6fdf..7718012 100644 --- a/src/java/org/mxchange/jcontacts/model/contact/JobsContactSessionBean.java +++ b/src/java/org/mxchange/jcontacts/model/contact/JobsContactSessionBean.java @@ -17,7 +17,6 @@ package org.mxchange.jcontacts.model.contact; import java.text.MessageFormat; -import java.util.Iterator; import java.util.List; import java.util.Objects; import javax.ejb.Stateless; @@ -98,21 +97,15 @@ public class JobsContactSessionBean extends BaseJobsEnterpriseBean implements Co return null; } - // Get iterator - final Iterator iterator = contacts.iterator(); - // Loop through all - while (iterator.hasNext()) { - // Get contact - final Contact next = iterator.next(); - + for (final Contact currentContact : contacts) { // Is same contact? - if ((Objects.equals(contact, next)) || (Contacts.isSameContact(contact, next))) { + if ((Objects.equals(contact, currentContact)) || (Contacts.isSameContact(contact, currentContact))) { // Debug message - this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.isContactFound: Found same contact: contactId={1}", this.getClass().getSimpleName(), next.getContactId())); //NOI18N + this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.isContactFound: Found same contact: contactId={1}", this.getClass().getSimpleName(), currentContact.getContactId())); //NOI18N // Found it - foundContact = next; + foundContact = currentContact; break; } } -- 2.39.5