Repository: incubator-freemarker
Updated Branches:
  refs/heads/3 99174103a -> e4207a53e


(Minor code and JavaDoc cleanup...)


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

Branch: refs/heads/3
Commit: e4207a53e390136d427c3e9e26171f4780af3fd6
Parents: 9917410
Author: ddekany <ddek...@apache.org>
Authored: Tue Mar 6 22:16:17 2018 +0100
Committer: ddekany <ddek...@apache.org>
Committed: Tue Mar 6 22:16:17 2018 +0100

----------------------------------------------------------------------
 .../java/org/apache/freemarker/core/Environment.java | 15 +++++----------
 .../org/apache/freemarker/dom/JaxenXPathSupport.java |  4 ++--
 2 files changed, 7 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/e4207a53/freemarker-core/src/main/java/org/apache/freemarker/core/Environment.java
----------------------------------------------------------------------
diff --git 
a/freemarker-core/src/main/java/org/apache/freemarker/core/Environment.java 
b/freemarker-core/src/main/java/org/apache/freemarker/core/Environment.java
index 4288197..9434990 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/Environment.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/Environment.java
@@ -229,7 +229,8 @@ public final class Environment extends 
MutableProcessingConfiguration<Environmen
 
     /**
      * Returns the topmost {@link Template}, with other words, the one for 
which this {@link Environment} was created.
-     * That template will never change, like {@code #include} or macro calls 
don't change it.
+     * That template will never change, like {@code #include} or macro calls 
don't change it. This method never returns
+     * {@code null}.
      * 
      * @see #getCurrentNamespace()
      */
@@ -240,7 +241,9 @@ public final class Environment extends 
MutableProcessingConfiguration<Environmen
     /**
      * Returns the {@link Template} that we are "lexically" inside at the 
moment. This template will change when
      * entering an {@code #include} or calling a macro or function in another 
template, or returning to yet another
-     * template with {@code #nested}.
+     * template with {@code #nested}. When you are calling a directive that's 
implemented in Java or a Java method
+     * from a template, the current template will be the last current 
template, not {@code null}. This method never
+     * returns {@code null}.
      * 
      * @see #getMainTemplate()
      * @see #getCurrentNamespace()
@@ -251,14 +254,6 @@ public final class Environment extends 
MutableProcessingConfiguration<Environmen
         return ln == 0 ? getMainTemplate() : instructionStack[ln - 
1].getTemplate();
     }
 
-    public Template getCurrentTemplateNotNull() {
-        Template currentTemplate = getCurrentTemplate();
-        if (currentTemplate == null) {
-            throw new IllegalStateException("There's no current template at 
the moment.");
-        }
-        return currentTemplate;
-    }
-
     /**
      * Deletes cached values that meant to be valid only during a single 
template execution.
      */

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/e4207a53/freemarker-dom/src/main/java/org/apache/freemarker/dom/JaxenXPathSupport.java
----------------------------------------------------------------------
diff --git 
a/freemarker-dom/src/main/java/org/apache/freemarker/dom/JaxenXPathSupport.java 
b/freemarker-dom/src/main/java/org/apache/freemarker/dom/JaxenXPathSupport.java
index 4cd06ed..24ff94c 100644
--- 
a/freemarker-dom/src/main/java/org/apache/freemarker/dom/JaxenXPathSupport.java
+++ 
b/freemarker-dom/src/main/java/org/apache/freemarker/dom/JaxenXPathSupport.java
@@ -78,7 +78,7 @@ class JaxenXPathSupport implements XPathSupport {
     public TemplateModel executeQuery(Object context, String xpathQuery) 
throws TemplateException {
         try {
             BaseXPath xpath;
-            Map<String, BaseXPath> xpathCache = 
Environment.getCurrentEnvironmentNotNull().getCurrentTemplateNotNull()
+            Map<String, BaseXPath> xpathCache = 
Environment.getCurrentEnvironmentNotNull().getCurrentTemplate()
                     .getCustomState(XPATH_CACHE_ATTR);
             synchronized (xpathCache) {
                 xpath = xpathCache.get(xpathQuery);
@@ -177,7 +177,7 @@ class JaxenXPathSupport implements XPathSupport {
             try {
                 Template raw = getTemplate(uri);
                 _ObjectHolder<Document> docHolder = 
Environment.getCurrentEnvironmentNotNull()
-                        
.getCurrentTemplateNotNull().getCustomState(FM_DOM_NAVIAGOTOR_CACHED_DOM);
+                        
.getCurrentTemplate().getCustomState(FM_DOM_NAVIAGOTOR_CACHED_DOM);
                 synchronized (docHolder) {
                     Document doc = docHolder.get();
                     if (doc == null) {

Reply via email to