Repository: incubator-freemarker
Updated Branches:
  refs/heads/3 52faf3e73 -> 04898a206


Changed the default of sourceEncoding ("encoding" earlier) to UTF-8 from the 
platform default charset. Using the platform default charset was proven to be 
fragile in practice, like applications could break when moved to another server 
if the application  was unwillingly relying on the default.


Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/04898a20
Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/04898a20
Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/04898a20

Branch: refs/heads/3
Commit: 04898a20635cc46fd5fa971476683bb0ac31e5f7
Parents: 52faf3e
Author: ddekany <[email protected]>
Authored: Mon Jun 12 18:47:23 2017 +0200
Committer: ddekany <[email protected]>
Committed: Mon Jun 12 18:47:47 2017 +0200

----------------------------------------------------------------------
 FM3-CHANGE-LOG.txt                                        |  9 +++++++--
 .../MutableParsingAndProcessingConfigurationTest.java     | 10 ++++------
 .../java/org/apache/freemarker/core/Configuration.java    |  3 ++-
 .../org/apache/freemarker/core/ParsingConfiguration.java  |  4 +---
 .../apache/freemarker/test/TestConfigurationBuilder.java  |  7 -------
 5 files changed, 14 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/04898a20/FM3-CHANGE-LOG.txt
----------------------------------------------------------------------
diff --git a/FM3-CHANGE-LOG.txt b/FM3-CHANGE-LOG.txt
index dbaef97..f6e7a66 100644
--- a/FM3-CHANGE-LOG.txt
+++ b/FM3-CHANGE-LOG.txt
@@ -96,7 +96,6 @@ the FreeMarer 3 changelog here:
 - Deleted o.a.f.core.util.DOMNodeModel (it has noting to do with the standard 
XML support, o.a.f.core.model.dom)
 - All CacheStorage-s must be thread safe from now on (removed 
ConcurrentCacheStorage marker interface)
 - Removed support for incompatibleImprovements before 3.0.0. So currently 
3.0.0 is the only support value.
-- Changed the default of logTemplateExceptions to false.
 - Removed `String Configurable.getSetting(String)` and `Properties 
getSettings()`. It has never worked well,
   and is impossible to implement properly.
 - Even for setting values that are class names without following `()` or other 
argument list, the INSTANCE field and
@@ -261,4 +260,10 @@ the FreeMarer 3 changelog here:
   - FM2 Configuration.${c}_TAG_SYNTAX with TagSyntax.${c}
   - FM2 Configuration.${c}_AUTO_ESCAPING_POLICY with AutoEscapingPolicy.${c}
 - Renamed the `cacheStorage` Configuration setting to `templateCacheStorage`.
-- Renamed the `localizedLookup` Configuration setting to `localizedLookup`.
\ No newline at end of file
+- Renamed the `localizedLookup` Configuration setting to `localizedLookup`.
+- Changed the defaults of some Configuration settings:
+  - sourceEncoding ("encoding" earlier) to UTF-8 from the platform default 
charset.
+    Using the platform default charset was proven to be fragile in practice,
+    like applications could break when moved to another server if the 
application
+    was unwillingly relying on the default.
+  - Changed the default of logTemplateExceptions to false.

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/04898a20/freemarker-core-test/src/test/java/org/apache/freemarker/core/MutableParsingAndProcessingConfigurationTest.java
----------------------------------------------------------------------
diff --git 
a/freemarker-core-test/src/test/java/org/apache/freemarker/core/MutableParsingAndProcessingConfigurationTest.java
 
