freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ddek...@apache.org
Subject incubator-freemarker git commit: Changed the default of sqlDateAndTimeTimeZone (sql_date_and_time_time_zone) to TimeZone.default() from null (where null meant falling back to the timeZone setting value).
Date Mon, 12 Jun 2017 21:55:17 GMT
Repository: incubator-freemarker
Updated Branches:
  refs/heads/3 0a60fc618 -> 4a79ad8a4


Changed the default of sqlDateAndTimeTimeZone (sql_date_and_time_time_zone) to TimeZone.default()
from null (where null meant falling back to the timeZone setting value).


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

Branch: refs/heads/3
Commit: 4a79ad8a4db558dcff7e7ea4194772b7550b1ddf
Parents: 0a60fc6
Author: ddekany <ddekany@apache.org>
Authored: Mon Jun 12 23:55:10 2017 +0200
Committer: ddekany <ddekany@apache.org>
Committed: Mon Jun 12 23:55:10 2017 +0200

----------------------------------------------------------------------
 FM3-CHANGE-LOG.txt                                      |  6 ++++--
 .../core/MutableProcessingConfigurationTest.java        |  9 +++++++--
 .../org/apache/freemarker/core/SQLTimeZoneTest.java     |  7 +++++--
 .../core/templatesuite/CoreTemplateTestSuite.java       |  3 +++
 .../java/org/apache/freemarker/core/Configuration.java  |  2 +-
 .../apache/freemarker/core/ProcessingConfiguration.java | 12 ++++++------
 6 files changed, 26 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4a79ad8a/FM3-CHANGE-LOG.txt
----------------------------------------------------------------------
diff --git a/FM3-CHANGE-LOG.txt b/FM3-CHANGE-LOG.txt
index a8f3089..e73dbad 100644
--- a/FM3-CHANGE-LOG.txt
+++ b/FM3-CHANGE-LOG.txt
@@ -262,12 +262,14 @@ the FreeMarer 3 changelog here:
 - Renamed the `cacheStorage` Configuration setting to `templateCacheStorage`.
 - 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.
+  - 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.
   - Changed the default of templateExceptionHandler (template_exception_hander) to
-    TemplateExceptionHandler.RETHROW_HANDLER
+    TemplateExceptionHandler.RETHROW_HANDLER from DEBUG_HANDLER
+  - Changed the default of sqlDateAndTimeTimeZone (sql_date_and_time_time_zone) to
+    TimeZone.default() from null (where null meant falling back to the timeZone setting value)
 - Removed the logTemplateExceptions (log_template_exceptions) setting. FreeMarker now
   behaves as if it was false. When a FreeMarker method throws an exception, the
   caller is responsible for either logging it or letting it bubble up.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4a79ad8a/freemarker-core-test/src/test/java/org/apache/freemarker/core/MutableProcessingConfigurationTest.java
