You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by "M Kim (JIRA)" <ji...@apache.org> on 2015/02/16 18:50:13 UTC

[jira] [Created] (IVY-1513) NullPointerException in addConfiguredMacrodef of Configurator.java

M Kim created IVY-1513:
--------------------------

             Summary: NullPointerException in addConfiguredMacrodef of Configurator.java
                 Key: IVY-1513
                 URL: https://issues.apache.org/jira/browse/IVY-1513
             Project: Ivy
          Issue Type: Bug
    Affects Versions: 2.4.0
            Reporter: M Kim


NullPointerException occurs in addConfiguredMacrodef of Configurator.java because the parameter macrodef is null. However, this null value is returned from getCurrent() method which explicitly returns null when objectStack field is empty. Therefore, NPE should be suitably handled where getCurrent() is called. 

{code}
    public Object getCurrent() {
        return objectStack.isEmpty() ? null : ((ObjectDescriptor) objectStack.peek()).getObject();
    }

    public void endMacroDef() {
        addConfiguredMacrodef(((MacroDef) getCurrent()));
        objectStack.pop();
    }

    public void addConfiguredMacrodef(MacroDef macrodef) {
        macrodefs.put(macrodef.getName(), macrodef);
    }
{code}

<Stack Trace>
{code}
test(Test)java.lang.NullPointerException
at org.apache.ivy.util.Configurator.addConfiguredMacrodef(Configurator.java:749)
at org.apache.ivy.util.Configurator.endMacroDef(Configurator.java:744)
at Test.test(Test.java:20)
{code}

<Test Case>
{code}
public void test(){
  Configurator var = new Configurator();
  var.startMacroDef("macro");
  var.clear();
  var.endMacroDef();
}
{code}




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)