b/freemarker-core-test/src/test/java/org/apache/freemarker/core/MutableParsingAndProcessingConfigurationTest.java
index 689d600..2e96c18 100644
--- 
a/freemarker-core-test/src/test/java/org/apache/freemarker/core/MutableParsingAndProcessingConfigurationTest.java
+++ 
b/freemarker-core-test/src/test/java/org/apache/freemarker/core/MutableParsingAndProcessingConfigurationTest.java
@@ -262,17 +262,15 @@ public class MutableParsingAndProcessingConfigurationTest 
{
     public void testSourceEncodingSetting() throws TemplateException, 
ConfigurationException {
         Configuration.Builder cfgB = new 
Configuration.Builder(Configuration.VERSION_3_0_0);
 
-        assertEquals(Charset.defaultCharset(), cfgB.getSourceEncoding());
+        assertEquals(StandardCharsets.UTF_8, cfgB.getSourceEncoding());
         assertFalse(cfgB.isSourceEncodingSet());
 
-        Charset nonDefault = 
Charset.defaultCharset().equals(StandardCharsets.UTF_8) ? 
StandardCharsets.ISO_8859_1
-                : StandardCharsets.UTF_8;
-        cfgB.setSourceEncoding(nonDefault);
+        cfgB.setSourceEncoding(StandardCharsets.ISO_8859_1);
         assertTrue(cfgB.isSourceEncodingSet());
-        assertEquals(nonDefault, cfgB.getSourceEncoding());
+        assertEquals(StandardCharsets.ISO_8859_1, cfgB.getSourceEncoding());
 
         cfgB.unsetSourceEncoding();
-        assertEquals(Charset.defaultCharset(), cfgB.getSourceEncoding());
+        assertEquals(StandardCharsets.UTF_8, cfgB.getSourceEncoding());
         assertFalse(cfgB.isSourceEncodingSet());
 
         cfgB.setSetting(Configuration.ExtendableBuilder.SOURCE_ENCODING_KEY, 
"JVM default");

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/04898a20/freemarker-core/src/main/java/org/apache/freemarker/core/Configuration.java
----------------------------------------------------------------------
diff --git 
a/freemarker-core/src/main/java/org/apache/freemarker/core/Configuration.java 
b/freemarker-core/src/main/java/org/apache/freemarker/core/Configuration.java
index 164c8f2..9f5a50e 100644
--- 
a/freemarker-core/src/main/java/org/apache/freemarker/core/Configuration.java
+++ 
b/freemarker-core/src/main/java/org/apache/freemarker/core/Configuration.java
@@ -25,6 +25,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.Serializable;
 import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -2585,7 +2586,7 @@ public final class Configuration implements 
TopLevelConfiguration, CustomStateSc
 
         @Override
         protected Charset getDefaultSourceEncoding() {
-            return Charset.defaultCharset();
+            return StandardCharsets.UTF_8;
         }
 
         @Override

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/04898a20/freemarker-core/src/main/java/org/apache/freemarker/core/ParsingConfiguration.java
----------------------------------------------------------------------
diff --git 
a/freemarker-core/src/main/java/org/apache/freemarker/core/ParsingConfiguration.java
 
b/freemarker-core/src/main/java/org/apache/freemarker/core/ParsingConfiguration.java
index 18e17f6..c5797c7 100644
--- 
a/freemarker-core/src/main/java/org/apache/freemarker/core/ParsingConfiguration.java
+++ 
b/freemarker-core/src/main/java/org/apache/freemarker/core/ParsingConfiguration.java
@@ -252,9 +252,7 @@ public interface ParsingConfiguration {
     /**
      * Sets the charset used for decoding template files.
      * <p>
-     * Defaults to the default system {@code fileEncoding}, which can change 
from one server to
-     * another, so <b>you should always set this setting</b>. If you don't 
know what charset your should chose,
-     * {@code "UTF-8"} is usually a good choice.
+     * Defaults to {@code "UTF-8"}. (On some desktop applications {@link 
Charset#defaultCharset()} is maybe preferable.)
      * <p>
      * When a project contains groups (like folders) of template files where 
the groups use different encodings,
      * consider using the {@link Configuration#getTemplateConfigurations() 
templateConfigurations} setting on the

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/04898a20/freemarker-test-utils/src/main/java/org/apache/freemarker/test/TestConfigurationBuilder.java
----------------------------------------------------------------------
diff --git 
a/freemarker-test-utils/src/main/java/org/apache/freemarker/test/TestConfigurationBuilder.java
 
b/freemarker-test-utils/src/main/java/org/apache/freemarker/test/TestConfigurationBuilder.java
index 7f869db..7cee6f1 100644
--- 
a/freemarker-test-utils/src/main/java/org/apache/freemarker/test/TestConfigurationBuilder.java
+++ 
b/freemarker-test-utils/src/main/java/org/apache/freemarker/test/TestConfigurationBuilder.java
@@ -19,8 +19,6 @@
 
 package org.apache.freemarker.test;
 
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
 import java.util.Locale;
 import java.util.TimeZone;
 
@@ -66,11 +64,6 @@ public class TestConfigurationBuilder extends 
Configuration.ExtendableBuilder<Te
     }
 
     @Override
-    protected Charset getDefaultSourceEncoding() {
-        return StandardCharsets.UTF_8;
-    }
-
-    @Override
     protected TimeZone getDefaultTimeZone() {
         return DEFAULT_TIME_ZONE;
     }

Reply via email to