Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 6B82A200D05 for ; Tue, 8 Aug 2017 00:32:17 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 6A32A1662EE; Mon, 7 Aug 2017 22:32:17 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 6A32A1662A0 for ; Tue, 8 Aug 2017 00:32:16 +0200 (CEST) Received: (qmail 28864 invoked by uid 500); 7 Aug 2017 22:32:15 -0000 Mailing-List: contact notifications-help@freemarker.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@freemarker.incubator.apache.org Delivered-To: mailing list notifications@freemarker.incubator.apache.org Received: (qmail 28848 invoked by uid 99); 7 Aug 2017 22:32:15 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Aug 2017 22:32:15 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 239B31A1BA8 for ; Mon, 7 Aug 2017 22:32:15 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.222 X-Spam-Level: X-Spam-Status: No, score=-4.222 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id IrjWnIicZNSw for ; Mon, 7 Aug 2017 22:32:08 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id 2EE1361B3C for ; Mon, 7 Aug 2017 22:32:04 +0000 (UTC) Received: (qmail 28200 invoked by uid 99); 7 Aug 2017 22:32:04 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Aug 2017 22:32:04 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id AD548F5853; Mon, 7 Aug 2017 22:32:03 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ddekany@apache.org To: notifications@freemarker.incubator.apache.org Date: Mon, 07 Aug 2017 22:32:18 -0000 Message-Id: <7dbeb2677dd94dac953671a8a5051376@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [16/21] incubator-freemarker git commit: FREEMARKER-63: Removed NestedContentNotSupportedException, as TemplateDirectiveModel.isNestedContentSupported() now takes care of that problem. archived-at: Mon, 07 Aug 2017 22:32:17 -0000 FREEMARKER-63: Removed NestedContentNotSupportedException, as TemplateDirectiveModel.isNestedContentSupported() now takes care of that problem. Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/da4c3329 Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/da4c3329 Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/da4c3329 Branch: refs/heads/3 Commit: da4c33292d5d73cdfb53613ca64bd0834fcfb5fd Parents: 5bd19ad Author: ddekany Authored: Sun Jul 30 23:20:34 2017 +0200 Committer: ddekany Committed: Sun Jul 30 23:22:02 2017 +0200 ---------------------------------------------------------------------- FM3-CHANGE-LOG.txt | 2 + .../core/userpkg/NamedVarargsOnlyDirective.java | 2 - .../userpkg/PositionalVarargsOnlyDirective.java | 2 - .../NestedContentNotSupportedException.java | 57 -------------------- ...nterruptionSupportTemplatePostProcessor.java | 8 ++- .../test/templateutil/AssertDirective.java | 3 -- .../templateutil/AssertEqualsDirective.java | 3 -- 7 files changed, 5 insertions(+), 72 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/da4c3329/FM3-CHANGE-LOG.txt ---------------------------------------------------------------------- diff --git a/FM3-CHANGE-LOG.txt b/FM3-CHANGE-LOG.txt index 938f9bf..21ce533 100644 --- a/FM3-CHANGE-LOG.txt +++ b/FM3-CHANGE-LOG.txt @@ -424,6 +424,8 @@ Core / Miscellaneous get(), to be more similar to the Java 8 API. - Removed the legacy predefined shared variables: "html_escape", "normalize_newlines", "xml_escape", "capture_output", "compress" +- Removed `NestedContentNotSupportedException`, as `TemplateDirectiveModel.isNestedContentSupported()` now takes care + of that problem. Build / development process changes http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/da4c3329/freemarker-core-test/src/test/java/org/apache/freemarker/core/userpkg/NamedVarargsOnlyDirective.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/userpkg/NamedVarargsOnlyDirective.java b/freemarker-core-test/src/test/java/org/apache/freemarker/core/userpkg/NamedVarargsOnlyDirective.java index f978dbe..fed4bc7 100644 --- a/freemarker-core-test/src/test/java/org/apache/freemarker/core/userpkg/NamedVarargsOnlyDirective.java +++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/userpkg/NamedVarargsOnlyDirective.java @@ -23,7 +23,6 @@ import java.io.IOException; import java.io.Writer; import org.apache.freemarker.core.Environment; -import org.apache.freemarker.core.NestedContentNotSupportedException; import org.apache.freemarker.core.TemplateException; import org.apache.freemarker.core.model.ArgumentArrayLayout; import org.apache.freemarker.core.model.CallPlace; @@ -46,7 +45,6 @@ public class NamedVarargsOnlyDirective extends TestTemplateDirectiveModel { @Override public void execute(TemplateModel[] args, CallPlace callPlace, Writer out, Environment env) throws TemplateException, IOException { - NestedContentNotSupportedException.check(callPlace); out.write("#nvo("); printParam("nVarargs", args[NAMED_VARARGS_ARG_IDX], out, true); out.write(")"); http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/da4c3329/freemarker-core-test/src/test/java/org/apache/freemarker/core/userpkg/PositionalVarargsOnlyDirective.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/userpkg/PositionalVarargsOnlyDirective.java b/freemarker-core-test/src/test/java/org/apache/freemarker/core/userpkg/PositionalVarargsOnlyDirective.java index b9d2b92..540a641 100644 --- a/freemarker-core-test/src/test/java/org/apache/freemarker/core/userpkg/PositionalVarargsOnlyDirective.java +++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/userpkg/PositionalVarargsOnlyDirective.java @@ -23,7 +23,6 @@ import java.io.IOException; import java.io.Writer; import org.apache.freemarker.core.Environment; -import org.apache.freemarker.core.NestedContentNotSupportedException; import org.apache.freemarker.core.TemplateException; import org.apache.freemarker.core.model.ArgumentArrayLayout; import org.apache.freemarker.core.model.CallPlace; @@ -44,7 +43,6 @@ public class PositionalVarargsOnlyDirective extends TestTemplateDirectiveModel { @Override public void execute(TemplateModel[] args, CallPlace callPlace, Writer out, Environment env) throws TemplateException, IOException { - NestedContentNotSupportedException.check(callPlace); out.write("#pvo("); printParam("pVarargs", args[ARGS_LAYOUT.getPositionalVarargsArgumentIndex()], out, true); out.write(")"); http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/da4c3329/freemarker-core/src/main/java/org/apache/freemarker/core/NestedContentNotSupportedException.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/NestedContentNotSupportedException.java b/freemarker-core/src/main/java/org/apache/freemarker/core/NestedContentNotSupportedException.java deleted file mode 100644 index a6e6be5..0000000 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/NestedContentNotSupportedException.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.freemarker.core; - -import org.apache.freemarker.core.model.CallPlace; -import org.apache.freemarker.core.model.TemplateDirectiveModel; -import org.apache.freemarker.core.util._StringUtil; - -/** - * Used in custom {@link TemplateDirectiveModel}-s to check if the directive invocation has no body. This is more - * intelligent than a {@code null} check; for example, when the body only contains a thread interruption check node, it - * treats it as valid. - */ -public class NestedContentNotSupportedException extends TemplateException { - - public static void check(CallPlace body) throws NestedContentNotSupportedException { - if (body.hasNestedContent()) { - throw new NestedContentNotSupportedException(Environment.getCurrentEnvironment()); - } - } - - private NestedContentNotSupportedException(Environment env) { - this(null, null, env); - } - - private NestedContentNotSupportedException(Exception cause, Environment env) { - this(null, cause, env); - } - - private NestedContentNotSupportedException(String description, Environment env) { - this(description, null, env); - } - - private NestedContentNotSupportedException(String description, Exception cause, Environment env) { - super( "Nested content (body) not supported." - + (description != null ? " " + _StringUtil.jQuote(description) : ""), - cause, env); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/da4c3329/freemarker-core/src/main/java/org/apache/freemarker/core/ThreadInterruptionSupportTemplatePostProcessor.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/ThreadInterruptionSupportTemplatePostProcessor.java b/freemarker-core/src/main/java/org/apache/freemarker/core/ThreadInterruptionSupportTemplatePostProcessor.java index 687675c..71db276 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/ThreadInterruptionSupportTemplatePostProcessor.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ThreadInterruptionSupportTemplatePostProcessor.java @@ -30,10 +30,6 @@ import org.apache.freemarker.core.model.TemplateDateModel; *

* Known compatibility risks when using this post-processor: *

    - *
  • {@link TemplateDateModel}-s that care to explicitly check if their nested content is {@code null} might start to - * complain that you have specified a body despite that the directive doesn't support that. Directives should use - * {@link NestedContentNotSupportedException#check(CallPlace)} instead of a simple - * {@code null}-check to avoid this problem.
  • *
  • * Software that uses {@link CallPlace#isNestedOutputCacheable()} will always get {@code false}, because * interruption checks ({@link ASTThreadInterruptionCheck} elements) are, obviously, not cacheable. This should only @@ -41,7 +37,9 @@ import org.apache.freemarker.core.model.TemplateDateModel; *
  • * Software that investigates the AST will see the injected {@link ASTThreadInterruptionCheck} elements. As of this * writing the AST API-s aren't published, also such software need to be able to deal with new kind of elements - * anyway, so this shouldn't be a problem. + * anyway, so this shouldn't be a problem. When a {@link TemplateDateModel} checks if it has no nested content, it + * should always use {@link CallPlace#hasNestedContent()}, which will ignore nested content that only + * contains a {@link ASTThreadInterruptionCheck}. *
*/ class ThreadInterruptionSupportTemplatePostProcessor extends TemplatePostProcessor { http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/da4c3329/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/AssertDirective.java ---------------------------------------------------------------------- diff --git a/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/AssertDirective.java b/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/AssertDirective.java index ffb2c40..50ffe60 100644 --- a/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/AssertDirective.java +++ b/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/AssertDirective.java @@ -23,7 +23,6 @@ import java.io.IOException; import java.io.Writer; import org.apache.freemarker.core.Environment; -import org.apache.freemarker.core.NestedContentNotSupportedException; import org.apache.freemarker.core.TemplateException; import org.apache.freemarker.core.model.ArgumentArrayLayout; import org.apache.freemarker.core.model.CallPlace; @@ -48,8 +47,6 @@ public class AssertDirective implements TemplateDirectiveModel { @Override public void execute(TemplateModel[] args, CallPlace callPlace, Writer out, Environment env) throws TemplateException, IOException { - NestedContentNotSupportedException.check(callPlace); - TemplateModel test = args[TEST_ARG_IDX]; if (test == null) { throw new MissingRequiredParameterException(TEST_ARG_NAME, env); http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/da4c3329/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/AssertEqualsDirective.java ---------------------------------------------------------------------- diff --git a/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/AssertEqualsDirective.java b/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/AssertEqualsDirective.java index 8334c20..fda0d22 100644 --- a/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/AssertEqualsDirective.java +++ b/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/AssertEqualsDirective.java @@ -23,7 +23,6 @@ import java.io.IOException; import java.io.Writer; import org.apache.freemarker.core.Environment; -import org.apache.freemarker.core.NestedContentNotSupportedException; import org.apache.freemarker.core.TemplateException; import org.apache.freemarker.core.model.ArgumentArrayLayout; import org.apache.freemarker.core.model.CallPlace; @@ -60,8 +59,6 @@ public class AssertEqualsDirective implements TemplateDirectiveModel { @Override public void execute(TemplateModel[] args, CallPlace callPlace, Writer out, Environment env) throws TemplateException, IOException { - NestedContentNotSupportedException.check(callPlace); - TemplateModel actual = args[ACTUAL_ARG_IDX]; if (actual == null) { throw new MissingRequiredParameterException(ACTUAL_ARG_NAME, env);