NullPointerException?

Discussion in 'Plugin Development' started by Blockhead7360, Aug 22, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    Blockhead7360

    Hello! I am working on updating one of my plugins, and I cannot seem to figure out why this is getting a null pointer. Is it the "getKeys" thing? The NPE is on line 2 of the code below:

    Code:
    int d = 0;
                        if (getConfig().getConfigurationSection("email.accounts.saves.account-info." + email_send_email.get(name) + ".mail").getKeys(false) == null){
                            d = 1;
                        }
                      
                        if (getConfig().getConfigurationSection("email.accounts.saves.account-info." + email_send_email.get(name) + ".mail").getKeys(false) != null){
                            d = getConfig().getConfigurationSection("email.accounts.saves.account-info." + email_send_email.get(name) + ".mail").getKeys(false).size() + 1;
    
    //and then more code here after doing the check above
    
                        }
    Thanks :D
     
  2. Offline

    beastman3226

    What line?
     
  3. Offline

    Blockhead7360

    @beastman3226 Line 2

    @beastman3226 on the full code, it's line 186, but above, its 2

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 11, 2016
  4. Offline

    beastman3226

    Alright, there are two variables that you don't have that it could be. Check that name is being given a value before this is called. And the other is the email_send_email. Best way to handle this is to add debug statements that tell you the value of these as the method gets called.
     
  5. Offline

    Blockhead7360

    @beastman3226 I added a debug statement, but the hashmap contained exactly what I wanted it to...

    @beastman3226 and the value "name" was been given

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 11, 2016
  6. Offline

    beastman3226

    Can we see the full Stacktrace then?
     
  7. Offline

    Blockhead7360

    @beastman3226 actually, there is no need to fix this null pointer, as I have fixed it another way with a StringList. Thanks for your help though
     
Thread Status:
Not open for further replies.

Share This Page