struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcucchi...@apache.org
Subject svn commit: r1097343 - /struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/PlainTextResult.java
Date Thu, 28 Apr 2011 07:51:45 GMT
Author: mcucchiara
Date: Thu Apr 28 07:51:45 2011
New Revision: 1097343

URL: http://svn.apache.org/viewvc?rev=1097343&view=rev
Log:
WW-3615 - Dead code in PlainTextResult

Modified:
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/PlainTextResult.java

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/PlainTextResult.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/PlainTextResult.java?rev=1097343&r1=1097342&r2=1097343&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/PlainTextResult.java
(original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/PlainTextResult.java
Thu Apr 28 07:51:45 2011
@@ -21,17 +21,17 @@
 
 package org.apache.struts2.dispatcher;
 
-import java.io.InputStreamReader;
-import java.io.PrintWriter;
-import java.nio.charset.Charset;
-
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletResponse;
-
 import com.opensymphony.xwork2.ActionInvocation;
 import com.opensymphony.xwork2.util.logging.Logger;
 import com.opensymphony.xwork2.util.logging.LoggerFactory;
 
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletResponse;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.nio.charset.Charset;
+
 /**
  * <!-- START SNIPPET: description -->
  *
@@ -141,24 +141,22 @@ public class PlainTextResult extends Str
         PrintWriter writer = response.getWriter();
         InputStreamReader reader = null;
         try {
+        	InputStream resourceAsStream = servletContext.getResourceAsStream(finalLocation);
             if (charset != null) {
-                reader = new InputStreamReader(servletContext.getResourceAsStream(finalLocation),
charset);
-            }
-            else {
-                reader = new InputStreamReader(servletContext.getResourceAsStream(finalLocation));
-            }
-            if (reader == null) {
-                LOG.warn("resource at location ["+finalLocation+"] cannot be obtained (return
null) from ServletContext !!! ");
-            }
-            else {
+                reader = new InputStreamReader(resourceAsStream, charset);
+            } else {
+                reader = new InputStreamReader(resourceAsStream);
+            }
+            if (resourceAsStream == null) {
+            	LOG.warn("resource at location ["+finalLocation+"] cannot be obtained (return
null) from ServletContext !!! ");
+            } else {
                 char[] buffer = new char[BUFFER_SIZE];
-                int charRead = 0;
+                int charRead;
                 while((charRead = reader.read(buffer)) != -1) {
                     writer.write(buffer, 0, charRead);
                 }
             }
-        }
-        finally {
+        } finally {
             if (reader != null)
                 reader.close();
             if (writer != null) {



Mime
View raw message