freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ddek...@apache.org
Subject [3/3] incubator-freemarker git commit: Removed the static default Configuration instance. (It's not possible to create a template with null Configuration constructor argument anymore.)
Date Mon, 20 Feb 2017 21:52:38 GMT
Removed the static default Configuration instance. (It's not possible to create a template
with null Configuration constructor argument anymore.)


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

Branch: refs/heads/3
Commit: ddc907ddfd1ceb13f24c746a17faa274a1c4bbb2
Parents: c9719cb
Author: ddekany <ddekany@apache.org>
Authored: Mon Feb 20 22:52:28 2017 +0100
Committer: ddekany <ddekany@apache.org>
Committed: Mon Feb 20 22:52:28 2017 +0100

----------------------------------------------------------------------
 .../apache/freemarker/core/Configuration.java   | 49 --------------------
 .../org/apache/freemarker/core/Template.java    |  8 +---
 src/manual/en_US/FM3-CHANGE-LOG.txt             |  4 +-
 3 files changed, 5 insertions(+), 56 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ddc907dd/src/main/java/org/apache/freemarker/core/Configuration.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/Configuration.java b/src/main/java/org/apache/freemarker/core/Configuration.java
index 3c64c1f..2d15987 100644
--- a/src/main/java/org/apache/freemarker/core/Configuration.java
+++ b/src/main/java/org/apache/freemarker/core/Configuration.java
@@ -404,10 +404,6 @@ public class Configuration extends Configurable implements Cloneable,
ParserConf
         }
     }
     
-    private final static Object defaultConfigLock = new Object();
-
-    private static volatile Configuration defaultConfig;
-
     private volatile boolean localizedLookup = true;
     private boolean whitespaceStripping = true;
     private int autoEscapingPolicy = ENABLE_IF_DEFAULT_AUTO_ESCAPING_POLICY;
@@ -709,51 +705,6 @@ public class Configuration extends Configurable implements Cloneable,
ParserConf
     public void clearEncodingMap() {
         localeToCharsetMap.clear();
     }
-
-    /**
-     * Returns the default (singleton) Configuration object. Note that you can
-     * create as many separate configurations as you wish; this global instance
-     * is provided for convenience, or when you have no reason to use a separate
-     * instance.
-     * 
-     * @deprecated The usage of the static singleton (the "default")
-     * {@link Configuration} instance can easily cause erroneous, unpredictable
-     * behavior. This is because multiple independent software components may use
-     * FreeMarker internally inside the same application, so they will interfere
-     * because of the common {@link Configuration} instance. Each such component
-     * should use its own private {@link Configuration} object instead, that it
-     * typically creates with <code>new Configuration()</code> when the component
-     * is initialized.
-     */
-    @Deprecated
-    static public Configuration getDefaultConfiguration() {
-        Configuration defaultConfig = Configuration.defaultConfig;
-        if (defaultConfig == null) {
-            synchronized (defaultConfigLock) {
-                defaultConfig = Configuration.defaultConfig;
-                if (defaultConfig == null) {
-                    defaultConfig = new Configuration();
-                    Configuration.defaultConfig = defaultConfig; 
-                }
-            }
-        }
-        return defaultConfig;
-    }
-
-    /**
-     * Sets the Configuration object that will be retrieved from future calls
-     * to {@link #getDefaultConfiguration()}.
-     * 
-     * @deprecated Using the "default" {@link Configuration} instance can
-     * easily lead to erroneous, unpredictable behaviour.
-     * See more {@link Configuration#getDefaultConfiguration() here...}.
-     */
-    @Deprecated
-    static public void setDefaultConfiguration(Configuration config) {
-        synchronized (defaultConfigLock) {
-            defaultConfig = config;
-        }
-    }
     
     /**
      * Sets a {@link TemplateLoader} that is used to look up and load templates;

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ddc907dd/src/main/java/org/apache/freemarker/core/Template.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/Template.java b/src/main/java/org/apache/freemarker/core/Template.java
index d9fa398..113f9ea 100644
--- a/src/main/java/org/apache/freemarker/core/Template.java
+++ b/src/main/java/org/apache/freemarker/core/Template.java
@@ -115,9 +115,7 @@ public class Template extends Configurable {
      */
     private Template(String name, String sourceName, Configuration cfg, ParserConfiguration
customParserConfiguration) {
         super(cfg);
-        if (cfg == null) {
-            throw new IllegalArgumentException("\"cfg\" can't be null");
-        }
+        _NullArgumentException.check("cfg", cfg);
         this.name = name;
         this.sourceName = sourceName;
         templateLanguageVersion = normalizeTemplateLanguageVersion(cfg.getIncompatibleImprovements());
@@ -177,9 +175,7 @@ public class Template extends Configurable {
      *            {@link StringReader} need not be closed.) The {@link Reader} need not be
buffered, because this
      *            method ensures that it will be read in few kilobyte chunks, not byte by
byte.
      * @param cfg
-     *            The Configuration object that this Template is associated with. If this
is {@code null}, the "default"
-     *            {@link Configuration} object is used, which is highly discouraged, because
it can easily lead to
-     *            erroneous, unpredictable behavior. (See more {@link Configuration#getDefaultConfiguration()
here...})
+     *            The Configuration object that this Template is associated with. Can't be
{@code null}.
      * 
      * @since 2.3.22
      */

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ddc907dd/src/manual/en_US/FM3-CHANGE-LOG.txt
----------------------------------------------------------------------
diff --git a/src/manual/en_US/FM3-CHANGE-LOG.txt b/src/manual/en_US/FM3-CHANGE-LOG.txt
index 6e6aae2..6c4f610 100644
--- a/src/manual/en_US/FM3-CHANGE-LOG.txt
+++ b/src/manual/en_US/FM3-CHANGE-LOG.txt
@@ -107,4 +107,6 @@ the FreeMarer 3 changelog here:
     project, these were removed. Static methods that simplify an already loaded DOM have
remained, because that's
     FreeMarker-specific functionality.
   - Removed parameterless DefaultObjectWrapper and BeansWrapper constructors. Now specifying
the
-    incomplatibleImprovement version is required.
\ No newline at end of file
+    incomplatibleImprovement version is required.
+  - Removed the static default Configuration instance. (It's not possible to create a template
with null Configuration
+    constructor argument anymore.)
\ No newline at end of file


Mime
View raw message