Skip to content

Conversation

waa-ben
Copy link

@waa-ben waa-ben commented Sep 19, 2025

When a Cur detects an ID attribute it fails to enter() it's locale before generating a tempCur(), leading to an index out of bounds exception from Locale:1934 when attempting to get the next available tempFrame.

@waa-ben
Copy link
Author

waa-ben commented Sep 19, 2025

This is blocking us upgrading at the moment, I'm not sure how long this has been an issue but it was exposed by the new-ish code that detects any attribute with the name "id" as an ID. In our environment the input was passed in by an org.apache.xml.serializer.ToXMLSAXHandler deep in a stack when apply an xsl transform to a document.

I'm happy to provide more details if required.


package xmlcursor.checkin;

import com.sun.org.apache.xml.internal.serializer.AttributesImplSerializer;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't want to use com.sum classes - they are only meant for internal use of the Java Runtime

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah apologies, I've changed it to just use org.xml.sax.helpers.AttributesImpl which I assume is more appropriate. That implementation wasn't the cause of the issue though so with that updated does this PR make sense?

@pjfanning
Copy link
Member

The new test fails with the following without the locale enter/exit change.

testSaxHandlerIdDetection()
java.lang.AssertionError: Temp frame not pushed
	at org.apache.xmlbeans.impl.store.Locale.tempCur(Locale.java:1928)
	at org.apache.xmlbeans.impl.store.Locale.tempCur(Locale.java:1920)
	at org.apache.xmlbeans.impl.store.Xobj.tempCur(Xobj.java:329)
	at org.apache.xmlbeans.impl.store.Cur$CurLoadContext.attr(Cur.java:2927)
	at org.apache.xmlbeans.impl.store.Cur$CurLoadContext.attr(Cur.java:2942)
	at org.apache.xmlbeans.impl.store.Locale$SaxHandler.startElement(Locale.java:2339)
	at xmlcursor.checkin.StoreTests.testSaxHandlerIdDetection(StoreTests.java:1979)
	at java.base/java.lang.reflect.Method.invoke(Method.java:569)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)

@pjfanning
Copy link
Member

I added https://issues.apache.org/jira/browse/XMLBEANS-660 to track this

@pjfanning
Copy link
Member

Thanks - merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants