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 A55BF200C73 for ; Wed, 10 May 2017 16:40:14 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id A3D55160BA8; Wed, 10 May 2017 14:40:14 +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 EA4D1160B9C for ; Wed, 10 May 2017 16:40:13 +0200 (CEST) Received: (qmail 58055 invoked by uid 500); 10 May 2017 14:40:13 -0000 Mailing-List: contact issues-help@struts.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@struts.apache.org Delivered-To: mailing list issues@struts.apache.org Received: (qmail 58045 invoked by uid 99); 10 May 2017 14:40:13 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 10 May 2017 14:40:13 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 9A639C0E12 for ; Wed, 10 May 2017 14:40:12 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.201 X-Spam-Level: X-Spam-Status: No, score=-99.201 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id b20RsYiTtOxk for ; Wed, 10 May 2017 14:40:12 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id C771B5FC7F for ; Wed, 10 May 2017 14:40:11 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 5B225E01A8 for ; Wed, 10 May 2017 14:40:11 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 6A2B621E22 for ; Wed, 10 May 2017 14:40:05 +0000 (UTC) Date: Wed, 10 May 2017 14:40:05 +0000 (UTC) From: "ASF subversion and git services (JIRA)" To: issues@struts.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (WW-4749) Buffer/Flush behaviour in FreemarkerResult MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Wed, 10 May 2017 14:40:14 -0000 [ https://issues.apache.org/jira/browse/WW-4749?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16004786#comment-16004786 ] ASF subversion and git services commented on WW-4749: ----------------------------------------------------- Commit bbcd9dc2514b286065a16657d58418aa9ef4be75 in struts's branch refs/heads/master from [~lukaszlenart] [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=bbcd9dc ] WW-4749 Uses ordinary boolean instead of Boolean > Buffer/Flush behaviour in FreemarkerResult > ------------------------------------------ > > Key: WW-4749 > URL: https://issues.apache.org/jira/browse/WW-4749 > Project: Struts 2 > Issue Type: Improvement > Components: Core Results > Affects Versions: 2.3.31, 2.5.1 > Reporter: Lorenzo Bernacchioni > Assignee: Lukasz Lenart > Priority: Minor > Fix For: 2.5.next > > > Scenario: the application use freemarker with a {{TemplateExceptionHandler.RETHROW_HANDLER}} policy, but occasionally needs to produce large XML (20~200Mb) and goes out of memory. > In [FreemarkerResult|http://grepcode.com/file/repo1.maven.org/maven2/org.apache.struts/struts2-core/2.5-BETA1/org/apache/struts2/views/freemarker/FreemarkerResult.java#191] there are two possible behaviours (line 191): > * *Buffer-behaviour*: the whole template is processed and if everything is OK it is flushed to the output, otherwise an exception is thrown and handled at higher level before any output has been sent. This is intended to be used when {{TemplateExceptionHandler.RETHROW_HANDLER}} is active > * *Flush-behaviour*: template is processed and flushed according to freemarker library policies, used with any other {{TemplateExceptionHandler}} > Since {{TemplateExceptionHandler}} cannot be switched for a given request (it is a global configuration embedded in {{FreemarkerManager}}) there is no way to force a Flush-behaviour. (you can only force a Buffer-behaviour using {{isWriteIfCompleted}}) > I implemented a more flexible solution that let you force the behaviour in both ways: > {code:title=FreemarkerResult.java|borderStyle=solid} > final boolean willUsebufferedWriter; > if (useBufferedWriter != null){ > willUsebufferedWriter = useBufferedWriter; > }else{ > willUsebufferedWriter = configuration.getTemplateExceptionHandler() == TemplateExceptionHandler.RETHROW_HANDLER; > } > > if (willUsebufferedWriter){ > ... > }else{ > ... > } > {code} > where {{useBufferedWriter}} is a parameter that can be modified per request > {code} > > big_feed.ftl > text/xml > false > > {code} -- This message was sent by Atlassian JIRA (v6.3.15#6346)