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 8144621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:26:11+00:00 2026-06-06T13:26:11+00:00

The following method calculates cost. It access other classes when required. Cloud class holds

  • 0

The following method calculates cost. It access other classes when required. Cloud class holds the information for pricing.

However the method is giving me a nullpointer exception at the following line.
BoundaryPrice btp = cloud.getBoundaryPriceMap().get(boundaryType);
The value for totalcost never changes.
Any idea to high light the problem here?

private float getCostForConnector(Connector connector)
{
    Cloud cloud = new Cloud("http://amazon.com/europeEC2Clouds#dublinEC2Cloud", dynDesInventory);
    List<Port> portList = getListOfPort(connector);
    Resource root = findCommonRoot(connector);

    Port p1 = portList.get(0);
    Port p2 = portList.get(1);
    float totalCost = 0.0f;
    try
    {
    String rootBoundaryType = getRootBoundaryType();

    Float dataProducedFromP1 = getDataCountForPort(p1);
    Float dataProducedFromP2 = getDataCountForPort(p2);

    List<String> portOnePathOut =  getListOfNetworkBoundary(p1, root);
    List<String> portTwoPathOut =  getListOfNetworkBoundary(p2, root);

        for(String boundaryType: portOnePathOut)
        {
            BoundaryPrice btp = cloud.getBoundaryPriceMap().get(boundaryType);
            if (btp != null)
            {
                totalCost += btp.getOutPrice(boundaryType) + dataProducedFromP1;
                totalCost += btp.getInPrice(boundaryType) + dataProducedFromP2;
            }
        }

        for(String boundaryType: portTwoPathOut)
        {
            BoundaryPrice btp = cloud.getBoundaryPriceMap().get(boundaryType);
            if (btp != null)
            {
                totalCost += btp.getOutPrice(boundaryType) + dataProducedFromP2;
                totalCost += btp.getInPrice(boundaryType) + dataProducedFromP1;
            }
        }

        BoundaryPrice btp = cloud.getBoundaryPriceMap().get(rootBoundaryType);
        if (btp != null)
        {
            totalCost += (dataProducedFromP1 + dataProducedFromP2) * btp.getIntraPrice(rootBoundaryType);
        }


    }catch(NullPointerException e) {
        System.err.println("Caught NullPointerException: ");
    }
    return totalCost;

}
  • 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-06T13:26:13+00:00Added an answer on June 6, 2026 at 1:26 pm
    1. One of portOnePathOut and portTwoPathOut lists is null
    2. portList is null
    3. cloud.getBoundaryPriceMap() is null
    4. btp.getIntraPrice(rootBoundaryType) is numeric wrapper and it is null
    5. dataProducedFromP1 or dataProducedFromP2 are null
    6. btp.getOutPrice(boundaryType), btp.getIntraPrice(rootBoundaryType) or btp.getInPrice(boundaryType) are null
    7. some object inside functions you invoke is null

    The list would be much shorter next time when you post the stack trace.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following method does not access any shared variable. It is still not thread
I have following method that that calculates distance and returns it in miles: public
I have the following method that calculates the top 20 numbers in a list
The following method, when called with something like String val = getCell(SELECT col FROM
The following method is launched from the constructor of UserControl. A cross thread exception
The following method does not apply the wpf changes (background = red) until the
The following method does its job but keeps printing a warning also, im pretty
I have the following method, which takes in the name of a file as
I have the following method that returns void and I need to use it
I have the following method where I want to test the event.status property only

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.