commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gary Gregory (JIRA)" <>
Subject [jira] [Updated] (JXPATH-166) JXPathContextReferenceImpl.addNodePointerFactory not working anymore
Date Tue, 04 Feb 2014 16:38:09 GMT


Gary Gregory updated JXPATH-166:

    Affects Version/s:     (was: 1.4)
                       Nightly Builds

> JXPathContextReferenceImpl.addNodePointerFactory not working anymore
> --------------------------------------------------------------------
>                 Key: JXPATH-166
>                 URL:
>             Project: Commons JXPath
>          Issue Type: Bug
>    Affects Versions: Nightly Builds
>            Reporter: Michele Vivoda
>   Original Estimate: 5m
>  Remaining Estimate: 5m
> I tried the following in a single test run in isolation:
> {{JXPathContextReferenceImpl.addNodePointerFactory(new ContainerPointerFactory());}}
> and got ExceptionInInitializer, I see a refactoring for  JXPathContext done by [~ggregory]
in last (recent) revision 1523175. Reverting to previous 1234255 fixes the issue. 
> The refactoring contains some static-init code in JXPathContext  that creates an instance
of a subclass of JXPathContext itself... seems to trigger one of the rare occasions in which
a static final field might be null, as happens then in a JXPathContextReferenceImpl constructor
where final field {{nodeFactories}} is null. My understanding is this: a call to any static
method of {{JXPathContextReferenceImpl}} triggers load of {{JXPathContext}} class that executes
static initialization code that creates a new {{JXPathContext}} that in turn is an other {{JXPathContextReferenceImpl}}
with static final field null since the static initializer of its super class must still terminate.
See something similar in and
> My fix is either to restore the volatile lazy initializaton just for {{compilationContext}}
or, perhaps (not sure), just create a new context each time in the {{compile(xpath)}} static
> {noformat}
> java.lang.ExceptionInInitializerError
> 	at org.apache.commons.jxpath.ri.AddNodePointerFactoryTest.testAddFactory(
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(
> 	at java.lang.reflect.Method.invoke(
> 	at junit.framework.TestCase.runTest(
> 	at junit.framework.TestCase.runBare(
> 	at junit.framework.TestResult$1.protect(
> 	at junit.framework.TestResult.runProtected(
> 	at
> 	at
> 	at junit.framework.TestSuite.runTest(
> 	at
> 	at
> 	at
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
> 	at
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(
> Caused by: java.lang.NullPointerException
> 	at org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.<init>(
> 	at org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.<init>(
> 	at org.apache.commons.jxpath.ri.JXPathContextFactoryReferenceImpl.newContext(
> 	at org.apache.commons.jxpath.JXPathContext.newContext(
> 	at org.apache.commons.jxpath.JXPathContext.<clinit>(
> 	... 19 more
> {noformat}

This message was sent by Atlassian JIRA

View raw message