----------------------------------------------------------------------
diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/MutableProcessingConfigurationTest.java
b/freemarker-core-test/src/test/java/org/apache/freemarker/core/MutableProcessingConfigurationTest.java
index 718bc76..4295e17 100644
--- a/freemarker-core-test/src/test/java/org/apache/freemarker/core/MutableProcessingConfigurationTest.java
+++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/MutableProcessingConfigurationTest.java
@@ -278,7 +278,7 @@ public class MutableProcessingConfigurationTest {
             TimeZone.setDefault(sysDefTZ);
 
             Configuration.Builder cfgB = new Configuration.Builder(Configuration.VERSION_3_0_0);
-            assertNull(cfgB.getSQLDateAndTimeTimeZone());
+            assertEquals(sysDefTZ, cfgB.getSQLDateAndTimeTimeZone());
 
             cfgB.setSQLDateAndTimeTimeZone(null);
             assertNull(cfgB.getSQLDateAndTimeTimeZone());
@@ -288,6 +288,9 @@ public class MutableProcessingConfigurationTest {
 
             cfgB.setSetting(MutableProcessingConfiguration.SQL_DATE_AND_TIME_TIME_ZONE_KEY,
"null");
             assertNull(cfgB.getSQLDateAndTimeTimeZone());
+
+            cfgB.unsetSQLDateAndTimeTimeZone();
+            assertEquals(sysDefTZ, cfgB.getSQLDateAndTimeTimeZone());
         } finally {
             TimeZone.setDefault(origSysDefTZ);
         }
@@ -298,7 +301,9 @@ public class MutableProcessingConfigurationTest {
         TimeZone localTZ = TimeZone.getTimeZone("Europe/Brussels");
 
         {
-            Configuration cfg = new Configuration.Builder(Configuration.VERSION_3_0_0).build();
+            Configuration cfg = new Configuration.Builder(Configuration.VERSION_3_0_0)
+                    .sqlDateAndTimeTimeZone(null)
+                    .build();
             Template t = new Template(null, "", cfg);
             Environment env1 = t.createProcessingEnvironment(null, new StringWriter());
             Environment env2 = t.createProcessingEnvironment(null, new StringWriter());

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4a79ad8a/freemarker-core-test/src/test/java/org/apache/freemarker/core/SQLTimeZoneTest.java
----------------------------------------------------------------------
diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/SQLTimeZoneTest.java
b/freemarker-core-test/src/test/java/org/apache/freemarker/core/SQLTimeZoneTest.java
index c9877ca..7aca106 100644
--- a/freemarker-core-test/src/test/java/org/apache/freemarker/core/SQLTimeZoneTest.java
+++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/SQLTimeZoneTest.java
@@ -139,6 +139,7 @@ public class SQLTimeZoneTest extends TemplateTest {
         TimeZone.setDefault(GMT_P02);
         try {
             Configuration.ExtendableBuilder<?> cfgB = createConfigurationBuilder();
+            cfgB.setSQLDateAndTimeTimeZone(null);
             cfgB.unsetTimeZone();
             setConfiguration(cfgB.build());
 
@@ -170,6 +171,7 @@ public class SQLTimeZoneTest extends TemplateTest {
     public void testWithGMT1AndNullSQL() throws Exception {
         setConfiguration(createConfigurationBuilder()
                 .timeZone(TimeZone.getTimeZone("GMT+01:00"))
+                .sqlDateAndTimeTimeZone(null)
                 .build());
         assertNull(getConfiguration().getSQLDateAndTimeTimeZone());
 
@@ -190,6 +192,7 @@ public class SQLTimeZoneTest extends TemplateTest {
     public void testWithGMT2AndNullSQL() throws Exception {
         setConfiguration(createConfigurationBuilder()
                 .timeZone(TimeZone.getTimeZone("GMT+02"))
+                .sqlDateAndTimeTimeZone(null)
                 .build());
         assertNull(getConfiguration().getSQLDateAndTimeTimeZone());
 
@@ -264,6 +267,7 @@ public class SQLTimeZoneTest extends TemplateTest {
     private Configuration.ExtendableBuilder<?> testCacheFlushing_createBuilder() {
         return createConfigurationBuilder()
                 .timeZone(_DateUtil.UTC)
+                .sqlDateAndTimeTimeZone(null) // Default from FM2...
                 .dateFormat("yyyy-MM-dd E")
                 .timeFormat("HH:mm:ss E")
                 .dateTimeFormat("yyyy-MM-dd'T'HH:mm:ss E");
@@ -294,10 +298,9 @@ public class SQLTimeZoneTest extends TemplateTest {
     public void testChangeSettingInTemplate() throws Exception {
         setConfiguration(createConfigurationBuilder()
                 .timeZone(_DateUtil.UTC)
+                .sqlDateAndTimeTimeZone(null)
                 .build());
 
-        assertNull(getConfiguration().getSQLDateAndTimeTimeZone());
-
         assertOutput(
                 "${sqlDate}, ${sqlTime}, ${sqlTimestamp}, ${javaDate?datetime}\n"
                 + "<#setting sql_date_and_time_time_zone='GMT+02'>\n"

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4a79ad8a/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/CoreTemplateTestSuite.java
----------------------------------------------------------------------
diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/CoreTemplateTestSuite.java
b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/CoreTemplateTestSuite.java
index b3103b0..2adef86 100644
--- a/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/CoreTemplateTestSuite.java
+++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/CoreTemplateTestSuite.java
@@ -114,6 +114,7 @@ public class CoreTemplateTestSuite extends TemplateTestSuite {
             });
             dataModel.put("sqlDate", new java.sql.Date(1273955885023L));
             dataModel.put("sqlTime", new java.sql.Time(74285023L));
+            confB.setSQLDateAndTimeTimeZone(null); // Default in FM2, when the tests were
written
         } else if (simpleTestName.startsWith("list-") || simpleTestName.startsWith("list[")
                 || simpleTestName.startsWith("list2[") || simpleTestName.startsWith("list3[")
                 || simpleTestName.equals("listhash")) {
@@ -170,6 +171,8 @@ public class CoreTemplateTestSuite extends TemplateTestSuite {
             dataModel.put("timeOnly", new java.sql.Time(d.getTime()));
             dataModel.put("dateOnly", new java.sql.Date(d.getTime()));
             dataModel.put("dateTime", new java.sql.Timestamp(d.getTime()));
+
+            confB.setSQLDateAndTimeTimeZone(null); // Default in FM2, when the tests were
written
         } else if (simpleTestName.equals("var-layers")) {
             dataModel.put("x", Integer.valueOf(4));
             dataModel.put("z", Integer.valueOf(4));

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4a79ad8a/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 5f86a8a..d370479 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
@@ -2591,7 +2591,7 @@ public final class Configuration implements TopLevelConfiguration, CustomStateSc
 
         @Override
         protected TimeZone getDefaultSQLDateAndTimeTimeZone() {
-            return null;
+            return TimeZone.getDefault();
         }
 
         @Override

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4a79ad8a/freemarker-core/src/main/java/org/apache/freemarker/core/ProcessingConfiguration.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/ProcessingConfiguration.java
b/freemarker-core/src/main/java/org/apache/freemarker/core/ProcessingConfiguration.java
index be875a4..f600643 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/ProcessingConfiguration.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ProcessingConfiguration.java
@@ -89,12 +89,12 @@ public interface ProcessingConfiguration {
 
     /**
      * The time zone used when dealing with {@link java.sql.Date java.sql.Date} and
-     * {@link java.sql.Time java.sql.Time} values. Its {@link Configuration}-level defaults
is {@code null} for
-     * backward compatibility, but in most applications this should be set to the JVM default
time zone (server
-     * default time zone), because that's what most JDBC drivers will use when constructing
the
-     * {@link java.sql.Date java.sql.Date} and {@link java.sql.Time java.sql.Time} values.
If this setting is {@code
-     * null} FreeMarker will use the value of ({@link #getTimeZone()}) for {@link java.sql.Date
java.sql.Date} and
-     * {@link java.sql.Time java.sql.Time} values, which often gives bad results.
+     * {@link java.sql.Time java.sql.Time} values. Its {@link Configuration}-level defaults
is
+     * {@link TimeZone#getDefault()}, that is, the JVM default time zone (server default
time zone), because that's
+     * what most JDBC drivers will use when constructing the {@link java.sql.Date java.sql.Date}
and
+     * {@link java.sql.Time java.sql.Time} values. If this setting is {@code null} FreeMarker
will use the value of
+     * ({@link #getTimeZone()}) for {@link java.sql.Date java.sql.Date} and {@link java.sql.Time
java.sql.Time}
+     * values, which often gives bad results due to how most JDBC drivers work.
      *
      * <p>This setting doesn't influence the formatting of other kind of values (like
of
      * {@link java.sql.Timestamp java.sql.Timestamp} or plain {@link java.util.Date java.util.Date}
values).


Mime
View raw message