You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by kr...@apache.org on 2019/03/27 21:43:22 UTC

[lucene-solr] branch jira/solr-13351 created (now 90d983c)

This is an automated email from the ASF dual-hosted git repository.

krisden pushed a change to branch jira/solr-13351
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git.


      at 90d983c  SOLR-13351: Workaround for VELOCITY-908

This branch includes the following new commits:

     new 90d983c  SOLR-13351: Workaround for VELOCITY-908

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[lucene-solr] 01/01: SOLR-13351: Workaround for VELOCITY-908

Posted by kr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

krisden pushed a commit to branch jira/solr-13351
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git

commit 90d983cf7cd8bf867a16fe8916b523d52d72b439
Author: Kevin Risden <kr...@apache.org>
AuthorDate: Wed Mar 27 17:42:15 2019 -0400

    SOLR-13351: Workaround for VELOCITY-908
    
    Signed-off-by: Kevin Risden <kr...@apache.org>
---
 solr/CHANGES.txt                                          |  4 +++-
 .../org/apache/solr/response/VelocityResponseWriter.java  | 15 +++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index c6690cc..0c371e0 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -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
 ----------------------
diff --git a/solr/contrib/velocity/src/java/org/apache/solr/response/VelocityResponseWriter.java b/solr/contrib/velocity/src/java/org/apache/solr/response/VelocityResponseWriter.java
index 9066dc6..828d29b 100644
--- a/solr/contrib/velocity/src/java/org/apache/solr/response/VelocityResponseWriter.java
+++ b/solr/contrib/velocity/src/java/org/apache/solr/response/VelocityResponseWriter.java
@@ -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);