Author: jholmes
Date: Tue Aug 28 11:14:00 2007
New Revision: 570513
URL: http://svn.apache.org/viewvc?rev=570513&view=rev
Log:
WW-2142 input streams need to be explicitly closed
Modified:
struts/struts2/branches/STRUTS_2_0_X/apps/showcase/src/main/java/org/apache/struts2/showcase/source/ViewSourceAction.java
struts/struts2/branches/STRUTS_2_0_X/core/src/main/java/org/apache/struts2/components/template/BaseTemplateEngine.java
struts/struts2/branches/STRUTS_2_0_X/core/src/main/java/org/apache/struts2/dispatcher/StreamResult.java
struts/struts2/branches/STRUTS_2_0_X/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerManager.java
struts/struts2/branches/STRUTS_2_0_X/core/src/site/resources/tags/tabbedPanel.html
struts/struts2/branches/STRUTS_2_0_X/core/src/site/resources/tags/url.html
Modified:
struts/struts2/branches/STRUTS_2_0_X/apps/showcase/src/main/java/org/apache/struts2/showcase/source/ViewSourceAction.java
URL:
http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_2_0_X/apps/showcase/src/main/java/org/apache/struts2/showcase/source/ViewSourceAction.java?rev=570513&r1=570512&r2=570513&view=diff
==============================================================================
---
struts/struts2/branches/STRUTS_2_0_X/apps/showcase/src/main/java/org/apache/struts2/showcase/source/ViewSourceAction.java
(original)
+++
struts/struts2/branches/STRUTS_2_0_X/apps/showcase/src/main/java/org/apache/struts2/showcase/source/ViewSourceAction.java
Tue Aug 28 11:14:00 2007
@@ -70,15 +70,23 @@
}
}
pageLines = read(in, -1);
+
+ if (in != null) {
+ in.close();
+ }
}
if (className != null && className.trim().length() > 0) {
- className = "/"+className.replace('.', '/') + ".java";
+ className = "/" + className.replace('.', '/') + ".java";
InputStream in = getClass().getResourceAsStream(className);
if (in == null) {
in =
servletContext.getResourceAsStream("/WEB-INF/src"+className);
}
classLines = read(in, -1);
+
+ if (in != null) {
+ in.close();
+ }
}
if (config != null && config.trim().length() > 0) {
@@ -118,8 +126,6 @@
this.padding = padding;
}
-
-
/**
* @return the classLines
*/
@@ -215,6 +221,4 @@
public void setServletContext(ServletContext arg0) {
this.servletContext = arg0;
}
-
-
}
Modified:
struts/struts2/branches/STRUTS_2_0_X/core/src/main/java/org/apache/struts2/components/template/BaseTemplateEngine.java
URL:
http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_2_0_X/core/src/main/java/org/apache/struts2/components/template/BaseTemplateEngine.java?rev=570513&r1=570512&r2=570513&view=diff
==============================================================================
---
struts/struts2/branches/STRUTS_2_0_X/core/src/main/java/org/apache/struts2/components/template/BaseTemplateEngine.java
(original)
+++
struts/struts2/branches/STRUTS_2_0_X/core/src/main/java/org/apache/struts2/components/template/BaseTemplateEngine.java
Tue Aug 28 11:14:00 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/branches/STRUTS_2_0_X/core/src/main/java/org/apache/struts2/dispatcher/StreamResult.java
URL:
http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_2_0_X/core/src/main/java/org/apache/struts2/dispatcher/StreamResult.java?rev=570513&r1=570512&r2=570513&view=diff
==============================================================================
---
struts/struts2/branches/STRUTS_2_0_X/core/src/main/java/org/apache/struts2/dispatcher/StreamResult.java
(original)
+++
struts/struts2/branches/STRUTS_2_0_X/core/src/main/java/org/apache/struts2/dispatcher/StreamResult.java
Tue Aug 28 11:14:00 2007
@@ -33,7 +33,7 @@
/**
* <!-- START SNIPPET: description -->
*
- * 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.
*
* <!-- END SNIPPET: description -->
Modified:
struts/struts2/branches/STRUTS_2_0_X/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerManager.java
URL:
http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_2_0_X/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerManager.java?rev=570513&r1=570512&r2=570513&view=diff
==============================================================================
---
struts/struts2/branches/STRUTS_2_0_X/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerManager.java
(original)
+++
struts/struts2/branches/STRUTS_2_0_X/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerManager.java
Tue Aug 28 11:14:00 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";
@@ -262,7 +262,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);
}
}
@@ -317,8 +317,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();
@@ -326,9 +328,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);
+ }
+ }
}
}
Modified:
struts/struts2/branches/STRUTS_2_0_X/core/src/site/resources/tags/tabbedPanel.html
URL:
http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_2_0_X/core/src/site/resources/tags/tabbedPanel.html?rev=570513&r1=570512&r2=570513&view=diff
==============================================================================
---
struts/struts2/branches/STRUTS_2_0_X/core/src/site/resources/tags/tabbedPanel.html
(original)
+++
struts/struts2/branches/STRUTS_2_0_X/core/src/site/resources/tags/tabbedPanel.html
Tue Aug 28 11:14:00 2007
@@ -327,7 +327,7 @@
<td align="left"
valign="top">useSelectedTabCookie</td>
<td align="left" valign="top">false</td>
<td align="left" valign="top">false</td>
- <td align="left" valign="top">true</td>
+ <td align="left" valign="top">false</td>
<td align="left"
valign="top">String</td>
<td align="left" valign="top">If set to
true, the id of the last selected tab will be stored in cookie. If the view is
rendered, it will be tried to read this cookie and activate the corresponding
tab on success, unless overridden by the selectedTab attribute. The cookie name
is "Struts2TabbedPanel_selectedTab_"+id.</td>
</tr>
Modified:
struts/struts2/branches/STRUTS_2_0_X/core/src/site/resources/tags/url.html
URL:
http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_2_0_X/core/src/site/resources/tags/url.html?rev=570513&r1=570512&r2=570513&view=diff
==============================================================================
--- struts/struts2/branches/STRUTS_2_0_X/core/src/site/resources/tags/url.html
(original)
+++ struts/struts2/branches/STRUTS_2_0_X/core/src/site/resources/tags/url.html
Tue Aug 28 11:14:00 2007
@@ -121,7 +121,7 @@
<td align="left" valign="top"></td>
<td align="left" valign="top">false</td>
<td align="left"
valign="top">String</td>
- <td align="left" valign="top">Specifies
if this should be a portlet render or action URL</td>
+ <td align="left" valign="top">Specifies
if this should be a portlet render or action URL. Default is "render". To
create an action URL, use "action".</td>
</tr>
<tr>
<td align="left"
valign="top">scheme</td>