SOLR-13351: Workaround for VELOCITY-908

Signed-off-by: Kevin Risden <krisden@apache.org>
This commit is contained in:
Kevin Risden 2019-03-27 17:42:15 -04:00
parent 98cadcf9f6
commit 90d983cf7c
No known key found for this signature in database
GPG Key ID: 040FAE3292C5F73F
2 changed files with 18 additions and 1 deletions

View File

@ -142,7 +142,9 @@ Bug Fixes
"shareSchema" and other circumstances occur. Furthermore it's reference to SolrConfig was removed. (David Smiley)
* SOLR-7414: CSVResponseWriter & XLSXResponseWriter return empty field when fl alias is combined with '*' selector
(Michael Lawrence, Munendra S N, Ishan Chattopadhyaya)
(Michael Lawrence, Munendra S N, Ishan Chattopadhyaya)
* SOLR-13351: Workaround for VELOCITY-908 (Kevin Risden)
Improvements
----------------------

View File

@ -26,6 +26,7 @@ import java.lang.invoke.MethodHandles;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.ResourceBundle;
@ -333,6 +334,20 @@ public class VelocityResponseWriter implements QueryResponseWriter, SolrCoreAwar
engine.setProperty(RuntimeConstants.INPUT_ENCODING, "UTF-8");
// Work around VELOCITY-908 with Velocity not handling locales properly
Object spaceGobblingInitProperty = velocityInitProps.get(RuntimeConstants.SPACE_GOBBLING);
if(spaceGobblingInitProperty != null) {
// If there is an init property, uppercase it before Velocity.
velocityInitProps.put(RuntimeConstants.SPACE_GOBBLING,
String.valueOf(spaceGobblingInitProperty).toUpperCase(Locale.ROOT));
} else {
// Fallback to checking if the engine default property is set and if not make it a reasonable default.
Object spaceGobblingEngineProperty = engine.getProperty(RuntimeConstants.SPACE_GOBBLING);
if(spaceGobblingEngineProperty == null) {
engine.setProperty(RuntimeConstants.SPACE_GOBBLING, RuntimeConstants.SpaceGobbling.LINES.toString());
}
}
// bring in any custom properties too
engine.init(velocityInitProps);