Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
1.7
-
None
-
None
Description
RuntimeInstance has
public Template getTemplate(String name)
throws ResourceNotFoundException, ParseErrorException
{
return getTemplate(name, getDefaultEncoding());
}
so if RuntimeInstance was not initialized before this method was called then it provides default encoding (ENCODING_DEFAULT = "ISO-8859-1") for getDefaultEncoding() instead of those that was set using
.setProperty(RuntimeConstants.INPUT_ENCODING, "UTF-8")
and Template contents incorrectly loaded.
This is so because initialization is done one step after a call of getDefaultEncoding() inside method
public Template getTemplate(String name, String encoding)
throws ResourceNotFoundException, ParseErrorException
{
requireInitialization();
return (Template)
resourceManager.getResource(name,
ResourceManager.RESOURCE_TEMPLATE, encoding);
}
Solution is to add requireInitialization(); before return getTemplate(name, getDefaultEncoding()); line in the first method.
OR
accept encoding == null in the second method:
public Template getTemplate(String name)
throws ResourceNotFoundException, ParseErrorException
{
return getTemplate(name, null);
}
public Template getTemplate(String name, String encoding)
throws ResourceNotFoundException, ParseErrorException
{
requireInitialization();
if (encoding == null)
encoding = getDefaultEncoding();
return (Template)
resourceManager.getResource(name,
ResourceManager.RESOURCE_TEMPLATE, encoding);
}