Bug 43910 - NullPointerException throw if there is no fo:root
Summary: NullPointerException throw if there is no fo:root
Status: CLOSED FIXED
Alias: None
Product: Fop - Now in Jira
Classification: Unclassified
Component: fo tree (show other bugs)
Version: 0.94
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: fop-dev
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-11-19 23:48 UTC by David Delbecq
Modified: 2012-04-01 06:27 UTC (History)
0 users



Attachments
Patch that solves the issue (2.15 KB, patch)
2007-11-20 01:47 UTC, David Delbecq
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Delbecq 2007-11-19 23:48:02 UTC
in AreaTreeHandler, if no fo:root was found in document (which can arise from
time to time when you use fo together with xslt), the endDocument() method
throws a nullpointerexception instead of making clean fallback (either generate
empty document or throw a SAXException). Because NullPointerException is quite
anonymous error, it makes it difficult for caller to properly catch it and
handle it in calling code.

Please note javadoc of endDocument states that it "throws SAXException if there
is some error". So this probably should be throwing a SAXException("no fo:root
found in document") 

Caused by: java.lang.NullPointerException
	at org.apache.fop.area.AreaTreeHandler.endDocument(AreaTreeHandler.java:264)
	at org.apache.fop.fo.FOTreeBuilder.endDocument(FOTreeBuilder.java:171)
	at net.sf.saxon.event.ContentHandlerProxy.close(ContentHandlerProxy.java:255)
	at net.sf.saxon.event.ImplicitResultChecker.close(ImplicitResultChecker.java:69)
	at net.sf.saxon.event.ProxyReceiver.close(ProxyReceiver.java:86)
	at
net.sf.saxon.event.ComplexContentOutputter.close(ComplexContentOutputter.java:458)
	at net.sf.saxon.Controller.transformDocument(Controller.java:1655)
	at net.sf.saxon.Controller.transform(Controller.java:1438)
Comment 1 David Delbecq 2007-11-20 01:47:34 UTC
Created attachment 21159 [details]
Patch that solves the issue

Submited patch that properly solves the issue. fop creates correct pdf that has
no page in it (only metadatas)
Comment 2 Jeremias Maerki 2007-11-20 02:29:18 UTC
Patch applied. Thanks.
http://svn.apache.org/viewvc?rev=596600&view=rev

I couldn't reproduce the NPE but the change makes sense if it helps you.
Comment 3 Glenn Adams 2012-04-01 06:27:32 UTC
batch transition pre-FOP1.0 resolved+fixed bugs to closed+fixed