[ https://issues.apache.org/jira/browse/VELOCITY-809?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Claude Brisson resolved VELOCITY-809. ------------------------------------- Resolution: Fixed Fixed by commit 1752790. > RuntimeInstance returns template with incorrect encoding (if not specified) > when not initialized before > ------------------------------------------------------------------------------------------------------- > > Key: VELOCITY-809 > URL: https://issues.apache.org/jira/browse/VELOCITY-809 > Project: Velocity > Issue Type: Bug > Components: Engine > Affects Versions: 1.7 > Reporter: Dark Mortal > > 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); > } -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@velocity.apache.org For additional commands, e-mail: dev-h...@velocity.apache.org