commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 11049] New: - JXPathContext.createPath() does work for field of multiplicity > 1
Date Mon, 22 Jul 2002 18:03:03 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11049>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11049

JXPathContext.createPath() does work for field of multiplicity > 1

           Summary: JXPathContext.createPath() does work for field of
                    multiplicity > 1
           Product: Commons
           Version: 1.0 Final
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: JXPath
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: abeveridge@12.com


When attempting to create a new indexed path (corresponding to a multiple 
field), I get a JXPathException that is ultimately caused by an 
IndexOutOfBounds exception. 

For example, if Names is an array/Collection of size 3, then context.createPath
("foo[3]") will throw a JXPathException (before getting to my implementation of 
AbstractFactory).

I chased the bug down in the latest codebase to the 
org.apache.commons.jxpath.ri.model.beans.BeanPropertyPointer.createPath
(JXPathContext context) method.

The first thing this method does is to attempt to check 
    (getNodeValue() != null)
but in the case that the path does not yet exist, and the exception is thrown.

My suggested fix: this method needs a bit more logic in the intial check, such 
as:

    Object nv = (index < getLength()) ? getNodeValue() : null;
    if (nv == null) {
        // same as before
        ....
    }
 
Can you let me know whether you condone this change? (abeveridge@12.com).

Finally, here is the stack trace that I get:

org.apache.commons.jxpath.JXPathException: Exception trying to create xpath 
names[3]; Cannot access property: names; 
java.lang.reflect.InvocationTargetException
    at org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.createPath
(JXPathContextReferenceImpl.java:309)
    at org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.createPath
(JXPathContextReferenceImpl.java:287)
    at com.oxygen.object.BusinessObject.setProperty(BusinessObject.j
ava:233)
    at com.oxygen.object.BusinessObjectXpathTest.testMomAndDad(Busin
essObjectXpathTest.java:214)
    at java.lang.reflect.Method.invoke(Native Method)
    at junit.framework.TestCase.runTest(TestCase.java:166)
    at junit.framework.TestCase.runBare(TestCase.java:140)
    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:131)
    at junit.framework.TestSuite.runTest(TestSuite.java:173)
    at junit.framework.TestSuite.run(TestSuite.java:168)
    at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run
(JUnitTestRunner.java:231)
    at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main
(JUnitTestRunner.java:409)

    =====NESTED EXCEPTION=====
org.apache.commons.jxpath.JXPathException: Cannot access property: names; 
java.lang.reflect.InvocationTargetException
    at org.apache.commons.jxpath.util.ValueUtils.getValue(ValueUtils
.java:346)
    at org.apache.commons.jxpath.ri.model.beans.BeanPropertyPointer.getNodeValue
(BeanPropertyPointer.java:190)
    at org.apache.commons.jxpath.ri.model.beans.BeanPropertyPointer.createPath
(BeanPropertyPointer.java:223)
    at org.apache.commons.jxpath.ri.model.beans.PropertyOwnerPointer.createChild
(PropertyOwnerPointer.java:169)
    at org.apache.commons.jxpath.ri.model.beans.NullElementPointer.createChild
(NullElementPointer.java:164)
    at org.apache.commons.jxpath.ri.model.beans.NullPointer.createPath
(NullPointer.java:142)
    at org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.createPath
(JXPathContextReferenceImpl.java:306)
    at org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.createPath
(JXPathContextReferenceImpl.java:287)
    at com.oxygen.object.BusinessObject.setProperty(BusinessObject.java:233)
    at com.oxygen.object.BusinessObjectXpathTest.testMomAndDad
(BusinessObjectXpathTest.java:214)
    at java.lang.reflect.Method.invoke(Native Method)
    at junit.framework.TestCase.runTest(TestCase.java:166)
    at junit.framework.TestCase.runBare(TestCase.java:140)
    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:131)
    at junit.framework.TestSuite.runTest(TestSuite.java:173)
    at junit.framework.TestSuite.run(TestSuite.java:168)
    at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run
(JUnitTestRunner.java:231)
    at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main
(JUnitTestRunner.java:409)

    ====NESTED EXCEPTION=====
java.lang.reflect.InvocationTargetException: 
java.lang.IndexOutOfBoundsException: Index: 2, Size: 2
    at java.util.ArrayList.RangeCheck(ArrayList.java:486)
    at java.util.ArrayList.get(ArrayList.java:302)
    at com.oxygen.object.Dad.getNames(Dad.java:210)
    at java.lang.reflect.Method.invoke(Native Method)
    at org.apache.commons.jxpath.util.ValueUtils.getValue(ValueUtils.java:342)
    at org.apache.commons.jxpath.ri.model.beans.BeanPropertyPointer.getNodeValue
(BeanPropertyPointer.java:190)
    at org.apache.commons.jxpath.ri.model.beans.BeanPropertyPointer.createPath
(BeanPropertyPointer.java:223)
    at org.apache.commons.jxpath.ri.model.beans.PropertyOwnerPointer.createChild
(PropertyOwnerPointer.java:169)
    at org.apache.commons.jxpath.ri.model.beans.NullElementPointer.createChild
(NullElementPointer.java:164)
    at org.apache.commons.jxpath.ri.model.beans.NullPointer.createPath
(NullPointer.java:142)
    at org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.createPath
(JXPathContextReferenceImpl.java:306)
    at org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.createPath
(JXPathContextReferenceImpl.java:287)
    at com.oxygen.object.BusinessObject.setProperty(BusinessObject.java:233)
    at com.oxygen.object.BusinessObjectXpathTest.testMomAndDad
(BusinessObjectXpathTest.java:214)
    at java.lang.reflect.Method.invoke(Native Method)
    at junit.framework.TestCase.runTest(TestCase.java:166)
    at junit.framework.TestCase.runBare(TestCase.java:140)
    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:131)
    at junit.framework.TestSuite.runTest(TestSuite.java:173)
    at junit.framework.TestSuite.run(TestSuite.java:168)
    at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run
(JUnitTestRunner.java:231)
    at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main
(JUnitTestRunner.java:409)

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message