URIResolve causing stack overflow

1 view
Skip to first unread message

Jakob Saternus

unread,
Nov 13, 2007, 7:36:21 AM11/13/07
to xtf-...@googlegroups.com

Hello,

With dependency="yes" XTF can crash with the following error:

2007-nov-11 07:07:49 org.apache.catalina.core.StandardWrapperValve
invoke
ALLVARLIG: Servlet.service() for servlet dynaXML threw exception
java.lang.StackOverflowError
at java.net.URI$Parser.charAt(Unknown Source)
at java.net.URI$Parser.scan(Unknown Source)
at java.net.URI$Parser.checkChars(Unknown Source)
at java.net.URI$Parser.parseHierarchical(Unknown Source)
at java.net.URI$Parser.parse(Unknown Source)
at java.net.URI.<init>(Unknown Source)
at java.net.URI.create(Unknown Source)
at java.net.URI.resolve(Unknown Source)
at
net.sf.saxon.java.JavaPlatform.makeAbsolute(JavaPlatform.java:115)
at
net.sf.saxon.StandardURIResolver.resolve(StandardURIResolver.java:157)
at
org.cdlib.xtf.servletBase.StylesheetCache$DepResolver.resolve(StylesheetCache.java:225)
at
org.cdlib.xtf.servletBase.StylesheetCache$DepResolver.resolve(StylesheetCache.java:225)
(1000 more lines)


I skimmed through the source and found that if you enable dependency
checking a new URIResolver is set each time a new stylesheet is loaded.
The problem is: the new URIResolver calls recursively the old one.

The following code (found in the generate() function) should be moved
to the StylesheetCache constructor:

// Set a URI resolver for dependency checking, if enabled.
if (dependencyChecking)
factory.setURIResolver(new DepResolver(dependencyReceiver,
factory.getURIResolver()));

Regards,
Jakob

Martin Haye

unread,
Nov 13, 2007, 10:53:19 AM11/13/07
to xtf-...@googlegroups.com
Another good find Jakob. What if I left code where it is (I'm superstitious about the factory being replaced) but added an instanceof check like this:


// Set a URI resolver for dependency checking, if enabled.

if (dependencyChecking && !(factory.getURIResolver() instanceof DepResolver))
factory.setURIResolver(new DepResolver(dependencyReceiver,
factory.getURIResolver()));

--Martin

winmail.dat

Jakob Saternus

unread,
Nov 13, 2007, 1:56:55 PM11/13/07
to Martin Haye

Well, the factory is created in the constructor just a few lines above
so it should be safe to set such properties there, once for all.
I cannot see a place where the factory could be replaced.

Jakob

Martin Haye

unread,
Nov 13, 2007, 5:26:19 PM11/13/07
to xtf-...@googlegroups.com
Good point.

--Martin

Martin Haye

unread,
Nov 16, 2007, 2:22:36 PM11/16/07
to xtf-...@googlegroups.com
Hi Jakob,

You're right, it belongs in the constructor. I just checked in that change.

--Martin


On 11/13/07 10:56 AM, "Jakob Saternus" <ja...@uuc.se> wrote:

>> org.cdlib.xtf.servletBase.StylesheetCache$DepResolver.resolve(StylesheetCache
>> .java:225)
>> at
>> org.cdlib.xtf.servletBase.StylesheetCache$DepResolver.resolve(StylesheetCache

Reply all
Reply to author
Forward
0 new messages