[stringtemplate-interest] StringTemplateGroup attribute renderer bug + fix

VAUCHER Laurent VAUCHER at fermat.fr
Fri Oct 14 01:49:42 PDT 2005


  This morning (UTC+1) I tried to add my own AttributeRenderer to a
StringTemplateGroup, and had the unpleasant suprise to receive a
NullPointerException. After reading the code, it seems that a group
where one attribute renderer is registered must either define renderes
for all possible attribute types, or have a super group that does. I
would have thought that in this case, the standard default renderer
would be used, and since the result is an NPE, it might only be an
edge-case that escaped.

  Therefore, I successfully made a patch to StringTemplateGroup.java,
around line 594 :


	if ( renderer==null ) {
+		if ( superGroup==null ) {
+			return null; // no parent?  Stop.
+		}
		// no renderer registered for this class, check super
group
		renderer =
superGroup.getAttributeRenderer(attributeClassType);
	}


Laurent.



More information about the stringtemplate-interest mailing list