Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A0E7510DE8 for ; Tue, 4 Feb 2014 05:40:12 +0000 (UTC) Received: (qmail 72807 invoked by uid 500); 4 Feb 2014 05:40:11 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 72728 invoked by uid 500); 4 Feb 2014 05:40:10 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 72720 invoked by uid 99); 4 Feb 2014 05:40:09 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Feb 2014 05:40:09 +0000 Date: Tue, 4 Feb 2014 05:40:09 +0000 (UTC) From: "Michele Vivoda (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (JXPATH-166) JXPathContextReferenceImpl.addNodePointerFactory not working anymore MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/JXPATH-166?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Michele Vivoda updated JXPATH-166: ---------------------------------- Description: 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 http://stackoverflow.com/a/2547638/1536382 and http://stackoverflow.com/questions/2547713/why-static-fields-are-not-initialized-in-time My fix is either to restore the volatile lazy initializaton just for {{compilationContext}} or, perhaps better, just create a new context each time in the {{compile(xpath)}} static method. {noformat} java.lang.ExceptionInInitializerError at org.apache.commons.jxpath.ri.AddNodePointerFactoryTest.testAddFactory(AddNodePointerFactoryTest.java:32) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Caused by: java.lang.NullPointerException at org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.(JXPathContextReferenceImpl.java:191) at org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.(JXPathContextReferenceImpl.java:178) at org.apache.commons.jxpath.ri.JXPathContextFactoryReferenceImpl.newContext(JXPathContextFactoryReferenceImpl.java:39) at org.apache.commons.jxpath.JXPathContext.newContext(JXPathContext.java:425) at org.apache.commons.jxpath.JXPathContext.(JXPathContext.java:389) ... 19 more {noformat} was: 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 http://stackoverflow.com/a/2547638/1536382 and http://stackoverflow.com/questions/2547713/why-static-fields-are-not-initialized-in-time My fix is either to restore the volatile lazy initializaton just for {{compilationContext}} or, perhaps better, just create a new context each time in the {{compile(xpath)} static method. {noformat} java.lang.ExceptionInInitializerError at org.apache.commons.jxpath.ri.AddNodePointerFactoryTest.testAddFactory(AddNodePointerFactoryTest.java:32) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Caused by: java.lang.NullPointerException at org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.(JXPathContextReferenceImpl.java:191) at org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.(JXPathContextReferenceImpl.java:178) at org.apache.commons.jxpath.ri.JXPathContextFactoryReferenceImpl.newContext(JXPathContextFactoryReferenceImpl.java:39) at org.apache.commons.jxpath.JXPathContext.newContext(JXPathContext.java:425) at org.apache.commons.jxpath.JXPathContext.(JXPathContext.java:389) ... 19 more {noformat} > JXPathContextReferenceImpl.addNodePointerFactory not working anymore > -------------------------------------------------------------------- > > Key: JXPATH-166 > URL: https://issues.apache.org/jira/browse/JXPATH-166 > Project: Commons JXPath > Issue Type: Bug > Affects Versions: 1.4 > 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 http://stackoverflow.com/a/2547638/1536382 and http://stackoverflow.com/questions/2547713/why-static-fields-are-not-initialized-in-time > My fix is either to restore the volatile lazy initializaton just for {{compilationContext}} or, perhaps better, just create a new context each time in the {{compile(xpath)}} static method. > {noformat} > java.lang.ExceptionInInitializerError > at org.apache.commons.jxpath.ri.AddNodePointerFactoryTest.testAddFactory(AddNodePointerFactoryTest.java:32) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) > at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:606) > at junit.framework.TestCase.runTest(TestCase.java:154) > at junit.framework.TestCase.runBare(TestCase.java:127) > at junit.framework.TestResult$1.protect(TestResult.java:106) > at junit.framework.TestResult.runProtected(TestResult.java:124) > at junit.framework.TestResult.run(TestResult.java:109) > at junit.framework.TestCase.run(TestCase.java:118) > at junit.framework.TestSuite.runTest(TestSuite.java:208) > at junit.framework.TestSuite.run(TestSuite.java:203) > at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130) > at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) > Caused by: java.lang.NullPointerException > at org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.(JXPathContextReferenceImpl.java:191) > at org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.(JXPathContextReferenceImpl.java:178) > at org.apache.commons.jxpath.ri.JXPathContextFactoryReferenceImpl.newContext(JXPathContextFactoryReferenceImpl.java:39) > at org.apache.commons.jxpath.JXPathContext.newContext(JXPathContext.java:425) > at org.apache.commons.jxpath.JXPathContext.(JXPathContext.java:389) > ... 19 more > {noformat} -- This message was sent by Atlassian JIRA (v6.1.5#6160)