Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8336667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:03:57+00:00 2026-06-09T04:03:57+00:00

This is a method where I am using the while loop. I strongly suspect

  • 0

This is a method where I am using the while loop. I strongly suspect that an infinite loop is possible. How to check and eliminate that?

I am using two while loops here. Sould I totally dismantle the while loop?

public class ReferenceListSaveHandler
{
public PublishReferenceListUpdates populateResponse(SearchQueryResponse pSearchQueryResponse,SearchQueryResponse pListResponse, ObjectFactory objFactory)         throws IOException, ParserConfigurationException, SAXException,SipException, Exception
    {
        ReferenceDataProcessor lRefPro = new ReferenceDataProcessor();
        PublishReferenceListUpdates lResponse = null;
        Record listRecord = null;
        ReferenceDataListItemListType lReferenceDataListItemListType = objFactory
            .createReferenceDataListItemListType();
        ReferenceDataListType lReferenceDataListType = null;
        ReferenceDataListItemType lReferenceDataListItemType = null;
        boolean ifSynonym = false;
        String lRowIdObject = null;
        final int lRowIdLength = 14;

        if (refListItemItr.hasNext())
        {
            Record record = (Record)refListItemItr.next();
            boolean continueProcessing = true;
            boolean lastRecord = false;
            while (continueProcessing)
            { // first use of while loop
                if (refListItemItr.hasNext() || lastRecord)
                {
                    continueProcessing = true;
                    lastRecord = false;
                }
                else
                {
                    continueProcessing = false;
                }

                if (continueProcessing)
                {
                    lSynonymListType = objFactory
                        .createSynonymListType();

                    Field itemLSIDField = record
                        .getField(ReferenceDataConstants.FIELD_COMPOUND_ASSET_ID);

                    if (itemLSIDField == null)
                    {
                        continue;
                    }
                    else
                    {
                        currentItemLSID = itemLSIDField
                            .getStringValue().trim();
                    }
                    lReferenceDataListItemType = objFactory
                        .createReferenceDataListItemType();
                    lReferenceDataListItemType = setListDetails(record,
                        lReferenceDataListItemType,
                        lId, lName, objFactory);


                    while (refListItemItr.hasNext()
                           && continueProcessing)
                    {  // second use of while loop
                        SynonymType lSynonymType = null;
                        if (continueProcessing)
                        {
                            if (lSynonymType != null)
                                lSynonymListType.getSynonym().add(lSynonymType);
                        }
                    }
                    continueProcessing = true;
                }
            }//while loop
        }
    }
}

Please help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T04:04:00+00:00Added an answer on June 9, 2026 at 4:04 am

    Problem number one: refListItemItr, whatever that is (its definition is not shown), has a .next() method but it’s never called inside the loop.

    Problem number two: The second while loop is always infinite if you enter it:

    while (refListItemItr.hasNext()
           && continueProcessing)
    {
        SynonymType lSynonymType = null;
        if (continueProcessing)
        {
            if (lSynonymType != null)
                lSynonymListType.getSynonym().add(lSynonymType);
        } 
    }
    

    Neither refListItemItr.hasNext(), nor continueProcessing can change inside this loop. That’s why it’s an infinite loop.

    EDIT:
    I can’t tell you how to change the code because there are many possible ways to change it, depending on what’s supposed to happen. You can try this but it may or may not work:

    1. Remove the second loop entirely (it does nothing right now).
    2. Add this line just before the end of the first loop:

          record = (Record)refListItemItr.next(); // ADD THIS LINE
      } //while loop BEFORE THIS LINE
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been using this copy method for quite a while, in lots of
I am using this method - (void)keyboardWillShow:(NSNotification *)notification that is triggered when the keyboard
I'm using the following loop to grab files for an animation. This method makes
Using PHP , I would like to make a while loop that reads a
I have a while loop that loops until bool done = true; In the
I am using this method on a button click. My app is not yet
I'm using this method to install an application, but it doesn't put the applications
I am using this method to get a list of week start from my
I am using this method for resize the images: version :big do process :resize_to_fit
I find myself using this method a ton to perform actions based on a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.