SOLR-7972: Fix VelocityResponseWriter template encoding issue

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1697789 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Erik Hatcher 2015-08-26 00:15:18 +00:00
parent a65779666d
commit 306d7f4198
4 changed files with 11 additions and 0 deletions

View File

@ -153,6 +153,9 @@ Bug Fixes
* SOLR-7956: There are interrupts on shutdown in places that can cause ChannelAlreadyClosed
exceptions which prevents proper closing of transaction logs. (Mark Miller)
* SOLR-7972: Fix VelocityResponseWriter template encoding issue.
Templates must be UTF-8 encoded. (Erik Hatcher)
Optimizations
----------------------

View File

@ -284,6 +284,8 @@ public class VelocityResponseWriter implements QueryResponseWriter, SolrCoreAwar
engine.setProperty(RuntimeConstants.RESOURCE_LOADER, StringUtils.join(loaders,','));
engine.setProperty(RuntimeConstants.INPUT_ENCODING, "UTF-8");
// bring in any custom properties too
engine.init(velocityInitProps);

View File

@ -92,6 +92,11 @@ public class VelocityResponseWriterTest extends SolrTestCaseJ4 {
assertEquals("0", h.query(req("q","*:*", "wt","velocity",VelocityResponseWriter.TEMPLATE,"numFound")));
}
@Test
public void testEncoding() throws Exception {
assertEquals("éñçø∂îñg", h.query(req("q","*:*", "wt","velocity",VelocityResponseWriter.TEMPLATE,"encoding")));
}
@Test
public void testMacros() throws Exception {
// tests that a macro in a custom macros.vm is visible