Bug 38648 - NPE in PropertyTokenizer.<init> with table-cell property border=inherit
Summary: NPE in PropertyTokenizer.<init> with table-cell property border=inherit
Status: CLOSED FIXED
Alias: None
Product: Fop - Now in Jira
Classification: Unclassified
Component: fo tree (show other bugs)
Version: trunk
Hardware: Other All
: P2 normal
Target Milestone: ---
Assignee: fop-dev
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-15 04:48 UTC by Nils Meier
Modified: 2012-04-01 06:29 UTC (History)
0 users



Attachments
test input with simple table using border=inherit in cells (758 bytes, text/plain)
2006-02-15 04:50 UTC, Nils Meier
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nils Meier 2006-02-15 04:48:53 UTC
I'm running the attached simply xsl-fo (foo.xml) through the FOTreeBuilder -
with "border=inherit" this fails because of a NPE below.

Somehow org.apache.fop.fo.properties.PropertyMaker.make(PropertyMaker.java:391)
passes a defaultValue=null down the line which doesn't fare well.

Thanks
Nils

----

java.lang.NullPointerException
	at org.apache.fop.fo.expr.PropertyTokenizer.<init>(PropertyTokenizer.java:67)
	at org.apache.fop.fo.expr.PropertyParser.<init>(PropertyParser.java:103)
	at org.apache.fop.fo.expr.PropertyParser.parse(PropertyParser.java:88)
	at org.apache.fop.fo.properties.PropertyMaker.make(PropertyMaker.java:423)
	at org.apache.fop.fo.properties.PropertyMaker.make(PropertyMaker.java:391)
	at org.apache.fop.fo.properties.PropertyMaker.get(PropertyMaker.java:298)
	at org.apache.fop.fo.PropertyList.get(PropertyList.java:171)
	at org.apache.fop.fo.StaticPropertyList.get(StaticPropertyList.java:71)
	at org.apache.fop.fo.PropertyList.get(PropertyList.java:152)
	at org.apache.fop.fo.PropertyList.getFromParent(PropertyList.java:208)
	at org.apache.fop.fo.properties.PropertyMaker.make(PropertyMaker.java:412)
	at org.apache.fop.fo.PropertyList.convertAttributeToProperty(PropertyList.java:344)
	at org.apache.fop.fo.PropertyList.addAttributesToList(PropertyList.java:300)
	at org.apache.fop.fo.FObj.processNode(FObj.java:118)
	at org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:216)
Comment 1 Nils Meier 2006-02-15 04:50:42 UTC
Created attachment 17700 [details]
test input with simple table using border=inherit in cells
Comment 2 Jeremias Maerki 2006-02-15 08:53:17 UTC
Hmm, surrounding the code in the PropertyTokenizer's constructor with an "if (s
!= null)" fixes the NPE, but "inherit" still doesn't work because only the
direct parent gets evaluated. The property value is not properly inherited.
Looks like this will need further inspection.

Work-around for now: Explicitely specify the border property on every
table-cell. Use attribute-sets in XSLT.
Comment 3 Andreas L. Delmelle 2006-02-15 11:02:03 UTC
I'll have a look at that, since I'm currently active in that part of the source code...

For now: the only real problem here is that if border has a value of "inherit", then only the parent is 
checked. Which is correct, since the border shorthand is a non-inherited property. Since there are no 
borders specified on the table-row (and the table-body), there is no border to be inherited.

The error message, however, is confusing and misleading for the end-user, so this definitely needs to 
be looked at.

Another possible workaround is to use: border="from-nearest-specified-value()" on the table-cells. I 
have tried this, and it seems to work nicely... Haven't checked the results yet, but might be an option 
for Nils.

Cheers,

Andreas
Comment 4 Jeremias Maerki 2006-02-15 11:07:39 UTC
Argh, missed that. I thought "inherit" meant the same as
from-nearest-specified-value(), not as from-parent(). D'oh! Thanks for setting
me straight.
Comment 5 Andreas L. Delmelle 2006-02-15 11:58:07 UTC
FWIW: I still stumble over these inheritance issues myself from time to time... :-)

I think the cause for the NPE being thrown is the fact that there is no default set on the PropertyMaker for 
the border shorthand (see: FOPropertyMapping.createShorthandProperties()). As such, the call to 
PropertyList.getFromParent() returns null (instead of, say, an empty string "") This leads to 
PropertyMaker.make() trying to run that null value through the PropertyParser, and the parser chokes on it.

I'll add this ASAP, but would like to add a little warning as well. 
Something like: "Specified value of 'inherit', but the property was not found on the parent... Using default 
value."
Comment 6 Andreas L. Delmelle 2006-02-15 14:11:03 UTC
Added a default value of "" to avoid the NPE being thrown.

Still TODO: add the warning. Property now silently falls back to the default value...

Main issue is fixed: FOP doesn't crash anymore in this case.

See: http://svn.apache.org/viewcvs?rev=378003&view=rev
Comment 7 Nils Meier 2006-02-15 15:01:36 UTC
(In reply to comment #3)
> For now: the only real problem here is that if border has 
> a value of "inherit", then only the parent is checked. 
> Which is correct, since the border shorthand is a 
> non-inherited property. Since there are no borders specified 
> on the table-row (and the table-body), there is no border to 
> be inherited.

just to clarify - there's a border property on the 'table'.
That doesn't count for inherit? I can't specify a border on
'table-body' because with border-collapse="separate" FOP 
reports "borders cannot be specified on a fo:table-body".

I know I can set the border on each cell but i wanted to 
not repeat that border property if i don't have to :)

Thanks
Nils
Comment 8 Andreas L. Delmelle 2006-02-15 15:11:30 UTC
Nils,

Your comment is correct. Because border (just like the individual border-* properties) is not an 
inherited property, the value is not automatically inherited by the descendant table-body and table-
row. So, the property gets its default/initial value on the table-row --null in this case, but this has been 
rectified-- and that value is then inherited by the table-cell.

The only ways I see to avoid having to specify border="inherit" on the intermediate table-body and 
table-row, is to follow either my suggestion, and use border="from-nearest-specified-value()" or 
Jeremias' option of repeating the border specs on every table-cell.

Cheers,

Andreas
Comment 9 Andreas L. Delmelle 2006-02-15 15:16:17 UTC
Just thought of a third option: use border="inherit" on the table-columns --they will inherit the table's 
borders--, and have the table-cells get that value through border="from-table-column()"
Comment 10 Glenn Adams 2012-04-01 06:29:56 UTC
batch transition pre-FOP1.0 resolved+fixed bugs to closed+fixed