500.html can produce error

Bug #478315 reported by tomas
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
play framework
Status tracked in 1.0
1.0
Fix Released
Undecided
Nicolas Leroux
1.1
Fix Committed
Undecided
Unassigned

Bug Description

I had several problems in my view, including #(if..} instead of #{if..} and instead of seeing the description of the problem in the browser, I got 'Application error, check logs', here is the exception:
Template execution error (In /app/views/errors/500.html around line 18)
Execution error occured in template /app/views/errors/500.html. Exception raised was IndexOutOfBoundsException : toIndex = 52.

play.exceptions.TemplateExecutionException: toIndex = 52
        at play.templates.Template.throwException(Template.java:263)
        at play.templates.Template.render(Template.java:228)
        at play.server.HttpHandler.serve500(HttpHandler.java:348)
        at Invocation.HTTP Request(Play!)
Caused by: java.lang.IndexOutOfBoundsException: toIndex = 52
        at java.util.SubList.<init>(AbstractList.java:602)
        at java.util.RandomAccessSubList.<init>(AbstractList.java:758)
        at java.util.AbstractList.subList(AbstractList.java:468)
        at /app/views/errors/500.html.(line:18)
        at play.templates.Template.render(Template.java:208)
        ... 2 more

This happened because groovy can pick up wrong line number, in my case it was greater than the number of lines in the file. Replacing line 98 in file 500.html with this fixes the problem - the whole template file would be shown:
from = exception.lineNumber - 5 >= 0 && exception.lineNumber < exception.source.size() ? exception.lineNumber - 5 : 0

Also, on line 105, the 'line' should be escaped:
                    <pre>&nbsp;${line.escapeHtml()}</pre>

I am using r.671
thanks

tomas (gugljafa)
description: updated
Changed in play:
status: New → Confirmed
Changed in play:
assignee: nobody → Nicolas (nicolas-lunatech)
Revision history for this message
Nicolas Leroux (nicolas-lunatech) wrote :

Thanks for the bug report and the solution :)

Changed in play:
status: Confirmed → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.