Return-Path: Delivered-To: apmail-struts-commits-archive@locus.apache.org Received: (qmail 28225 invoked from network); 28 Aug 2007 18:27:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 28 Aug 2007 18:27:15 -0000 Received: (qmail 83485 invoked by uid 500); 28 Aug 2007 18:27:09 -0000 Delivered-To: apmail-struts-commits-archive@struts.apache.org Received: (qmail 83449 invoked by uid 500); 28 Aug 2007 18:27:09 -0000 Mailing-List: contact commits-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 commits@struts.apache.org Received: (qmail 83440 invoked by uid 99); 28 Aug 2007 18:27:09 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Aug 2007 11:27:09 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Aug 2007 18:28:06 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id DAD0D1A9832; Tue, 28 Aug 2007 11:26:49 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r570518 - in /struts/struts2/trunk: apps/showcase/src/main/java/org/apache/struts2/showcase/source/ core/src/main/java/org/apache/struts2/components/template/ core/src/main/java/org/apache/struts2/dispatcher/ core/src/main/java/org/apache/s... Date: Tue, 28 Aug 2007 18:26:49 -0000 To: commits@struts.apache.org From: jholmes@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070828182649.DAD0D1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jholmes Date: Tue Aug 28 11:26:48 2007 New Revision: 570518 URL: http://svn.apache.org/viewvc?rev=570518&view=rev Log: WW-2142 input streams need to be explicitly closed Modified: struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/source/ViewSourceAction.java struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/template/BaseTemplateEngine.java struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/StreamResult.java struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerManager.java Modified: struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/source/ViewSourceAction.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/source/ViewSourceAction.java?rev=570518&r1=570517&r2=570518&view=diff ============================================================================== --- struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/source/ViewSourceAction.java (original) +++ struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/source/ViewSourceAction.java Tue Aug 28 11:26:48 2007 @@ -72,6 +72,10 @@ } } pageLines = read(in, -1); + + if (in != null) { + in.close(); + } } if (className != null && className.trim().length() > 0) { @@ -81,6 +85,10 @@ in = servletContext.getResourceAsStream("/WEB-INF/src"+className); } classLines = read(in, -1); + + if (in != null) { + in.close(); + } } String rootPath = ServletActionContext.getServletContext().getRealPath("/"); Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/template/BaseTemplateEngine.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/template/BaseTemplateEngine.java?rev=570518&r1=570517&r2=570518&view=diff ============================================================================== --- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/template/BaseTemplateEngine.java (original) +++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/template/BaseTemplateEngine.java Tue Aug 28 11:26:48 2007 @@ -52,7 +52,7 @@ if (props == null) { String propName = template.getDir() + "/" + template.getTheme() + "/"+getThemePropertiesFileName(); -// WW-1292 + // WW-1292 // let's try getting it from the filesystem File propFile = new File(propName); InputStream is = null; @@ -77,6 +77,12 @@ props.load(is); } catch (IOException e) { LOG.error("Could not load " + propName, e); + } finally { + try { + is.close(); + } catch(IOException io) { + LOG.warn("Unable to close input stream", io); + } } } Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/StreamResult.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/StreamResult.java?rev=570518&r1=570517&r2=570518&view=diff ============================================================================== --- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/StreamResult.java (original) +++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/StreamResult.java Tue Aug 28 11:26:48 2007 @@ -33,7 +33,7 @@ /** * * - * A custom Result type for send raw data (via an InputStream) directly to the + * A custom Result type for sending raw data (via an InputStream) directly to the * HttpServletResponse. Very useful for allowing users to download content. * * Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerManager.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerManager.java?rev=570518&r1=570517&r2=570518&view=diff ============================================================================== --- struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerManager.java (original) +++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerManager.java Tue Aug 28 11:26:48 2007 @@ -105,7 +105,7 @@ */ public class FreemarkerManager { - private static final Log log = LogFactory.getLog(FreemarkerManager.class); + private static final Log LOG = LogFactory.getLog(FreemarkerManager.class); public static final String CONFIG_SERVLET_CONTEXT_KEY = "freemarker.Configuration"; public static final String KEY_EXCEPTION = "exception"; @@ -270,7 +270,7 @@ try { templatePathLoader = new FileTemplateLoader(new File(templatePath)); } catch (IOException e) { - log.error("Invalid template path specified: " + e.getMessage(), e); + LOG.error("Invalid template path specified: " + e.getMessage(), e); } } @@ -325,8 +325,10 @@ * @see freemarker.template.Configuration#setSettings for the definition of valid settings */ protected void loadSettings(ServletContext servletContext, freemarker.template.Configuration configuration) { + InputStream in = null; + try { - InputStream in = FileManager.loadFile("freemarker.properties", FreemarkerManager.class); + in = FileManager.loadFile("freemarker.properties", FreemarkerManager.class); if (in != null) { Properties p = new Properties(); @@ -334,9 +336,17 @@ configuration.setSettings(p); } } catch (IOException e) { - log.error("Error while loading freemarker settings from /freemarker.properties", e); + LOG.error("Error while loading freemarker settings from /freemarker.properties", e); } catch (TemplateException e) { - log.error("Error while loading freemarker settings from /freemarker.properties", e); + LOG.error("Error while loading freemarker settings from /freemarker.properties", e); + } finally { + if (in != null) { + try { + in.close(); + } catch(IOException io) { + LOG.warn("Unable to close input stream", io); + } + } } }