}
}
if (templateResolution == null || templateInputStream == null) {
throw new TemplateInputException(
"Error resolving template \"" + templateProcessingParameters.getTemplateName() + "\", " +
"template might not exist or might not be accessible by " +
"any of the configured Template Resolvers");
}
final String templateMode = templateResolution.getTemplateMode();
final ITemplateParser templateParser = this.parsersByTemplateMode.get(templateMode);
if (templateParser == null) {
throw new TemplateInputException(
"Template mode \"" + templateMode + "\" has not been configured");
}
if (logger.isTraceEnabled()) {
logger.trace("[THYMELEAF][{}] Starting parsing of template \"{}\"", TemplateEngine.threadIndex(), templateName);
}
final String characterEncoding = templateResolution.getCharacterEncoding();
Reader reader = null;
if (!StringUtils.isEmptyOrWhitespace(characterEncoding)) {
try {
reader = new InputStreamReader(templateInputStream, characterEncoding);
} catch (final UnsupportedEncodingException e) {
throw new TemplateInputException("Exception parsing document", e);
}
} else {
reader = new InputStreamReader(templateInputStream);
}