Be more robust about closing template Reader.
Also some tidying: we don't like tabs or trailing whitespace.
This commit is contained in:
@@ -741,16 +741,22 @@ public class Mustache
|
||||
// we compile our template lazily to avoid infinie recursion if a template includes
|
||||
// itself (see issue #13)
|
||||
if (_template == null) {
|
||||
Reader tin = null;
|
||||
try {
|
||||
Reader t = _comp.loader.getTemplate(_name);
|
||||
_template = _comp.compile(t);
|
||||
t.close();
|
||||
tin = _comp.loader.getTemplate(_name);
|
||||
_template = _comp.compile(tin);
|
||||
} catch (Exception e) {
|
||||
if (e instanceof RuntimeException) {
|
||||
throw (RuntimeException)e;
|
||||
} else {
|
||||
throw new MustacheException("Unable to load template: " + _name, e);
|
||||
}
|
||||
} finally {
|
||||
if (tin != null) try {
|
||||
tin.close();
|
||||
} catch (IOException ioe) {
|
||||
throw new RuntimeException(ioe);
|
||||
}
|
||||
}
|
||||
}
|
||||
// we must take care to preserve our context rather than creating a new one, which
|
||||
|
||||
Reference in New Issue
Block a user