Issue 57 in json-template: Unbalanced section push and pop in the Java implementation

8 views
Skip to first unread message

json-t...@googlecode.com

unread,
Jul 23, 2010, 3:40:49 PM7/23/10
to json-t...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 57 by louis...@rogers.com: Unbalanced section push and pop in the
Java implementation
http://code.google.com/p/json-template/issues/detail?id=57

When the data is missing for the template section, the
SectionStatement.java caused the exception in public Object
pushSection(String sectionName) of the file ScopedContext.java. It starts
happening for the second section of missing data.
Please see my fix bellow.

Regards,
Louis
///////////////////////////////////////////////////////////

public void execute(ScopedContext context, ITemplateRenderCallback
callback) {
// push a context first
Object cursorPosition = context
.pushSection(this.block.getSectionName());
if (!context.isEmptyContext(cursorPosition)) {
TemplateExecutor.execute(this.block.getStatements(), context,
callback);
//context.pop(); // Louis fix, remove this line
} else {
TemplateExecutor.execute(this.block.getStatements("or"), context,
callback);
}
context.pop(); // Louis fix, add this line
}

////////////////////////////////////////////////////////

json-t...@googlecode.com

unread,
Mar 6, 2012, 2:32:30 AM3/6/12
to json-t...@googlegroups.com

Comment #1 on issue 57 by isungu...@issart.com: Unbalanced section push and

Thanks, Louis, for pointing to issue source. But general problem is that
while processing 'or' statement stack top contains 'null' value. This value
remained after unsuccessful lookup for beginning of 'section' statement and
must be removed before executing 'or' section. So fix should looks like this
///////////////////////////////////////////////////////////

public void execute(ScopedContext context, ITemplateRenderCallback
callback) {
// push a context first
Object cursorPosition = context
.pushSection(this.block.getSectionName());
if (!context.isEmptyContext(cursorPosition)) {
TemplateExecutor.execute(this.block.getStatements(), context,
callback);

context.pop(); // leave as is
} else {
context.pop(); // add this line


TemplateExecutor.execute(this.block.getStatements("or"), context,
callback);
}
}

////////////////////////////////////////////////////////

json-t...@googlecode.com

unread,
Mar 12, 2012, 5:46:33 AM3/12/12
to json-t...@googlegroups.com
Updates:
Status: Fixed

Comment #3 on issue 57 by isungu...@issart.com: Unbalanced section push and

(No comment was entered for this change.)

Reply all
Reply to author
Forward
0 new messages