NullPointerException in ScriptingContainer.setCurrentDirectory()
----------------------------------------------------------------

                 Key: JRUBY-5453
                 URL: http://jira.codehaus.org/browse/JRUBY-5453
             Project: JRuby
          Issue Type: Bug
          Components: Embedding
         Environment: latest JRuby 1.6 code in master branch as of February 5, 
running on OS X 10.6.6
            Reporter: Adam Murray


The following test fails:

public void testSetCurrentDirectoryAfterMinimalSetup() {
        String directory = System.getProperty( "user.home" );
        ScriptingContainer instance = new ScriptingContainer();
        instance.setCurrentDirectory(directory);
        assertEquals(directory, instance.getCurrentDirectory());
}

with java.lang.NullPointerException
    at 
org.jruby.embed.internal.SingletonLocalContextProvider.isRuntimeInitialized(SingletonLocalContextProvider.java:83)
    at 
org.jruby.embed.ScriptingContainer.setCurrentDirectory(ScriptingContainer.java:585)
    at 
org.jruby.test.TestScriptingContainer.testSetCurrentDirectoryAfterMinimalSetup(TestScriptingContainer.java:14)

I was able to fix it by changing 
SingletonLocalContextProvider.isRuntimeInitialized() to:

public boolean isRuntimeInitialized() {
    if (localContext == null) {
        localContext = getInstance();
    }
    return localContext.initialized;
}

My change was to add the if condition, which matches the way a null 
localContext is handled in the other methods in this class.


I'll submit a pull requests for this on github, but I was a little confused by 
the unit test situation with ScriptingContainer. I found tests under 
test/org/jruby/embed, but they didn't seem to be running as part of the ant 
test tasks. I guess it might be because those tests use the "new style" JUnit 
annotations, but MainTestSuite still does things the "old way". So I guess some 
adjustments need to be made to get the tests in the embed package hooked up to 
the main test suite. Instead of attempting to address this situation, I simply 
added a new TestCase subclass under test/org/jruby/test/

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to